SovereignCloudStack / cluster-stack-operator

The SCS Cluster Stack Operator takes care of life cycle management, configuration and provider specific tasks of Kubernetes clusters created with SCS Cluster Stacks
https://scs.community/
Apache License 2.0
8 stars 3 forks source link

USABLE and LATEST columns showing wrong values #57

Open chess-knight opened 7 months ago

chess-knight commented 7 months ago

/kind bug

What steps did you take and what happened:

Create clusterstack with multiple versions, e.g.:

apiVersion: clusterstack.x-k8s.io/v1alpha1
kind: ClusterStack
metadata:
  name: clusterstack
  namespace: cluster
spec:
  provider: openstack
  name: ferrol
  kubernetesVersion: "1.27"
  channel: stable
  autoSubscribe: false
  providerRef:
    apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
    kind: OpenStackClusterStackReleaseTemplate
    name: cspotemplate
  versions:
    - v1
    - v2
    - v3
    - v4

Wait for clusterstackreleases to be Ready:

$ kubectl get clusterstackreleases.clusterstack.x-k8s.io -n cluster
NAME                       K8S VERSION   READY   AGE    REASON   MESSAGE
openstack-ferrol-1-27-v1   v1.27.5       true    113m            
openstack-ferrol-1-27-v2   v1.27.5       true    113m            
openstack-ferrol-1-27-v3   v1.27.8       true    113m            
openstack-ferrol-1-27-v4   v1.27.8       true    113m

Get clusterstack:

$ kubectl get clusterstack clusterstack -n cluster 
NAME           PROVIDER    CLUSTERSTACK   K8S    CHANNEL   AUTOSUBSCRIBE   USABLE           LATEST                               AGE    REASON   MESSAGE
clusterstack   openstack   ferrol         1.27   stable    false           v3, v3, v3, v3   openstack-ferrol-1-27-v3 | v1.27.8   113m
$ kubectl get clusterstack clusterstack -n cluster 
NAME           PROVIDER    CLUSTERSTACK   K8S    CHANNEL   AUTOSUBSCRIBE   USABLE           LATEST                               AGE    REASON   MESSAGE
clusterstack   openstack   ferrol         1.27   stable    false           v1, v1, v1, v1   openstack-ferrol-1-27-v1 | v1.27.5   119m

I see the wrong USABLE and LATEST columns. It is also changing over time.

What did you expect to happen:

USABLE: v1, v2, v3, v4 LATEST: openstack-ferrol-1-27-v4 | v1.27.8

Environment:

janiskemper commented 7 months ago

thanks! I will look into this!

jschoone commented 2 months ago

Hi @janiskemper, I think faced the same issue.

I build Cluster Stacks for Kubernetes 1.{27..30} in hash mode and got those:

ls -1 .release
openstack-scs-1-27-v0-sha-uaneeqt
openstack-scs-1-28-v0-sha-dowig83
openstack-scs-1-29-v0-sha-n42lfdt
openstack-scs-1-30-v0-sha-kuuaqoz

So the yaml looks as follows:

---
apiVersion: clusterstack.x-k8s.io/v1alpha1
kind: ClusterStack
metadata:
  name: openstack-scs-1-27
spec:
  provider: openstack
  name: scs
  kubernetesVersion: "1.27"
  channel: custom
  autoSubscribe: false
  providerRef:
    apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
    kind: OpenStackClusterStackReleaseTemplate
    name: cspotemplate
  versions:
  - v0-sha.uaneeqt
---
apiVersion: clusterstack.x-k8s.io/v1alpha1
kind: ClusterStack
metadata:
  name: openstack-scs-1-28
spec:
  provider: openstack
  name: scs
  kubernetesVersion: "1.28"
  channel: custom
  autoSubscribe: false
  providerRef:
    apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
    kind: OpenStackClusterStackReleaseTemplate
    name: cspotemplate
  versions:
  - v0-sha.dowig83
---
apiVersion: clusterstack.x-k8s.io/v1alpha1
kind: ClusterStack
metadata:
  name: openstack-scs-1-29
spec:
  provider: openstack
  name: scs
  kubernetesVersion: "1.29"
  channel: custom
  autoSubscribe: false
  providerRef:
    apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
    kind: OpenStackClusterStackReleaseTemplate
    name: cspotemplate
  versions:
  - v0-sha.n42lfdt
---
apiVersion: clusterstack.x-k8s.io/v1alpha1
kind: ClusterStack
metadata:
  name: openstack-scs-1-30
spec:
  provider: openstack
  name: scs
  kubernetesVersion: "1.30"
  channel: custom
  autoSubscribe: false
  providerRef:
    apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
    kind: OpenStackClusterStackReleaseTemplate
    name: cspotemplate
  versions:
  - v0-sha.kuuaqoz

Everything seems to be deployed correctly. ClusterStacksReleases:

kubectl get clusterstackreleases
NAME                                K8S VERSION   READY   AGE   REASON   MESSAGE
openstack-scs-1-27-v0-sha-uaneeqt   v1.27.15      true    15h
openstack-scs-1-28-v0-sha-dowig83   v1.28.11      true    15h
openstack-scs-1-29-v0-sha-n42lfdt   v1.29.6       true    15h
openstack-scs-1-30-v0-sha-kuuaqoz   v1.30.2       true    15h
kubectl get openstacknodeimagereleases
NAME                                                           READY   AGE   REASON   MESSAGE
openstack-scs-1-27-ubuntu-capi-image-v1.27.15-v0-sha-uaneeqt   true    15h            
openstack-scs-1-28-ubuntu-capi-image-v1.28.11-v0-sha-dowig83   true    15h            
openstack-scs-1-29-ubuntu-capi-image-v1.29.6-v0-sha-n42lfdt    true    15h            
openstack-scs-1-30-ubuntu-capi-image-v1.30.2-v0-sha-kuuaqoz    true    15h            

And ClusterClass:

kubectl get cc
NAME                                AGE
openstack-scs-1-27-v0-sha.uaneeqt   15h
openstack-scs-1-28-v0-sha.dowig83   15h
openstack-scs-1-29-v0-sha.n42lfdt   15h
openstack-scs-1-30-v0-sha.kuuaqoz   15h

But the ClusterStacks look really weird:

kubectl get clusterstack
NAME                 PROVIDER    CLUSTERSTACK   K8S    CHANNEL   AUTOSUBSCRIBE   USABLE           LATEST                                         AGE   REASON   MESSAGE
openstack-scs-1-27   openstack   scs            1.27   custom    false           v0-sha-uaneeqt   openstack-scs-1-27-v0-sha-uaneeqt | v1.27.15   16h
openstack-scs-1-28   openstack   scs            1.28   custom    false           v0-sha-uaneeqt   openstack-scs-1-27-v0-sha-uaneeqt | v1.27.15   16h
openstack-scs-1-29   openstack   scs            1.29   custom    false           v0-sha-uaneeqt   openstack-scs-1-27-v0-sha-uaneeqt | v1.27.15   16h
openstack-scs-1-30   openstack   scs            1.30   custom    false           v0-sha-uaneeqt   openstack-scs-1-27-v0-sha-uaneeqt | v1.27.15   16h

Showing one in detail:

kubectl get clusterstack openstack-scs-1-29 -oyaml
apiVersion: clusterstack.x-k8s.io/v1alpha1
kind: ClusterStack
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"clusterstack.x-k8s.io/v1alpha1","kind":"ClusterStack","metadata":{"annotations":{},"name":"openstack-scs-1-29","namespace":"cluster"},"spec":{"autoSubscribe":false,"channel":"custom","kubernetesVersion":"1.29","name":"scs","provider":"openstack","providerRef":{"apiVersion":"infrastructure.clusterstack.x-k8s.io/v1alpha1","kind":"OpenStackClusterStackReleaseTemplate","name":"cspotemplate"},"versions":["v0-sha.n42lfdt"]}}
  creationTimestamp: "2024-06-24T14:57:28Z"
  generation: 1
  name: openstack-scs-1-29
  namespace: cluster
  resourceVersion: "105475"
  uid: b6e85127-4155-4202-987b-ef46b01ba189
spec:
  autoSubscribe: false
  channel: custom
  kubernetesVersion: "1.29"
  name: scs
  noProvider: false
  provider: openstack
  providerRef:
    apiVersion: infrastructure.clusterstack.x-k8s.io/v1alpha1
    kind: OpenStackClusterStackReleaseTemplate
    name: cspotemplate
  versions:
  - v0-sha.n42lfdt
status:
  conditions:
  - lastTransitionTime: "2024-06-24T14:57:49Z"
    status: "True"
    type: Ready
  - lastTransitionTime: "2024-06-24T15:49:39Z"
    status: "True"
    type: ClusterStackReleaseAvailable
  - lastTransitionTime: "2024-06-24T14:57:49Z"
    status: "True"
    type: ClusterStackReleasesSynced
  - lastTransitionTime: "2024-06-24T14:57:49Z"
    status: "True"
    type: ProviderClusterStackReleasesSynced
  latestRelease: openstack-scs-1-27-v0-sha-uaneeqt | v1.27.15
  summary:
  - name: v0-sha-uaneeqt
    phase: done
    ready: true
  - name: v0-sha-n42lfdt
    phase: ""
    ready: false
  usableVersions: v0-sha-uaneeqt
janiskemper commented 2 months ago

You are not allowed to have multiple ClusterStack objects with the same properties in one namespace. Actually we want to introduce a webhook that forbids this.

There is no handling for this. For example the clusterstackreleases get owned by the clusterStack that fits their properties.