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

[Cloud Security] fix fleet form save button bug #211563

Merged
merged 3 commits into from
Feb 22, 2025

Conversation

alexreal1314
Copy link
Contributor

@alexreal1314 alexreal1314 commented Feb 18, 2025

Summary

This PR tries to fix the following https://github.com/elastic/security-team/issues/11881
the bug causes a lot of flakiness in our test cases.

Checklist

Closes

this PR closes the above mentioned issues in relation for this ticket - https://github.com/elastic/security-team/issues/11881

Video recording

Screen.Recording.2025-02-17.at.12.53.56.mov

@alexreal1314 alexreal1314 force-pushed the 11881-bug-policy-form-save-button branch from 6c3a9e4 to 9590df3 Compare February 18, 2025 13:53
@alexreal1314 alexreal1314 changed the title add isFetchedPackagePolicies state to wait for policies to load befor… [Cloud Security] fix fleet form save button bug Feb 18, 2025
@alexreal1314 alexreal1314 marked this pull request as ready for review February 18, 2025 16:37
@alexreal1314 alexreal1314 requested review from a team as code owners February 18, 2025 16:37
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Feb 18, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

Comment on lines 589 to 595
updatePolicy(
{
...newPolicy,
name: currentIntegrationName,
},
Array.isArray(packagePolicyListByIntegration)
);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe instead of passing this new parameter just for our use case, and we being a single consumer, we can instead set the formState as not valid (this is already being checked to disable the button) as long as !Array.isArray(packagePolicyListByIntegration)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JordanSh the problem is that the valid state of the form is triggered from another place and it will cause the button to flicker, disabled -> enabled -> disabled.

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#7896

[✅] x-pack/test/fleet_api_integration/config.epm.ts: 25/25 tests passed.
[✅] x-pack/test/fleet_api_integration/config.agent.ts: 25/25 tests passed.
[✅] x-pack/test/fleet_api_integration/config.fleet.ts: 25/25 tests passed.
[✅] x-pack/test/cloud_security_posture_functional/config.agentless.ts: 25/25 tests passed.
[✅] x-pack/test/cloud_security_posture_functional/data_views/config.ts: 25/25 tests passed.
[✅] x-pack/test/cloud_security_posture_api/config.ts: 25/25 tests passed.

see run history

Copy link
Contributor

@juliaElastic juliaElastic left a comment

Choose a reason for hiding this comment

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

LGTM

@juliaElastic juliaElastic added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) labels Feb 19, 2025
@alexreal1314 alexreal1314 force-pushed the 11881-bug-policy-form-save-button branch from 1af91ab to a8eeeb2 Compare February 20, 2025 12:57
added unit test for CspPolicyTemplateForm component
@alexreal1314 alexreal1314 force-pushed the 11881-bug-policy-form-save-button branch from a8eeeb2 to fda66d9 Compare February 20, 2025 13:07
@alexreal1314
Copy link
Contributor Author

Used additional property 'isFetchedPackagePolicies' to handle enable/disable of save and continue button since formState = 'VALID' before the name input gets the most updated value from our fleet extensions template form.

@alexreal1314 alexreal1314 self-assigned this Feb 20, 2025
@alexreal1314 alexreal1314 added the Team:Cloud Security Cloud Security team related label Feb 20, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

...newPolicy,
name: currentIntegrationName,
},
Array.isArray(packagePolicyListByIntegration)
Copy link
Contributor

@JordanSh JordanSh Feb 20, 2025

Choose a reason for hiding this comment

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

i suggest to put this value into a named constant so it will be easier to understand why this check is being done. in this use case maybe something like hasPackagePoliciesLoaded

also, note that an empty array is will still return true for Array.isArray, is this case something we care about? if so, probably good to additionally check for length.

edit: in an offline conversation we figured that an empty array is actually a valid value for us, lets add a comment above this check so its clear to anyone reading it

updatePackagePolicy(updatedPolicy);
setIsFetchedPackagePolicies(isLoadedPackagePolicies);
Copy link
Contributor

@JordanSh JordanSh Feb 20, 2025

Choose a reason for hiding this comment

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

do other extensions also have this problem? maybe we can pass something more generic like extensionIsLoading, that why every extension can pass what ever fits their case.

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#7917

[✅] x-pack/test/fleet_functional/config.ts: 25/25 tests passed.
[✅] x-pack/test/cloud_security_posture_functional/config.ts: 25/25 tests passed.
[✅] x-pack/test/cloud_security_posture_functional/config.agentless.ts: 25/25 tests passed.

see run history

@elasticmachine
Copy link
Contributor

