-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Security Solution][Endpoint] Consistent pending actions agent status label #117875
Conversation
398aa70
to
9bf82e4
Compare
refs elastic/pull/115691 Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
9bf82e4
to
ed38d03
Compare
fixes elastic/security-team/issues/2105 Co-Authored-By: Ashokaditya <1849116+ashokaditya@users.noreply.github.com>
Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt) |
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.
if it works, it works
Indeed, I tested it manually several many times to make sure it works. |
...solution/public/common/components/endpoint/host_isolation/endpoint_host_isolation_status.tsx
Show resolved
Hide resolved
const wasReleasing = useRef<boolean>(false); | ||
const wasIsolating = useRef<boolean>(false); |
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.
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:
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
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.
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.
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.
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.
...solution/public/common/components/endpoint/host_isolation/endpoint_host_isolation_status.tsx
Outdated
Show resolved
Hide resolved
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>
@elasticmachine merge upstream |
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.
Thanks for the responses.
🚢
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @ashokaditya |
… 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>
… 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>
… 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>
… 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>
… 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>
… 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>
… 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>
… 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>
… 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>
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.
Checklist