kubernetes-sigs / cli-utils

This repo contains binaries that built from libraries in cli-runtime.
Apache License 2.0
154 stars 77 forks source link

Ensure that Daemonset controller has acted on the Daemonset. #550

Closed rohitagarwal003 closed 2 years ago

rohitagarwal003 commented 2 years ago

In status.Compute() -> checkGenericProperties() -> checkGeneration(), we check that metadata.generation is equal to status.observedGeneration but don't return an InProgress status if either of them is unset.

This may be reasonable for generic resource where we are unsure if these fields would be set, but for daemonsets, we know that these fields get set by the controller and so we should ensure that.

This fixes #548.

k8s-ci-robot commented 2 years ago

Hi @rohitagarwal003. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
rohitagarwal003 commented 2 years ago

/assign @mortent

mortent commented 2 years ago

/ok-to-test

karlkfi commented 2 years ago

Is this problem actually specific to DaemonSet? Don't most built-in controllers use metadata.generation and status.observedGeneration?

rohitagarwal003 commented 2 years ago

Is this problem actually specific to DaemonSet? Don't most built-in controllers use metadata.generation and status.observedGeneration?

Very likely. I only experimented using this library against DaemonSet at the moment. Would you mind if I update other types in follow up PRs?

rohitagarwal003 commented 2 years ago

Ping. Let me know how you want to proceed. I can also update the PR to update all resources in this PR if that's preferred.

karlkfi commented 2 years ago

I think we will want a more generic solution, but I don't know the set of resources that have controllers than specify status.observedGeneration. It's probably not 100%. So we might need to start with a list of resources we know do use it. Is that something you can compile? It's ok if it's not complete. We can always add more later. but I suspect the list includes many of the core resources and probably common extended ones too.

mortent commented 2 years ago

I think many of the commonly used built-in resource types do have observedGeneration (in particular Deployment and StatefulSet), but we can't assume that all types have it. We should add this check to the ones we know follow this pattern, but I'm ok adding that in follow-up PRs. The longer-term solution here could be to use the openAPI to check if a resource has the status.observedGeneration property, but that would be a bigger change. I'm also not sure if we want to go down this path.

/approve

rohitagarwal003 commented 2 years ago

Thanks @karlkfi, @mortent.

I will work on a follow-up PR. Can you also LGTM this in the meantime. Thanks!

k8s-ci-robot commented 2 years ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mortent, rohitagarwal003, seans3

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/cli-utils/blob/master/OWNERS)~~ [mortent,seans3] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
seans3 commented 2 years ago

/retest