Skip to content

Add status conditions helpers #1143

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

Merged
merged 6 commits into from
Feb 4, 2020

Conversation

joelanford
Copy link
Member

@joelanford joelanford commented Feb 27, 2019

Description of the change:
This PR adds status condition helpers that simplify setting and checking conditions on CR status fields.

Motivation for the change:
To promote the use of status conditions and to help users implement them consistently and according to best practices.

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 27, 2019
@joelanford
Copy link
Member Author

Submitted upstream issue: kubernetes-sigs/controller-tools#155

@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 6, 2019
@joelanford
Copy link
Member Author

As suggested by @shawn-hurley, I tried using a typed slice for the status conditions helper and implementing the same set of methods that are on the struct (see commit 4f8388a).

type ConditionsSlice []Condition

Unfortunately, that also fails during operator-sdk generate openapi:

E0306 12:39:33.837821 30846 openapi.go:294] Error when generating: conditions, Conditions github.com/operator-framework/operator-sdk/pkg/status.ConditionsSlice
2019/03/06 12:39:33 OpenAPI code generation error: Failed executing generator: some packages had errors:
slice Element kind Interface is not supported in []github.com/operator-framework/operator-sdk/pkg/status.Condition

I traced that error back to here: https://github.com/kubernetes/kube-openapi/blob/15615b16d372105f0c69ff47dfe7402926a65aaa/pkg/generators/openapi.go#L624

It looks like there's potential for upstream work related to this error as well. For example, the openapi.OpenAPIDefinitionGetter interface looks promising, but so far I haven't been able to figure out how to hook into anything that calls it.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Mar 15, 2019
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 13, 2019
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 9, 2019
@joelanford joelanford force-pushed the status-helpers branch 6 times, most recently from 12fa1a5 to 0abfef9 Compare May 15, 2019 03:44
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 15, 2019
@joelanford joelanford changed the title [WIP] Add status condition helpers Add status conditions helpers May 15, 2019
@joelanford joelanford removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 14, 2020
@joelanford joelanford force-pushed the status-helpers branch 3 times, most recently from 5774b86 to 784c03a Compare January 14, 2020 14:29
Copy link
Contributor

@jmccormick2001 jmccormick2001 left a comment

Choose a reason for hiding this comment

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

/lgtm - is any user facing documentation required for this change?

Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

New file license years need to be changed, and 2 suggestions. Overall LGTM.

@joelanford
Copy link
Member Author

@jmccormick2001 Good point, I'll see if I can find a spot to mention this. Maybe in the user guide.

I tried to make the GoDoc comments pretty verbose/descriptive since this is mainly a bunch of optional helpers in a library, but it is helpful and is worth highlighting in a user-facing doc as well.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 20, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 20, 2020
@joelanford joelanford force-pushed the status-helpers branch 2 times, most recently from 24a45b5 to 3b9548e Compare January 23, 2020 14:57
@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 3, 2020
Copy link
Member

@estroz estroz left a comment

Choose a reason for hiding this comment

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

Just grammar nits, otherwise

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2020
Co-Authored-By: Eric Stroczynski <[email protected]>
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 4, 2020
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@joelanford joelanford merged commit 3b2256c into operator-framework:master Feb 4, 2020
@joelanford joelanford deleted the status-helpers branch February 4, 2020 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants