mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.10`: - [[Profiling] checking viewer resources in the admin check (#164086)](https://github.com/elastic/kibana/pull/164086) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Cauê Marcondes","email":"55978943+cauemarcondes@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-08-22T10:14:18Z","message":"[Profiling] checking viewer resources in the admin check (#164086)\n\nWe identified a bug in the set up check where for admin users we should\r\nalso include the checks that were made in the step above.\r\n\r\nWe also decided to revert the changes in the package names.\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco Gualazzi <inge4pres@users.noreply.github.com>","sha":"2e854d65ce0bc7bbe579d90582151f2ebe50d004","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:skip","ci:build-cloud-image","v8.10.0","v8.11.0"],"number":164086,"url":"https://github.com/elastic/kibana/pull/164086","mergeCommit":{"message":"[Profiling] checking viewer resources in the admin check (#164086)\n\nWe identified a bug in the set up check where for admin users we should\r\nalso include the checks that were made in the step above.\r\n\r\nWe also decided to revert the changes in the package names.\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco Gualazzi <inge4pres@users.noreply.github.com>","sha":"2e854d65ce0bc7bbe579d90582151f2ebe50d004"}},"sourceBranch":"main","suggestedTargetBranches":["8.10"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164086","number":164086,"mergeCommit":{"message":"[Profiling] checking viewer resources in the admin check (#164086)\n\nWe identified a bug in the set up check where for admin users we should\r\nalso include the checks that were made in the step above.\r\n\r\nWe also decided to revert the changes in the package names.\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco Gualazzi <inge4pres@users.noreply.github.com>","sha":"2e854d65ce0bc7bbe579d90582151f2ebe50d004"}}]}] BACKPORT--> Co-authored-by: Cauê Marcondes <55978943+cauemarcondes@users.noreply.github.com>
This commit is contained in:
parent
96c2337d3e
commit
aeedd83a9b
4 changed files with 60 additions and 8 deletions
|
@ -82,6 +82,9 @@ describe('Merging partial state operations', () => {
|
|||
const defaultSetupState = createDefaultSetupState();
|
||||
it('returns false when permission is not configured', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(true),
|
||||
createSymbolizerPolicyState(true),
|
||||
createProfilingInApmPolicyState(true),
|
||||
createResourceState({ enabled: true, created: true }),
|
||||
createSettingsState(true),
|
||||
createPermissionState(false),
|
||||
|
@ -92,6 +95,9 @@ describe('Merging partial state operations', () => {
|
|||
|
||||
it('returns false when resource management is not enabled', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(true),
|
||||
createSymbolizerPolicyState(true),
|
||||
createProfilingInApmPolicyState(true),
|
||||
createResourceState({ enabled: false, created: true }),
|
||||
createSettingsState(true),
|
||||
createPermissionState(true),
|
||||
|
@ -102,6 +108,9 @@ describe('Merging partial state operations', () => {
|
|||
|
||||
it('returns false when resources are not created', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(true),
|
||||
createSymbolizerPolicyState(true),
|
||||
createProfilingInApmPolicyState(true),
|
||||
createResourceState({ enabled: true, created: false }),
|
||||
createSettingsState(true),
|
||||
createPermissionState(true),
|
||||
|
@ -112,6 +121,9 @@ describe('Merging partial state operations', () => {
|
|||
|
||||
it('returns false when settings are not configured', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(true),
|
||||
createSymbolizerPolicyState(true),
|
||||
createProfilingInApmPolicyState(true),
|
||||
createResourceState({ enabled: true, created: true }),
|
||||
createSettingsState(false),
|
||||
createPermissionState(true),
|
||||
|
@ -122,6 +134,9 @@ describe('Merging partial state operations', () => {
|
|||
|
||||
it('returns true when all checks are valid', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(true),
|
||||
createSymbolizerPolicyState(true),
|
||||
createProfilingInApmPolicyState(false),
|
||||
createResourceState({ enabled: true, created: true }),
|
||||
createSettingsState(true),
|
||||
createPermissionState(true),
|
||||
|
@ -129,6 +144,45 @@ describe('Merging partial state operations', () => {
|
|||
|
||||
expect(areResourcesSetupForAdmin(mergedState)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('returns false when collector is not found', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(false),
|
||||
createSymbolizerPolicyState(true),
|
||||
createProfilingInApmPolicyState(false),
|
||||
createResourceState({ enabled: true, created: true }),
|
||||
createSettingsState(true),
|
||||
createPermissionState(true),
|
||||
]);
|
||||
|
||||
expect(areResourcesSetupForAdmin(mergedState)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns false when symbolizer is not found', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(true),
|
||||
createSymbolizerPolicyState(false),
|
||||
createProfilingInApmPolicyState(false),
|
||||
createResourceState({ enabled: true, created: true }),
|
||||
createSettingsState(true),
|
||||
createPermissionState(true),
|
||||
]);
|
||||
|
||||
expect(areResourcesSetupForAdmin(mergedState)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('returns false when profiling is in APM server', () => {
|
||||
const mergedState = mergePartialSetupStates(defaultSetupState, [
|
||||
createCollectorPolicyState(true),
|
||||
createSymbolizerPolicyState(true),
|
||||
createProfilingInApmPolicyState(true),
|
||||
createResourceState({ enabled: true, created: true }),
|
||||
createSettingsState(true),
|
||||
createPermissionState(true),
|
||||
]);
|
||||
|
||||
expect(areResourcesSetupForAdmin(mergedState)).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('For viewer users', () => {
|
||||
|
|
|
@ -88,6 +88,7 @@ export function areResourcesSetupForViewer(state: SetupState): boolean {
|
|||
|
||||
export function areResourcesSetupForAdmin(state: SetupState): boolean {
|
||||
return (
|
||||
areResourcesSetupForViewer(state) &&
|
||||
state.resource_management.enabled &&
|
||||
state.resources.created &&
|
||||
state.permissions.configured &&
|
||||
|
|
|
@ -15,8 +15,8 @@ import { ELASTIC_CLOUD_APM_POLICY, getApmPolicy } from './get_apm_policy';
|
|||
import { ProfilingSetupOptions } from './types';
|
||||
|
||||
const CLOUD_AGENT_POLICY_ID = 'policy-elastic-agent-on-cloud';
|
||||
const COLLECTOR_PACKAGE_POLICY_NAME = 'Universal Profiling Collector';
|
||||
const SYMBOLIZER_PACKAGE_POLICY_NAME = 'Universal Profiling Symbolizer';
|
||||
const COLLECTOR_PACKAGE_POLICY_NAME = 'elastic-universal-profiling-collector';
|
||||
const SYMBOLIZER_PACKAGE_POLICY_NAME = 'elastic-universal-profiling-symbolizer';
|
||||
|
||||
async function getPackagePolicy({
|
||||
soClient,
|
||||
|
@ -103,7 +103,7 @@ export async function createCollectorPackagePolicy({
|
|||
enabled: true,
|
||||
package: {
|
||||
name: packageName,
|
||||
title: COLLECTOR_PACKAGE_POLICY_NAME,
|
||||
title: 'Universal Profiling Collector',
|
||||
version,
|
||||
},
|
||||
name: COLLECTOR_PACKAGE_POLICY_NAME,
|
||||
|
@ -161,7 +161,7 @@ export async function createSymbolizerPackagePolicy({
|
|||
enabled: true,
|
||||
package: {
|
||||
name: packageName,
|
||||
title: SYMBOLIZER_PACKAGE_POLICY_NAME,
|
||||
title: 'Universal Profiling Symbolizer',
|
||||
version,
|
||||
},
|
||||
name: SYMBOLIZER_PACKAGE_POLICY_NAME,
|
||||
|
|
|
@ -110,10 +110,7 @@ export function registerSetupRoute({
|
|||
* because of users with viewer privileges
|
||||
* cannot get the cluster settings
|
||||
*/
|
||||
if (
|
||||
areResourcesSetupForViewer(mergedStateForViewer) &&
|
||||
mergedStateForViewer.data.available
|
||||
) {
|
||||
if (areResourcesSetupForViewer(mergedStateForViewer)) {
|
||||
return response.ok({
|
||||
body: {
|
||||
has_setup: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue