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

feat: set default observedGeneration to -1 on HelmReleases #294

Merged
merged 5 commits into from
Aug 5, 2021

Conversation

makkes
Copy link
Member

@makkes makkes commented Jul 7, 2021

This resolves an issue with kustomize-controller marking a
Kustomization as healthy even when the helm-controller hasn't even
looked at the HelmRelease targeted by the Kustomization's
healthChecks, yet. Setting observedGeneration to -1 by default will
cause kstatus to report a status of InProgress instead of Ready.

see fluxcd/kustomize-controller#387 for
details on the issues this is solving.

Signed-off-by: Max Jonas Werner [email protected]

@hiddeco
Copy link
Member

hiddeco commented Jul 7, 2021

Would like to study a bit if this is a common pattern, and if there are others. If you have already done this, please tell and I will take it into account.

Given the simplicity however, I am leaning towards simply going with this, but in any case it should be patched on all our controllers.

@makkes
Copy link
Member Author

makkes commented Jul 7, 2021

I absolutely agree that we should investigate how common this way of setting default statuses is. I would suppose a webhook is more common given the flexibility a webhook offers.

in any case it should be patched on all our controllers.

You mean on kustomize-controller, source-controller etc.?

@stefanprodan
Copy link
Member

We've discuss webhooks before, I would stay away from them until there is no way around it. Setting defaults for CR fields is not a job for a custom webhook as defaults are fully supported by the Kubernetes builtin admission controller.

@makkes
Copy link
Member Author

makkes commented Jul 8, 2021

I agree that adding a webhook is a pain in the neck. So for now we have discussed these 3 options to fix fluxcd/kustomize-controller#387:

  1. Use a webhook. See feat: set default observedGeneration to -1 on HelmReleases #294 (comment). This is painful to implement and adds a lot of overhead for little gain (at least for now).
  2. Set a default status.observedGeneration. This is what this PR introduces. It's a very small fix. A drawback is that I haven't found good examples of other projects doing this. It works, though, and fixes the bug.
  3. Rely on upstream changes to cli-utils, e.g. to be able to inject custom StatusReaders like I did in this PR. Another upstream change could be for kstatus to actually look at the CRD of a resource and see whether it defines a status field and if it does, mark the resources as Unknown as long as a status hasn't been set.

@hiddeco
Copy link
Member

hiddeco commented Jul 8, 2021

  1. Rely on upstream changes to cli-utils, e.g. to be able to inject custom StatusReaders like I did in this PR. Another upstream change could be for kstatus to actually look at the CRD of a resource and see whether it defines a status field and if it does, mark the resources as Unknown as long as a status hasn't been set.

A custom status reader would only solve it for us, but not for others using kstatus with defaults.

@makkes makkes force-pushed the default-observed-generation branch 3 times, most recently from 345186e to eb31982 Compare July 8, 2021 14:03
@hiddeco hiddeco added the enhancement New feature or request label Jul 14, 2021
@hiddeco
Copy link
Member

hiddeco commented Jul 14, 2021

This looks OK to be merged, but as I am on short leave from Fri - Wed, I am going to wait with merging as it would bump the MINOR version.

This allows allows patch releases to be made without too much hassle during my absence.

@hiddeco
Copy link
Member

hiddeco commented Jul 29, 2021

@makkes can you please rebase instead of merging in main? I promise to merge right after 🤞

@makkes makkes force-pushed the default-observed-generation branch from e5c8724 to de3079c Compare July 29, 2021 10:20
Max Jonas Werner added 5 commits August 5, 2021 14:03
This resolves an issue with kustomize-controller marking a
Kustomization as healthy even when the helm-controller hasn't even
looked at the HelmRelease targeted by the Kustomization's
healthChecks, yet. Setting `observedGeneration` to -1 by default will
cause kstatus to report a status of `InProgress` instead of `Ready`.

see fluxcd/kustomize-controller#387 for
details on the issues this is solving.

Signed-off-by: Max Jonas Werner <[email protected]>
Signed-off-by: Max Jonas Werner <[email protected]>
Signed-off-by: Max Jonas Werner <[email protected]>
When the e2e workflow fails the "Debug failure" step should not assume
that the CRDs it tries to fetch CRs for exist because the workflow
might have failed before even creating the CRDs.

Signed-off-by: Max Jonas Werner <[email protected]>
Since the kubectl version used in the workflow (v1.16.4) has a bug
(kubernetes/kubernetes#23386) with the
output of jsonpath formatting being a Go representation instead of
JSON.

Signed-off-by: Max Jonas Werner <[email protected]>
@hiddeco hiddeco force-pushed the default-observed-generation branch from de3079c to 89f8f7f Compare August 5, 2021 12:03
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

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

Thank you @makkes, and sorry for the wait 🍻

@hiddeco hiddeco merged commit 58c1ec5 into fluxcd:main Aug 5, 2021
@makkes makkes deleted the default-observed-generation branch August 5, 2021 12:53
makkes pushed a commit to makkes/kustomize-controller that referenced this pull request Aug 8, 2021
This is a follow-up to
fluxcd/helm-controller#294, porting the same
code to the kustomize-controller so that all Flux 2 controllers work
the same way in this regard.

Signed-off-by: Max Jonas Werner <[email protected]>
makkes pushed a commit to makkes/notification-controller that referenced this pull request Aug 8, 2021
This sets the `status.observedGeneration` field to -1 by default. This
is a follow-up to fluxcd/helm-controller#294,
porting the same code to the notification-controller so that all Flux
2 controllers work the same way in this regard.

Signed-off-by: Max Jonas Werner <[email protected]>
hiddeco added a commit that referenced this pull request Aug 9, 2021
hiddeco added a commit that referenced this pull request Aug 9, 2021
This reverts commit 58c1ec5, reversing
changes made to 098fa6d.

Signed-off-by: Hidde Beydals <[email protected]>
makkes pushed a commit to makkes/kustomize-controller that referenced this pull request Aug 27, 2021
This is a follow-up to
fluxcd/helm-controller#294, porting the same
code to the kustomize-controller so that all Flux 2 controllers work
the same way in this regard.

Signed-off-by: Max Jonas Werner <[email protected]>
makkes pushed a commit to makkes/notification-controller that referenced this pull request Aug 27, 2021
This sets the `status.observedGeneration` field to -1 by default. This
is a follow-up to fluxcd/helm-controller#294,
porting the same code to the notification-controller so that all Flux
2 controllers work the same way in this regard.

Signed-off-by: Max Jonas Werner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants