-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
// 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]); | ||
|
There was a problem hiding this comment.
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.
Pinging @elastic/fleet (Team:Fleet) |
There was a problem hiding this 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.
💚 Build Succeeded
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
(cherry picked from commit 69420e1)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
#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>
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.