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

Compare Resource Versions on update #272

Merged
merged 2 commits into from
May 14, 2018

Conversation

asymmetric
Copy link
Contributor

Accoriding to the controller design doc:

In cases where you are certain that you don't need to requeue items when there are no new changes, you can compare the resource version of the old and new objects. If they are the same, you skip requeuing the work.

We don't need to do anything when the Habitat hasn't changed so we can safely skip requeueing the object.

if !ok {
level.Error(hc.logger).Log("msg", "Failed to type assert StatefulSet", "obj", newObj)
return
}

h, err := hc.getHabitatFromLabeledResource(sts)
if oldSTS.ResourceVersion == newSTS.ResourceVersion {
level.Debug(hc.logger).Log("msg", "Update ignored as it didn't change Pod resource version", "pod", newSTS.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why Pod here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo.

Lorenzo Manacorda added 2 commits May 14, 2018 13:46
The ResourceVersion field can be used to know if an item has changed.

If there is nothing to do for an item that hasn't changed, the item can
be skipped.

See point 9 of the
[guidelines](https://github.com/kubernetes/community/blob/b8d4a1b389bd105d23ca496b1c67febe1e2efdf2/contributors/devel/controllers.md).

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
For clarity.

Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
Copy link
Contributor

@iaguis iaguis left a comment

Choose a reason for hiding this comment

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

lgtm

@asymmetric asymmetric merged commit 7d1c98d into habitat-sh:master May 14, 2018
@asymmetric asymmetric deleted the asymmetric/res-ver branch May 14, 2018 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants