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 helm-operator to Helm v3 #2080

Merged
merged 12 commits into from
Dec 12, 2019

Conversation

joelanford
Copy link
Member

@joelanford joelanford commented Oct 18, 2019

Description of the change:
This PR bumps Helm to v3.0.0, adds the helm-2to3 plugin to auto migrate existing CRs, and refactors relevant portions of the helm operator code due to the restructuring between helm 2 and helm 3

Motivation for the change:
To support Helm 3 in Operator SDK

@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 Oct 18, 2019
@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 18, 2019
go.mod Outdated
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190128024246-5eb7ae5bdb7a

// TODO: Can OLM use valid go modules version numbers?
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20190926160646-a61144936680
Copy link
Member

Choose a reason for hiding this comment

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

We've been wanting to, but some openshift automation added a v3.11 tag to our repository, which would force us to start at a greater semver for minimal version selection to skip it. IIRC, this happened right as we started to use modules (go 1.11 timeframe). We should revisit this soon.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh no! That's a bummer. I don't envy you. However, since there's no go.mod file on the commit tagged with v3.11.0, you might not be totally hosed. See https://github.com/golang/go/wiki/Modules#semantic-import-versioning, specifically item 2 in the "Three Transitional Exceptions" section.

It might be worth trying to add a valid go module semver tag in a throwaway fork at v0.12.0 to see whether you can import at that version without getting bumped "up" to v3.11.0. I'm pretty sure that will work.

Also since v3.11.0 is not a go module (since it is lacking a go.mod file), you may even be able to delete the v3.11.0 tag with little consequences. Don't quote me on that, but that's something else that might be worth trying in a throwaway fork.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Nov 13, 2019

@joelanford: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/marker 67e0b80 link /test marker

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.

@camilamacedo86 camilamacedo86 added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2019
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 21, 2019
@joelanford joelanford changed the title WIP: transition to Helm v3 and K8s 1.16 Upgrade helm-operator to Helm v3 Nov 21, 2019
@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 Nov 21, 2019
return releaseHistory, len(releaseHistory) > 0, nil
}

func releaseHistoryV3(storageBackend *v3storage.Storage, releaseName string) ([]*helmreleasev3.Release, bool, error) {
Copy link
Contributor

@camilamacedo86 camilamacedo86 Nov 26, 2019

Choose a reason for hiding this comment

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

Why is required have releaseHistoryV2 and releaseHistoryV3? Will we keep the compatibility with old versions?
Should it still work with v2 helms?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is necessary to handle automatically migrating existing Helm v2 releases to Helm v3. The idea here is that a user with existing CRs and an existing Helm v2-based operator can upgrade to the new Helm 3-based operator and the new operator will handle the transition seamlessly.

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

It mainly shows fine. I added a few questions/comments.
Also, it is missing the CHANGELOG and update all link docs to address the users check the refs in the helm3 docs instead of 2.

return nil, fmt.Errorf("failed to render chart templates: %s", err)
}
return tiller.SortByKind(releaseutil.SplitManifests(renderedTemplates)), nil
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Should not it be removed? Why keep this code commented?

@jmccormick2001
Copy link
Contributor

it could be my environment, but I built sdk for this PR, ran the user guide steps and am
seeing the following:

the CR shows size of 2....

replicaCount: 2
resources: {}
securityContext: {}
service:
  port: 8080
  type: ClusterIP
serviceAccount:
  create: true
  name: null
tolerations: []

kind: List
metadata:
resourceVersion: ""
selfLink: ""

but only a single pod and deployment is running....
jeffmc@doppio114 ~/projects/helmtest/nginx-operator> kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-operator-6c7c94494b-9nc6m 1/1 Running 0 90s
jeffmc@doppio114 ~/projects/helmtest/nginx-operator> kubectl get deploy
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-operator 1/1 1 1 119s

I'm seeing this in the operator log:
{"level":"error","ts":1575416482.6321547,"logger":"controller-runtime.controller","msg":"Reconciler error","controller":"nginx-controller","request":"default/example-nginx","error":"failed to load chart dir: apiVersion 'v2' is not valid. The value must be "v1"","stacktrace":"github.com/go-logr/zapr.

here is my test env:
jeffmc@doppio114 ~/projects/nginx-operator> kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:23:11Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:13:49Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
jeffmc@doppio114 ~/projects/nginx-operator> go version
go version go1.13.1 linux/amd64

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.

LGTM overall, just a bunch of nits and questions.

cmd/operator-sdk/new/cmd.go Outdated Show resolved Hide resolved
doc/helm/dev/developer_guide.md Show resolved Hide resolved
internal/scaffold/helm/chart.go Outdated Show resolved Hide resolved
internal/scaffold/helm/chart_test.go Show resolved Hide resolved
pkg/helm/release/manager.go Show resolved Hide resolved
pkg/helm/release/manager_factory.go Outdated Show resolved Hide resolved
pkg/helm/release/manager_factory.go Outdated Show resolved Hide resolved
pkg/helm/release/manager_factory.go Outdated Show resolved Hide resolved
pkg/helm/release/manager_factory.go Outdated Show resolved Hide resolved
pkg/helm/release/manager_factory.go Outdated Show resolved Hide resolved
@jmccormick2001
Copy link
Contributor

seems to test out ok on OCP 4.2, I deployed using the master branch (helm v2), then deleted the nginx-operator, then built a new nginx-operator against this PR code, redeployed the nginx-operator, then updated the CR to add a new nginx pod, seems to work.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 10, 2019
@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 10, 2019
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.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Dec 10, 2019
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Dec 11, 2019
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@joelanford joelanford merged commit 92cfdf3 into operator-framework:master Dec 12, 2019
@joelanford joelanford deleted the helm-v3 branch December 12, 2019 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dependency Issues or PRs related to dependency changes size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants