-
Notifications
You must be signed in to change notification settings - Fork 30
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
[Unit/Change]: trigger config change on unit config and revision changes #109
[Unit/Change]: trigger config change on unit config and revision changes #109
Conversation
This needs some test coverage :) |
This needs some understanding first @cmacknz; so since you are part of the elastic-agent-control-plane team I consider you more than an expert to help me understand. As far as I can tell from the code So @cmacknz, how |
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 understand why this is needed at all? configIdx
should always be incremented by the Elastic Agent when the configuration changes. If configIdx
is not incremented when the configuration is changed then there is a bug in the Elastic Agent not in the elastic-agent-client
?
@blakerouse a sole configIdx increase is not enough, based on this
|
The configuration index is a mechanism used to avoid pointlessly copying the configuration back and forth when nothing has changed. As Blake mentioned, when the expected configuration has changed the The change triggers are not part of the control protocol, they are a feature of the client library that is attempting to save all users from having to manually inspect each part of the expected configuration to know which part of it changed. The expectation here seems to be that there is a need to detect changes separate from the config index, with an assumption that they are completely detectable purely by doing comparisons on the source field, which is the YAML representation of the original configuration. That is the block below: if u.configIdx != cfgIdx {
u.configIdx = cfgIdx
if !gproto.Equal(u.config.GetSource(), cfg.GetSource()) {
u.config = cfg
triggers |= TriggeredConfigChange
}
} Looking at this, I see it appears possible that we do not set The code this PRs adds seems to be looking at the protobuf representation of the Looking at the agent side of this, I think the comparison here is slightly out of sync, because the agent is using if !gproto.Equal(expected.config, unit.Config) {
expected.config = unit.Config
expected.configStateIdx++
changed = true
} I'm not even sure why we need the I suspect the right answer is probably to remove the |
@cmacknz I agree 100% with the above statement and I can even adjust this PR to handle this. I did expand on the checks in the initial code of this PR motivated by the check of the Source field. That said, the single check you mention makes sense to me; if we rely on elastic-agent to increase the configIdx then this should be the single one criteria to cause a |
💚 Build Succeeded
History
|
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.
Not clear why the gproto.Equal
was added, probably just an optimization for not saying it changed if really it hadn't changed. Don't see any issue with removing it.
Looks good.
This PR adds checks for the RevisionNumber and Streams of the UnitExpectedConfig to properly cause a
TriggeredConfigChange
.@blakerouse I think you are the original implementor of the new control protocol, so any thoughts on that?