Skip to content

Commit

Permalink
[8.15] [Fleet] Fix get one agent when feature flag disabled (#188953) (
Browse files Browse the repository at this point in the history
…#188981)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Fleet] Fix get one agent when feature flag disabled
(#188953)](#188953)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Nicolas
Chaulet","email":"nicolas.chaulet@elastic.co"},"sourceCommit":{"committedDate":"2024-07-23T16:15:31Z","message":"[Fleet]
Fix get one agent when feature flag disabled
(#188953)","sha":"ebdc6be5d2e42b4bb66dcedaaa22a7642c9edd9d","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v8.16.0"],"title":"[Fleet]
Fix get one agent when feature flag
disabled","number":188953,"url":"https://github.com/elastic/kibana/pull/188953","mergeCommit":{"message":"[Fleet]
Fix get one agent when feature flag disabled
(#188953)","sha":"ebdc6be5d2e42b4bb66dcedaaa22a7642c9edd9d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188953","number":188953,"mergeCommit":{"message":"[Fleet]
Fix get one agent when feature flag disabled
(#188953)","sha":"ebdc6be5d2e42b4bb66dcedaaa22a7642c9edd9d"}}]}]
BACKPORT-->

Co-authored-by: Nicolas Chaulet <nicolas.chaulet@elastic.co>
  • Loading branch information
kibanamachine and nchaulet authored Jul 23, 2024
1 parent 2383eba commit ab83a81
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x-pack/plugins/fleet/server/routes/agent/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ import { defaultFleetErrorHandler, FleetNotFoundError } from '../../errors';
import * as AgentService from '../../services/agents';
import { fetchAndAssignAgentMetrics } from '../../services/agents/agent_metrics';
import { getAgentStatusForAgentPolicy } from '../../services/agents';
import { appContextService } from '../../services';

export function verifyNamespace(agent: Agent, currentNamespace?: string) {
if (!appContextService.getExperimentalFeatures().useSpaceAwareness) {
return;
}
const isInNamespace =
(currentNamespace && agent.namespaces?.includes(currentNamespace)) ||
(!currentNamespace &&
Expand Down

0 comments on commit ab83a81

Please sign in to comment.