Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Update package policy id when agent id changes #151886

Merged
merged 5 commits into from
Feb 26, 2023

Conversation

orouz
Copy link
Contributor

@orouz orouz commented Feb 22, 2023

Summary

closes https://github.com/elastic/security-team/issues/6001 (2nd screenshot)

there is an effect firing in StepDefinePackagePolicy that keeps package policy id in sync with agent policy.
after merging #149653, usage of this new extension point will require duplicating that effect. this PR lifts it to the onSubmit hook.

Comment on lines -89 to -100
// Update package policy's package and agent policy info
useEffect(() => {
// TODO move this to parent hook
// If agent policy has changed, update package policy's agent policy ID and namespace
if (agentPolicy && packagePolicy.policy_id !== agentPolicy.id) {
updatePackagePolicy({
policy_id: agentPolicy.id,
namespace: agentPolicy.namespace,
});
}
}, [packagePolicy, agentPolicy, packageInfo, updatePackagePolicy]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this effect was lifted to a single parent hook - onSubmit, which is 1 of 3 usages. the other two are not relevant:

  • edit screen doesn't allow changing agent policy
  • multi page layout doesn't use package-policy-replace-define-step

alternatively, we can instead keep it as is and duplicate it in our custom extension component.

@orouz orouz added the ci:cloud-redeploy Always create a new Cloud deployment label Feb 22, 2023
@orouz orouz added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:Fleet Team label for Observability Data Collection Fleet team v8.7.0 labels Feb 23, 2023
@orouz orouz requested a review from kpollich February 23, 2023 09:59
@orouz orouz marked this pull request as ready for review February 23, 2023 09:59
@orouz orouz requested a review from a team as a code owner February 23, 2023 09:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀
We already have some unit tests bootstrapped for that form hook it will be great and help document that behavior if we can add a unit test here.

@kfirpeled kfirpeled removed the backport:skip This commit does not require backporting label Feb 23, 2023
@kibana-ci
Copy link
Collaborator

kibana-ci commented Feb 26, 2023

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 933.1KB 933.1KB -2.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 428 430 +2

Total ESLint disabled count

id before after diff
securitySolution 506 508 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@orouz orouz merged commit 69420e1 into elastic:main Feb 26, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 26, 2023
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.7

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Feb 26, 2023
#152169)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Fleet] Update package policy id when agent id changes
(#151886)](#151886)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Or
Ouziel","email":"or.ouziel@elastic.co"},"sourceCommit":{"committedDate":"2023-02-26T11:32:42Z","message":"[Fleet]
Update package policy id when agent id changes
(#151886)","sha":"69420e1bae7e3821b7b861255c3da0a0c893161b","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","ci:cloud-redeploy","v8.7.0","v8.8.0"],"number":151886,"url":"https://github.com/elastic/kibana/pull/151886","mergeCommit":{"message":"[Fleet]
Update package policy id when agent id changes
(#151886)","sha":"69420e1bae7e3821b7b861255c3da0a0c893161b"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151886","number":151886,"mergeCommit":{"message":"[Fleet]
Update package policy id when agent id changes
(#151886)","sha":"69420e1bae7e3821b7b861255c3da0a0c893161b"}}]}]
BACKPORT-->

Co-authored-by: Or Ouziel <or.ouziel@elastic.co>
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this pull request Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:cloud-redeploy Always create a new Cloud deployment release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.7.0 v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants