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

Upgrade Kanister CRDs to v1 from v1beta1 #927

Merged
merged 17 commits into from
Jun 25, 2021
Merged

Upgrade Kanister CRDs to v1 from v1beta1 #927

merged 17 commits into from
Jun 25, 2021

Conversation

viveksinghggits
Copy link
Contributor

@viveksinghggits viveksinghggits commented Mar 11, 2021

Change Overview

This PR tries to update the version of CRDs that we create to v1 from v1beta1. Some of the issue that I faced

  • When we create CRD using kube-buidler, the fields are marked as required but we don't necessarily provide all the fields while creating the CRs. So we had to remove those required fields from CRDs.

After above changes, things were working on cluster version 1.20, but in kanister CI we run kubernetes version 1.18, and there things were failing because when we read the blueprint from examples/ dir to actually marshal it to types json, the values that we didnt specify in the manifest were being set as null. To resolve that we had to add omitempty in the types.go for some fields.

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

  • #XXX

Test Plan

  • 💪 Manual
  • 💚 E2E

Change integration_test.sh to run the test for

SHORT_APPS="^MongoDB$"

With the Kubernetes version that runs in CI

» k version
» make integration-test

logs can be found here.

With kubernetes version 1.20

 » make integration-test 

and the logs can be found here.

@viveksinghggits viveksinghggits changed the title [WIP] Upgrade CRDs to v1 from v1beta1 Upgrade Kanister CRDs to v1 from v1beta1 Jun 1, 2021
We tried to use kubebuilder to generate the CRDs for
go types but that is also not able to process some of
the types, for example `BlueprintPhase.Args`, `Phase.Output`
becauaes of `interface{}` and `Blueprint.Actions` because of
pointer type value.
- Remove required fields from CRDs
- Move CR resource names to consts package to resolve import cycle issue
- Remove un-nec logging
Even though e2e tests were running on my local cluster
tests were failing on the kanister CI, and the reason
was, when we read blueprint to create blueprint type
if a field is not specified in the blueprint, we initialized
the type with null for that field and in that case CRD validation
failed.
This commit tries to fix that by settign `omitemtpy` for those
fields.

I am thinking if we should add `omitempty` for every field in
types.go
In the test `ResourceSuite.TestBlueprintClient` we tried to
create blueprint with empty actions struct and then tried
to make sure that we are able to update the blueprint. And
checked actions after update that its not nil.
Since we are omitting empty field we are not going to get
actions if we pass empty actions, that why I have changed
the action to have some values.
Comment on lines -182 to -186
const (
BlueprintResourceName = "blueprint"
BlueprintResourceNamePlural = "blueprints"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have moved these to consts package to resolve import cycle issue that we faced when we tried to use them from customresource package.

@viveksinghggits
Copy link
Contributor Author

Per current implementation if CRDs are already created in the cluster nothing would happen. But in our case we would like to re-create them with v1 apiVersion to achieve that, if we delete and create the CRD we lose the CRs that were already created.
And we are getting below error while updating the CRD if its already present

customresourcedefinitions.apiextensions.k8s.io \"profiles.cr.kanister.io\" is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update

I am continuing looking into this.

Per current implementation we were not silently ignoring the
error if the CRDs are already present in the cluster.
Since we are significantly changing the CRD that wouldn't
work for, so this PR updates the CRDs if they are already
avaialable.
pkg/consts/consts.go Show resolved Hide resolved
pkg/customresource/actionset-crd.go Outdated Show resolved Hide resolved
pkg/customresource/actionset-crd.go Outdated Show resolved Hide resolved
pkg/customresource/actionset-crd.go Outdated Show resolved Hide resolved
pkg/customresource/actionset-crd.go Outdated Show resolved Hide resolved
pkg/customresource/actionset-crd.go Outdated Show resolved Hide resolved
pkg/customresource/actionset-crd.go Outdated Show resolved Hide resolved
pkg/customresource/customresource.go Outdated Show resolved Hide resolved
pkg/customresource/customresource.go Outdated Show resolved Hide resolved
pkg/customresource/customresource.go Outdated Show resolved Hide resolved
Copy link
Contributor

@pavannd1 pavannd1 left a comment

Choose a reason for hiding this comment

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

Do we need to change the permissions of the controller/Dockerfile or is it just a remnant of testing?

@viveksinghggits
Copy link
Contributor Author

Do we need to change the permissions of the controller/Dockerfile or is it just a remnant of testing?

Hi @pavannd1
Sorry about that we don't need that, I have fixed that now.

Copy link
Contributor

@pavannd1 pavannd1 left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot merged commit ea5ff6a into master Jun 25, 2021
@mergify mergify bot deleted the crd-v1 branch June 25, 2021 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants