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

[Security Solution][Endpoint] Consistent pending actions agent status label #117875

Merged

Conversation

ashokaditya
Copy link
Member

@ashokaditya ashokaditya commented Nov 8, 2021

Summary

Fixes the bug where users see an isolated badge for a few seconds after the host is released until it disappears.

Additionally, while testing found and fixed a bug that shows a count of pending actions when there are no pending actions. This happens due to the default query result size of 10.

isolation-badge-test

Checklist

@ashokaditya ashokaditya added bug Fixes for quality problems that affect the customer experience v8.0.0 release_note:skip Skip the PR/issue when compiling release notes impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. Team:Defend Workflows “EDR Workflows” sub-team of Security Solution auto-backport Deprecated - use backport:version if exact versions are needed v7.16.0 v8.1.0 labels Nov 8, 2021
@ashokaditya ashokaditya self-assigned this Nov 8, 2021
@ashokaditya ashokaditya force-pushed the fix/olm-pending_agent_status_label-2105 branch 2 times, most recently from 398aa70 to 9bf82e4 Compare November 11, 2021 09:59
refs elastic/pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
@ashokaditya ashokaditya force-pushed the fix/olm-pending_agent_status_label-2105 branch from 9bf82e4 to ed38d03 Compare November 11, 2021 10:07
ashokaditya and others added 3 commits November 11, 2021 11:08
fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt)

Copy link
Member

@pzl pzl left a comment

Choose a reason for hiding this comment

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

if it works, it works

@ashokaditya
Copy link
Member Author

if it works, it works

Indeed, I tested it manually several many times to make sure it works.

Comment on lines +35 to +36
const wasReleasing = useRef<boolean>(false);
const wasIsolating = useRef<boolean>(false);
Copy link
Contributor

@paul-tavares paul-tavares Nov 11, 2021

Choose a reason for hiding this comment

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

I'm having a hard time understanding why we need to useRef which given you a non-mutable const. Looking at this logic, it seem that these two variables are set only once - when the component renders for the very first time, and then they are never updated again. If that is truly what you mean with this change, then using useState() like this would do the trick:

Suggested change
const wasReleasing = useRef<boolean>(false);
const wasIsolating = useRef<boolean>(false);
const [wasReleasing] = useState<boolean>(pendingIsolate === 0 && pendingUnIsolate > 0);
const [wasIsolating] = useState<boolean>(pendingIsolate > 0 && pendingUnIsolate === 0);

but I have to ask: is that really what you expect? that these will never be updated even if the component is called with different props?

Also - since the entire returned value is already memoized, you might just want to move this logic inside of the useMemo()'s factory callback as:

const wasReleasing = pendingIsolate === 0 && pendingUnIsolate > 0;
const wasIsolating = pendingIsolate > 0 && pendingUnIsolate === 0;

NOTE: the reason I always pay closer attention when using useRef is that it can get you in trouble. Example: see my comment below for usage in useMemo dependencies

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, useRef returns a mutable object. Since, the component re-renders anyway when pendingIsolate and pendingUnIsolate change, passing the dependency array will have the same "effect".

Overall, the idea is when the component starts to render(before returning display nodes), we want to use the old state of these values (old isolated badge) to decide which badge to show next. The endpoint metadata doesn't update the Endpoint.state.isolation value as fast as the action response indices update the pending actions count.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. And since you only want it to be set on first render, you don't really need a mutable object. You can just use a useState() with an initial value right (like the suggestion in my prior comment)?

I'm approving since the end result I think is the same and you and confirmed that you truly only want this value to be capture on the very first render and even if they differ in subsequent re-renders, they will not be seen.

ashokaditya and others added 2 commits November 11, 2021 17:52
review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
@ashokaditya
Copy link
Member Author

@elasticmachine merge upstream

@elastic elastic deleted a comment from kibanamachine Nov 15, 2021
Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

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

Thanks for the responses.

🚢

@ashokaditya
Copy link
Member Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 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
securitySolution 4.5MB 4.5MB +215.0B

History

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

cc @ashokaditya

@ashokaditya ashokaditya merged commit f69ff00 into elastic:main Nov 16, 2021
@ashokaditya ashokaditya deleted the fix/olm-pending_agent_status_label-2105 branch November 16, 2021 11:01
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Nov 16, 2021
… label (elastic#117875)

* pull more than default 10 records!!

refs elastic/pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Nov 16, 2021
… label (elastic#117875)

* pull more than default 10 records!!

refs elastic/pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
8.0
7.16

The backport PRs will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Nov 16, 2021
… label (#117875) (#118665)

* pull more than default 10 records!!

refs /pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Nov 16, 2021
… label (#117875) (#118666)

* pull more than default 10 records!!

refs /pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
fkanout pushed a commit to fkanout/kibana that referenced this pull request Nov 17, 2021
… label (elastic#117875)

* pull more than default 10 records!!

refs elastic/pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
mbondyra pushed a commit to mbondyra/kibana that referenced this pull request Nov 19, 2021
… label (elastic#117875)

* pull more than default 10 records!!

refs elastic/pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
dmlemeshko pushed a commit that referenced this pull request Nov 29, 2021
… label (#117875)

* pull more than default 10 records!!

refs /pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
roeehub pushed a commit to build-security/kibana that referenced this pull request Dec 16, 2021
… label (elastic#117875)

* pull more than default 10 records!!

refs elastic/pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
gbamparop pushed a commit to gbamparop/kibana that referenced this pull request Jan 12, 2022
… label (elastic#117875)

* pull more than default 10 records!!

refs elastic/pull/115691

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* commit using ashokaditya@elastic.co

* show correct isolation status badge when pending actions data is updated

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* fix typo

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* remove redundant dependencies

review changes

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* show `isolated` right after pending state is refreshed

fixes elastic/security-team/issues/2105

Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>

* recompute only on prop change

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v7.16.0 v8.0.0 v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants