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: support v1 CRD objects in OLM #1416

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

exdx
Copy link
Member

@exdx exdx commented Mar 31, 2020

Description of the change:
The goal of this PR is to enable the catalog operator to fulfill install plans on bundles that contain CRDs that are in the newer apiextensions.k8s.io/v1 group and version. The OLM operator will also need an informer based on this new version. However, we still need to support the older v1beta1 version of CRDs as well. Most of the code from the existing reconciliation of v1beta1 type CRDs is duplicated to support the v1 version.

Additional work will be needed on the registry side to enable users to generate bundles with the new v1 CRDs and validate them.

The biggest change between v1beta1 and v1 version CRDs are around the validation fields - in v1beta1 the validation was optional since the structural schema was not required and turned off by default. In v1 the structural schema is required, and validation is required on each version of the supported resources. So the spec has changed around to reflect this between the two versions.

Note: The v1beta1 version of the CRD api will be served at the v1 endpoint based on the kubernetes api conventions. So performing a GET with the v1 CRD client on a v1beta1 CRD on-cluster will return the v1 representation of that CRD.
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#on-compatibility

Motivation for the change:
v1beta1 CRDs will be deprecated in kube as of 1.19

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /docs
  • Commit messages sensible and descriptive

@exdx exdx requested a review from ecordell March 31, 2020 21:46
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 31, 2020
pkg/lib/crd/version.go Outdated Show resolved Hide resolved
@exdx exdx changed the title [WIP] feat: support v1 CRD objects in OLM feat: support v1 CRD objects in OLM Apr 1, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 1, 2020
@exdx
Copy link
Member Author

exdx commented Apr 1, 2020

Are there any docs anywhere that should be updated to reflect that OLM supports v1 CRDs now as well?

@exdx exdx force-pushed the feat/v1-crds branch 4 times, most recently from 8b63433 to 7e377cf Compare April 6, 2020 18:00
@ecordell
Copy link
Member

ecordell commented Apr 6, 2020

/approve

Looks good! I think this refactor will help with csvless bundles.

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ecordell, exdx

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:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 6, 2020
Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

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

Great job! I have a few comments:

pkg/controller/operators/catalog/operator.go Outdated Show resolved Hide resolved
pkg/controller/operators/catalog/operator.go Outdated Show resolved Hide resolved
pkg/controller/operators/catalog/operator.go Outdated Show resolved Hide resolved
pkg/controller/operators/catalog/operator.go Outdated Show resolved Hide resolved
pkg/controller/operators/catalog/operator.go Outdated Show resolved Hide resolved
pkg/controller/operators/catalog/operator.go Outdated Show resolved Hide resolved
pkg/controller/operators/catalog/step.go Outdated Show resolved Hide resolved
pkg/controller/operators/olm/operator.go Outdated Show resolved Hide resolved
pkg/lib/crd/version.go Outdated Show resolved Hide resolved
pkg/lib/crd/version.go Show resolved Hide resolved
pkg/controller/operators/catalog/step.go Outdated Show resolved Hide resolved
pkg/lib/index/api.go Outdated Show resolved Hide resolved
pkg/lib/operatorlister/customresourcedefinition.go Outdated Show resolved Hide resolved
@exdx
Copy link
Member Author

exdx commented Apr 15, 2020

/retest

@exdx
Copy link
Member Author

exdx commented Apr 15, 2020

/hold

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed lgtm Indicates that a PR is ready to be merged. labels Apr 15, 2020
@exdx
Copy link
Member Author

exdx commented Apr 16, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 16, 2020
switch step.Status {
case v1alpha1.StepStatusPresent, v1alpha1.StepStatusCreated:
doStep := true
s, err := b.step(step.Status, step.Resource, step.Resource.Name)
Copy link
Member

Choose a reason for hiding this comment

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

I think this should take the whole step as a single argument.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. I renamed the function to create so we have create(step) for clarity as well.

Copy link
Member

@njhale njhale left a comment

Choose a reason for hiding this comment

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

Looking really good. Holding off on LGTM since there's one more change coming in (discussed offline).

I had one last minute design thought, but it doesn't need to hold this up.


// Stepper manages cluster interactions based on the step.
type Stepper interface {
Status() (v1alpha1.StepStatus, error)
Copy link
Member

@njhale njhale Apr 16, 2020

Choose a reason for hiding this comment

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

The naming here is a little confusing. Usually I would expect ${VERB}er to $VERB.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed

}

// step is a factory that creates StepperFuncs based on the Kind provided and the install plan step.
func (b *builder) step(stepStatus v1alpha1.StepStatus, resource v1alpha1.StepResource, name string) (Stepper, error) {
Copy link
Member

Choose a reason for hiding this comment

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

It seems like builder is really the Stepper because it's -- indirectly -- performing the step. It also needs to have knowledge of all the Stepper implementations.

What if:

  • A Stepper has a Step(take *v1alpha1.Step) (taken bool, err error) method, which performs an in-place update of the given step -- returning taken=true if the Stepper cared to take a step.
  • Different Stepper implementations are made for specific resource types; e.g. CSV, CRD, CR, etc...
  • A StepperChain Stepper implementation is made that calls a set of steppers in order until taken=true or an error is encountered -- forwarding the results along, or if no step was taken, returns taken=false.

I think something similar to this will let us view the stepper order and inclusion more easily; e.g.:

// On the Operator struct
o.stepper = StepperChain{
    NewCRDStepper(...),
    NewCSVStepper(...),
    NewDefaultStepper(...),
}
// ...
// In the InstallPlan transition
taken, err := o.stepper.Step(take)
if err != nil {
    // ...
}
if !taken {
    // ...
}
// ...

Copy link
Member

Choose a reason for hiding this comment

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

or maybe a continue bool return would be more flexible than taken -- the semantics would follow the namesake

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm down to think about this more next week

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 17, 2020
@exdx
Copy link
Member Author

exdx commented Apr 17, 2020

We've identified a potential issues with int -> float conversion (see helm/helm#5806 for an example) going from an unstructured object to a v1 CRD. Will file a bug and resolve following feature freeze.

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 17, 2020
@exdx exdx force-pushed the feat/v1-crds branch 2 times, most recently from 46fa1e8 to 992a0c9 Compare April 17, 2020 12:57
@exdx
Copy link
Member Author

exdx commented Apr 17, 2020

I believe e2e should pass now, barring flakes.

@exdx
Copy link
Member Author

exdx commented Apr 17, 2020

/retest

Stepper interface. All CRDs will be converted and handled at the v1
APIVersion.
@exdx
Copy link
Member Author

exdx commented Apr 17, 2020

/test e2e-aws-olm

@openshift-ci-robot
Copy link
Collaborator

@exdx: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/verify d7f5cfe link /test verify
ci/prow/e2e-gcp-upgrade d7f5cfe link /test e2e-gcp-upgrade
ci/prow/e2e-aws-console-olm d7f5cfe link /test e2e-aws-console-olm
ci/prow/e2e-gcp d7f5cfe link /test e2e-gcp
ci/prow/images d7f5cfe link /test images
ci/prow/e2e-aws-olm d7f5cfe link /test e2e-aws-olm

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@ecordell
Copy link
Member

upstream tests are passing with one known failure (external image dependency issue).

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants