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

fix: chart crd forceUpgrade field should be nil by default #5068

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

emosbaugh
Copy link
Contributor

Description

Even though the forceUpgrade field is a nil pointer, the k8s controller seems to be setting the field automatically in CRs that exist once the CRD is updated via a k0s upgrade. I believe this is because it defaults to true via the generated openapi spec.

              forceUpgrade:
                default: true
                description: 'ForceUpgrade when set to false, disables the use of
                  the "--force" flag when upgrading the the chart (default: true).'
                type: boolean

This results in a backwards incompatible change for those importing the schema prior to this version.

W1001 20:21:35.308507       1 reflector.go:539] pkg/mod/k8s.io/[email protected]/tools/cache/reflector.go:229: failed to list *v1beta1.ClusterConfig: json: unknown field "forceUpgrade"
$ curl -sSLf https://get.k0s.sh | sudo K0S_VERSION=v1.29.8+k0s.0 sh
$ sudo k0s install controller --single --config k0s.yaml --enable-dynamic-config
$ sudo k0s start
$ sudo k0s kubectl get clusterconfigs -A -oyaml
apiVersion: v1
items:
- apiVersion: k0s.k0sproject.io/v1beta1
  kind: ClusterConfig
  metadata:
    creationTimestamp: "2024-10-02T15:59:08Z"
    generation: 1
    name: k0s
    namespace: kube-system
    resourceVersion: "199"
    uid: 6b31fcff-9901-4545-bd4d-5c406052a7a4
  spec:
    extensions:
      helm:
        charts:
        - chartname: twuni/docker-registry
          name: docker-registry
          namespace: registry
          order: 0
          timeout: 0
          values: ""
          version: 2.2.3
        concurrencyLevel: 5
$ sudo k0s stop
$ curl -sSLf https://get.k0s.sh | sudo K0S_VERSION=v1.29.9+k0s.0 sh
$ sudo k0s start
$ sudo k0s kubectl get clusterconfigs -A -oyaml
apiVersion: v1
items:
- apiVersion: k0s.k0sproject.io/v1beta1
  kind: ClusterConfig
  metadata:
    creationTimestamp: "2024-10-02T15:59:08Z"
    generation: 1
    name: k0s
    namespace: kube-system
    resourceVersion: "199"
    uid: 6b31fcff-9901-4545-bd4d-5c406052a7a4
  spec:
    extensions:
      helm:
        charts:
        - chartname: twuni/docker-registry
          forceUpgrade: true
          name: docker-registry
          namespace: registry
          order: 0
          timeout: 0
          values: ""
          version: 2.2.3
        concurrencyLevel: 5

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added
$ curl -sSLf https://get.k0s.sh | sudo K0S_VERSION=v1.29.8+k0s.0 sh
$ sudo k0s install controller --single --config k0s.yaml --enable-dynamic-config
$ sudo k0s start
$ sudo k0s kubectl get clusterconfigs -A -oyaml
apiVersion: v1
items:
- apiVersion: k0s.k0sproject.io/v1beta1
  kind: ClusterConfig
  metadata:
    creationTimestamp: "2024-10-02T15:59:08Z"
    generation: 1
    name: k0s
    namespace: kube-system
    resourceVersion: "199"
    uid: 6b31fcff-9901-4545-bd4d-5c406052a7a4
  spec:
    extensions:
      helm:
        charts:
        - chartname: twuni/docker-registry
          name: docker-registry
          namespace: registry
          order: 0
          timeout: 0
          values: ""
          version: 2.2.3
        concurrencyLevel: 5
$ sudo k0s stop
$ # Install custom build
$ sudo k0s start
$ sudo k0s kubectl get crd clusterconfigs.k0s.k0sproject.io -oyaml | grep forceUpgrade: -A 6
                            forceUpgrade:
                              description: 'ForceUpgrade when set to false, disables
                                the use of the "--force" flag when upgrading the the
                                chart (default: true).'
                              type: boolean
                            name:
                              type: string
$ sudo k0s kubectl get clusterconfigs -A -oyaml
apiVersion: v1
items:
- apiVersion: k0s.k0sproject.io/v1beta1
  kind: ClusterConfig
  metadata:
    creationTimestamp: "2024-10-02T16:05:16Z"
    generation: 1
    name: k0s
    namespace: kube-system
    resourceVersion: "199"
    uid: 4f079d8f-f8e2-4e92-b980-4d137b409c31
  spec:
    extensions:
      helm:
        charts:
        - chartname: twuni/docker-registry
          name: docker-registry
          namespace: registry
          order: 0
          timeout: 0
          values: ""
          version: 2.2.3
        concurrencyLevel: 5

To test for forward compatibility, install the latest k0s 1.30 release and see that it upgrades fine back to default: true.

$ sudo k0s stop
$ curl -sSLf https://get.k0s.sh | sudo K0S_VERSION=v1.30.5+k0s.0 sh
$ sudo k0s start
$ sudo k0s kubectl version
Client Version: v1.30.5
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.5+k0s
$ sudo k0s kubectl get clusterconfigs -A -oyaml
apiVersion: v1
items:
- apiVersion: k0s.k0sproject.io/v1beta1
  kind: ClusterConfig
  metadata:
    creationTimestamp: "2024-10-02T16:05:16Z"
    generation: 1
    name: k0s
    namespace: kube-system
    resourceVersion: "199"
    uid: 4f079d8f-f8e2-4e92-b980-4d137b409c31
  spec:
    extensions:
      helm:
        charts:
        - chartname: twuni/docker-registry
          forceUpgrade: true
          name: docker-registry
          namespace: registry
          order: 0
          timeout: 0
          values: ""
          version: 2.2.3
        concurrencyLevel: 5

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@emosbaugh emosbaugh requested a review from a team as a code owner October 2, 2024 16:21
@twz123
Copy link
Member

twz123 commented Oct 2, 2024

/xref #4866

@twz123 twz123 added area/helm chore backport/release-1.31 PR that needs to be backported/cherrypicked to the release-1.31 branch labels Oct 2, 2024
@twz123 twz123 merged commit a0da55a into k0sproject:main Oct 3, 2024
92 checks passed
@k0s-bot
Copy link

k0s-bot commented Oct 3, 2024

Successfully created backport PR for release-1.31:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration area/helm backport/release-1.31 PR that needs to be backported/cherrypicked to the release-1.31 branch chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants