-
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] Fix syncing issue in Agent flyout #135734
Conversation
Pinging @elastic/fleet (Team:Fleet) |
@@ -42,11 +40,16 @@ export const Instructions = (props: InstructionProps) => { | |||
refreshAgentPolicies, | |||
} = props; | |||
const fleetStatus = useFleetStatus(); | |||
const { isUnhealthy: isFleetServerUnhealthy } = useFleetServerUnhealthy(); | |||
const REFRESH_INTERVAL = 10 * 1000; |
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.
there is no way to fix the root problem and refresh the status when fleet server is added? or at least only once when the flyout is open?
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.
For some reason when the flyout is first open the fleetStatus is not ready, so you have to reload the page to get it. I couldn't find a solution that refreshes the state, I tried in several ways using useEffect
but they mostly ended up int too many rerenders
errors.
@@ -42,11 +40,16 @@ export const Instructions = (props: InstructionProps) => { | |||
refreshAgentPolicies, | |||
} = props; | |||
const fleetStatus = useFleetStatus(); | |||
const { isUnhealthy: isFleetServerUnhealthy } = useFleetServerUnhealthy(); | |||
const REFRESH_INTERVAL = 10 * 1000; |
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 don't know if polling is the right solution here. Is there a way we can add fleetStatus.refresh
to wherever we currently wait on the the existence of a Fleet Server? Because fleetStatus
is a context object, we should be able to call refresh and update any other consumers of that context object from anywhere in the component tree.
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 tried using fleetStatus.refresh
without the setInterval as a first try and didn't work as expected.
An issue that I had a lot with this component is that react signals too many rerenders, which is probably a sign that we are doing something weird.
The solutions I could think of are basically 1- the polling that I implemented here 2- doing as many checks as possible in the parent components of the flyout, but since is called several times in the code it would be a lot of refactoring for a small bug fix.
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.
@criamico if you put the fleetStatus.refresh
in a useEffect
with an empty array it should only refresh once no?
something like this
useEffect(() => fleetStatus.refresh(), []);
Summarizing the changes I made in 6bd8326:
Long screen recording of the experience as it stands now on a fresh self hosted instance (local dev): Screen.Recording.2022-07-05.at.2.19.18.PM.mov |
This still isn't quite right, because we're stuck in the "Fleet Server" state in the enrollment flyout, so I'll continue to look at that. We're closer now though I think. |
Never mind on the above - we don't auto select the Fleet Server Policy 1 policy that we create so at least we're not stuck when the flyout opens after clicking "continue". |
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.
🚀
💚 Build SucceededMetrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: cc @criamico |
* [Fleet] Fix syncing issue in Agent flyout * Use context based solution instead of polling * Add clarifying comment * Fix types Co-authored-by: Kyle Pollich <[email protected]> (cherry picked from commit b8dcdea)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
* [Fleet] Fix syncing issue in Agent flyout * Use context based solution instead of polling * Add clarifying comment * Fix types Co-authored-by: Kyle Pollich <[email protected]> (cherry picked from commit b8dcdea) Co-authored-by: Cristina Amico <[email protected]>
Summary
Closes #131590
In the instructions I added a
setInterval
component that every 10 seconds refreshes the AgentStatus and AgentPolicies. Also remove the `isFleetServerHealthy because it doesn't update until a page refresh (preventing the layout to change) and simplified a bit the other checks.I looked for another way of syncing the panel with the main page but didn't find a better solution.
Repro steps
Add Fleet Server
layout.Continue enrolling Elastic Agent
buttonAdd agent layout
and not theAdd Fleet server
instructions