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
Trigger reprocess all event only when pool changes #1951
Trigger reprocess all event only when pool changes #1951
Conversation
controller/main.go
Outdated
if !reflect.DeepEqual(c.pools, pools) { | ||
c.pools = pools | ||
return controllers.SyncStateReprocessAll | ||
} |
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.
Maybe we should check the other way around, if is DeepEqual then return SyncStateSuccess,
with a log similar to what we have in the SetBalancer:
level.Debug(l).Log("event", "noChange", "msg", "service converged, no change")
else continue to execute the c.ips.SetPools and return Reprocess.
This is just to avoid running the c.ips.SetPools on the same/unchanged pools
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 had a reason to always run c.ips.SetPools but I can't remember what it was.
Will change it as you suggest. Thank you.
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.
done
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.
it's just a suggestion, but maybe don't negate the DeepEqual if statement,
so we won't have to branch if inside an if and make it easier to follow.
i.e. if the pools are equal we throw a log and return success, else
continue like before.
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 prefer the last return to be a success
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.
you can also say that the Reprocess state is the happy path, as it was previously,
anyways it is unclear to me in what scenario would we reconcile and call the pool controller handler when the pool didn't change
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.
it is unclear to me in what scenario would we reconcile and call the pool controller handler when the pool didn't change
This is a valid point too. The only scenario I can think of is when we do that is because a community entry changes but is not part of a legacy addresspool, which is a pretty cornery case.
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.
yeah, mainly changes on community and namespaces not related to existing pools
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.
but the community resource is translated into a BGPadv (both legacy and non) and that's part of the pool, no?
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.
community affects the legacy pools. BGPadv are part of the pools indeed but in the pools controller they are always empty
c1bd58f
to
1fda5a9
Compare
controller/main.go
Outdated
if err := c.ips.SetPools(pools); err != nil { | ||
level.Error(l).Log("op", "setConfig", "error", err, "msg", "applying new configuration failed") | ||
return controllers.SyncStateError | ||
if !reflect.DeepEqual(c.pools, pools) { |
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.
In the configController we have this part on the higher level controller. I'd rather do the same here
if r.currentConfig != nil && reflect.DeepEqual(r.currentConfig, cfg) { |
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.
yeah, that will require more changes. I would need to add a new parameter in the PoolReconciler structure to keep track of the pools. Perhaps in another PR.
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 might be missing something, but why comparing the rendered configs is not enough? At the end of the day it will contain only the pools.
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.
the config controller has a filed to store the current config, the pool controller does not
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, but it's about copying the config controller logic.
If we want this kind of optimization, we should be consistent.
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 agree with the consistency. But perhaps the config controller should be the one that needs to be changed. I don't know. I'll study it soon. The only thing I don't like is to have (and maintain) many variables with pool. We have pools in the controller structure, allocator structure and now we are thinking about adding a new one for the pool controller structure.
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 am suggesting not to keep only the pool, but do exactly the same as we do in the config controller, which is keeping an old version of the config and compare the rendered one (which yes, it will contain the pools).
I don't think it's a problem from readibility point of view, the config controller seems straightforward. We maintain a current config, check if changed and discard if it did not.
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 changed it as you suggested
This prevents the pool controller to trigger the reprocess all event when there are no changes in the pools. Signed-off-by: Marcelo Guerrero Viveros <marguerr@redhat.com>
1fda5a9
to
a664576
Compare
lgtm, thanks! |
This prevents the pool controller to trigger the reprocess all event when there are no changes in the pools.