elasticmachine commented Feb 21, 2025

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Fleet Cypress Tests #1 / Space aware policies creation should allow to update that policy to belong to both test and default space
  • [job] [logs] Fleet Cypress Tests #1 / Space aware policies creation should redirect to the agent policies list when removing the current space from a policy
  • [job] [logs] Fleet Cypress Tests #1 / Space aware policies creation the policy should be visible in the default space
  • [job] [logs] Fleet Cypress Tests #1 / View agents list Agent status filter should filter on healthy and unhealthy
  • [job] [logs] Fleet Cypress Tests #1 / View agents list Bulk actions should allow to bulk upgrade agents and cancel that upgrade

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 1330 1331 +1

Async chunks

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

id before after diff
cloudSecurityPosture 503.8KB 503.8KB +31.0B
fleet 1.7MB 1.7MB +69.0B
total +100.0B
Unknown metric groups

API count

id before after diff
fleet 1457 1458 +1

History

cc @alexreal1314

@alexreal1314 alexreal1314 added release_note:fix bug Fixes for quality problems that affect the customer experience and removed release_note:skip Skip the PR/issue when compiling release notes labels Feb 22, 2025
@alexreal1314 alexreal1314 merged commit a37b3cf into main Feb 22, 2025
14 checks passed
@alexreal1314 alexreal1314 deleted the 11881-bug-policy-form-save-button branch February 22, 2025 08:42
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.0

https://github.com/elastic/kibana/actions/runs/13471348180

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Feb 22, 2025
## Summary

This PR tries to fix the following
[https://github.com/elastic/security-team/issues/11881](url)
the bug causes a lot of flakiness in our test cases.

### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed

### Closes
this PR closes the above mentioned issues in relation for this ticket -
elastic/security-team#11881

### Video recording

https://github.com/user-attachments/assets/b6389216-8078-4f06-9a39-41b9559f8f1b
(cherry picked from commit a37b3cf)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
9.0

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 22, 2025
)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Cloud Security] fix fleet form save button bug
(#211563)](#211563)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Alex
Prozorov","email":"alex.prozorov@elastic.co"},"sourceCommit":{"committedDate":"2025-02-22T08:42:52Z","message":"[Cloud
Security] fix fleet form save button bug (#211563)\n\n## Summary\n\nThis
PR tries to fix the
following\n[https://github.com/elastic/security-team/issues/11881](url)\nthe
bug causes a lot of flakiness in our test cases.\n\n### Checklist\n- [x]
[Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n\n### Closes\nthis PR closes the above
mentioned issues in relation for this ticket
-\nhttps://github.com/elastic/security-team/issues/11881\n\n### Video
recording\n\nhttps://github.com/user-attachments/assets/b6389216-8078-4f06-9a39-41b9559f8f1b","sha":"a37b3cfba24ff07b29c58efc56644b7b32326897","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Fleet","Team:Cloud
Security","backport:prev-minor","v9.1.0"],"title":"[Cloud Security] fix
fleet form save button
bug","number":211563,"url":"https://github.com/elastic/kibana/pull/211563","mergeCommit":{"message":"[Cloud
Security] fix fleet form save button bug (#211563)\n\n## Summary\n\nThis
PR tries to fix the
following\n[https://github.com/elastic/security-team/issues/11881](url)\nthe
bug causes a lot of flakiness in our test cases.\n\n### Checklist\n- [x]
[Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n\n### Closes\nthis PR closes the above
mentioned issues in relation for this ticket
-\nhttps://github.com/elastic/security-team/issues/11881\n\n### Video
recording\n\nhttps://github.com/user-attachments/assets/b6389216-8078-4f06-9a39-41b9559f8f1b","sha":"a37b3cfba24ff07b29c58efc56644b7b32326897"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/211563","number":211563,"mergeCommit":{"message":"[Cloud
Security] fix fleet form save button bug (#211563)\n\n## Summary\n\nThis
PR tries to fix the
following\n[https://github.com/elastic/security-team/issues/11881](url)\nthe
bug causes a lot of flakiness in our test cases.\n\n### Checklist\n- [x]
[Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n\n### Closes\nthis PR closes the above
mentioned issues in relation for this ticket
-\nhttps://github.com/elastic/security-team/issues/11881\n\n### Video
recording\n\nhttps://github.com/user-attachments/assets/b6389216-8078-4f06-9a39-41b9559f8f1b","sha":"a37b3cfba24ff07b29c58efc56644b7b32326897"}}]}]
BACKPORT-->

Co-authored-by: Alex Prozorov <alex.prozorov@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) bug Fixes for quality problems that affect the customer experience release_note:fix Team:Cloud Security Cloud Security team related Team:Fleet Team label for Observability Data Collection Fleet team v9.0.0 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants