From 73b6e2d5149d53fbf0cc93553eaf336002657472 Mon Sep 17 00:00:00 2001 From: Jian Zhu Date: Tue, 22 Apr 2025 16:57:23 +0800 Subject: [PATCH] check nil for LocalSecrets config (#962) Signed-off-by: zhujian --- ...cluster-manager.clusterserviceversion.yaml | 2 +- ...cluster-management.io_klusterlets.crd.yaml | 18 +++++++++++++ ...cluster-management.io_klusterlets.crd.yaml | 18 +++++++++++++ .../klusterlet.clusterserviceversion.yaml | 2 +- ...pen-cluster-management.io_klusterlets.yaml | 18 +++++++++++++ go.mod | 2 +- go.sum | 4 +-- .../klusterlet_controller.go | 3 ++- vendor/modules.txt | 2 +- ...cluster-management.io_klusterlets.crd.yaml | 18 +++++++++++++ .../api/operator/v1/types_klusterlet.go | 18 +++++++++++++ .../api/operator/v1/zz_generated.deepcopy.go | 26 +++++++++++++++++++ .../v1/zz_generated.swagger_doc_generated.go | 11 ++++++++ 13 files changed, 135 insertions(+), 7 deletions(-) diff --git a/deploy/cluster-manager/olm-catalog/latest/manifests/cluster-manager.clusterserviceversion.yaml b/deploy/cluster-manager/olm-catalog/latest/manifests/cluster-manager.clusterserviceversion.yaml index 93be637a9..63b07f8b4 100644 --- a/deploy/cluster-manager/olm-catalog/latest/manifests/cluster-manager.clusterserviceversion.yaml +++ b/deploy/cluster-manager/olm-catalog/latest/manifests/cluster-manager.clusterserviceversion.yaml @@ -59,7 +59,7 @@ metadata: categories: Integration & Delivery,OpenShift Optional certified: "false" containerImage: quay.io/open-cluster-management/registration-operator:latest - createdAt: "2025-04-16T09:20:17Z" + createdAt: "2025-04-22T08:06:53Z" description: Manages the installation and upgrade of the ClusterManager. operators.operatorframework.io/builder: operator-sdk-v1.32.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/deploy/klusterlet/chart/klusterlet/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml b/deploy/klusterlet/chart/klusterlet/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml index acd44f13e..ec7dabab5 100644 --- a/deploy/klusterlet/chart/klusterlet/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml +++ b/deploy/klusterlet/chart/klusterlet/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml @@ -251,6 +251,24 @@ spec: ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on ManagedCluster when creating only, other actors can update it afterwards. type: object + clusterClaimConfiguration: + description: |- + ClusterClaimConfiguration represents the configuration of ClusterClaim + Effective only when the `ClusterClaim` feature gate is enabled. + properties: + maxCustomClusterClaims: + default: 20 + description: Maximum number of custom ClusterClaims allowed. + format: int32 + type: integer + reservedClusterClaimSuffixes: + description: Custom suffixes for reserved ClusterClaims. + items: + type: string + type: array + required: + - maxCustomClusterClaims + type: object featureGates: description: "FeatureGates represents the list of feature gates for registration\nIf it is set empty, default feature gates diff --git a/deploy/klusterlet/config/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml b/deploy/klusterlet/config/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml index acd44f13e..ec7dabab5 100644 --- a/deploy/klusterlet/config/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml +++ b/deploy/klusterlet/config/crds/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml @@ -251,6 +251,24 @@ spec: ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on ManagedCluster when creating only, other actors can update it afterwards. type: object + clusterClaimConfiguration: + description: |- + ClusterClaimConfiguration represents the configuration of ClusterClaim + Effective only when the `ClusterClaim` feature gate is enabled. + properties: + maxCustomClusterClaims: + default: 20 + description: Maximum number of custom ClusterClaims allowed. + format: int32 + type: integer + reservedClusterClaimSuffixes: + description: Custom suffixes for reserved ClusterClaims. + items: + type: string + type: array + required: + - maxCustomClusterClaims + type: object featureGates: description: "FeatureGates represents the list of feature gates for registration\nIf it is set empty, default feature gates diff --git a/deploy/klusterlet/olm-catalog/latest/manifests/klusterlet.clusterserviceversion.yaml b/deploy/klusterlet/olm-catalog/latest/manifests/klusterlet.clusterserviceversion.yaml index 1c1ab6e8b..5f514fa20 100644 --- a/deploy/klusterlet/olm-catalog/latest/manifests/klusterlet.clusterserviceversion.yaml +++ b/deploy/klusterlet/olm-catalog/latest/manifests/klusterlet.clusterserviceversion.yaml @@ -31,7 +31,7 @@ metadata: categories: Integration & Delivery,OpenShift Optional certified: "false" containerImage: quay.io/open-cluster-management/registration-operator:latest - createdAt: "2025-04-16T09:20:17Z" + createdAt: "2025-04-22T08:06:53Z" description: Manages the installation and upgrade of the Klusterlet. operators.operatorframework.io/builder: operator-sdk-v1.32.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 diff --git a/deploy/klusterlet/olm-catalog/latest/manifests/operator.open-cluster-management.io_klusterlets.yaml b/deploy/klusterlet/olm-catalog/latest/manifests/operator.open-cluster-management.io_klusterlets.yaml index 65682128f..6fbe1a2c0 100644 --- a/deploy/klusterlet/olm-catalog/latest/manifests/operator.open-cluster-management.io_klusterlets.yaml +++ b/deploy/klusterlet/olm-catalog/latest/manifests/operator.open-cluster-management.io_klusterlets.yaml @@ -251,6 +251,24 @@ spec: ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on ManagedCluster when creating only, other actors can update it afterwards. type: object + clusterClaimConfiguration: + description: |- + ClusterClaimConfiguration represents the configuration of ClusterClaim + Effective only when the `ClusterClaim` feature gate is enabled. + properties: + maxCustomClusterClaims: + default: 20 + description: Maximum number of custom ClusterClaims allowed. + format: int32 + type: integer + reservedClusterClaimSuffixes: + description: Custom suffixes for reserved ClusterClaims. + items: + type: string + type: array + required: + - maxCustomClusterClaims + type: object featureGates: description: "FeatureGates represents the list of feature gates for registration\nIf it is set empty, default feature gates diff --git a/go.mod b/go.mod index 7fc111701..a1071142a 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( k8s.io/kube-aggregator v0.32.1 k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 open-cluster-management.io/addon-framework v0.12.1-0.20250407131028-9d436ffc2da7 - open-cluster-management.io/api v0.16.2-0.20250416130057-11622a5f2170 + open-cluster-management.io/api v0.16.2-0.20250422072120-cadf714c3055 open-cluster-management.io/sdk-go v0.16.1-0.20250411154302-3a424961ead4 sigs.k8s.io/cluster-inventory-api v0.0.0-20240730014211-ef0154379848 sigs.k8s.io/controller-runtime v0.20.2 diff --git a/go.sum b/go.sum index 41f85e8e0..6afa7d605 100644 --- a/go.sum +++ b/go.sum @@ -487,8 +487,8 @@ k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6J k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= open-cluster-management.io/addon-framework v0.12.1-0.20250407131028-9d436ffc2da7 h1:oLu9ag44Msf56Hb19b/b+UTNq0J2l9rhlBQ1gh7izCU= open-cluster-management.io/addon-framework v0.12.1-0.20250407131028-9d436ffc2da7/go.mod h1:7AEw1Sq9UEWpQGTU8zV1XPNkFRBYPbyBh8tfhISV++s= -open-cluster-management.io/api v0.16.2-0.20250416130057-11622a5f2170 h1:SFtPxSCIPwDEv4iXNb4CiwjkT1gLdk6bPJGeFaKv6Ho= -open-cluster-management.io/api v0.16.2-0.20250416130057-11622a5f2170/go.mod h1:/OeqXycNBZQoe3WG6ghuWsMgsKGuMZrK8ZpsU6gWL0Y= +open-cluster-management.io/api v0.16.2-0.20250422072120-cadf714c3055 h1:D2vT3nnMS/To3ptz8LLg1zfJm/pL8XIaO1g7Qbyc/5o= +open-cluster-management.io/api v0.16.2-0.20250422072120-cadf714c3055/go.mod h1:/OeqXycNBZQoe3WG6ghuWsMgsKGuMZrK8ZpsU6gWL0Y= open-cluster-management.io/sdk-go v0.16.1-0.20250411154302-3a424961ead4 h1:PT6kDaKjDi0EaQyNzIWzYAYeK4QpBHbm+/7VPrpJEkY= open-cluster-management.io/sdk-go v0.16.1-0.20250411154302-3a424961ead4/go.mod h1:FtOYjn5dL8e9S1gzNb8cBNsFzHJ1F3cpmCo+qrltido= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 h1:CPT0ExVicCzcpeN4baWEV2ko2Z/AsiZgEdwgcfwLgMo= diff --git a/pkg/operator/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go b/pkg/operator/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go index 4df13ae7d..6e43131df 100644 --- a/pkg/operator/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go +++ b/pkg/operator/operators/klusterlet/controllers/klusterletcontroller/klusterlet_controller.go @@ -214,7 +214,8 @@ func (config *klusterletConfig) populateBootstrap(klusterlet *operatorapiv1.Klus if config.MultipleHubs { var bootstapKubeconfigSecrets []string - if klusterlet.Spec.RegistrationConfiguration.BootstrapKubeConfigs.Type == operatorapiv1.LocalSecrets { + if klusterlet.Spec.RegistrationConfiguration.BootstrapKubeConfigs.Type == operatorapiv1.LocalSecrets && + klusterlet.Spec.RegistrationConfiguration.BootstrapKubeConfigs.LocalSecrets != nil { for _, secret := range klusterlet.Spec.RegistrationConfiguration.BootstrapKubeConfigs.LocalSecrets.KubeConfigSecrets { bootstapKubeconfigSecrets = append(bootstapKubeconfigSecrets, secret.Name) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 84f4d8e90..e722c6730 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1714,7 +1714,7 @@ open-cluster-management.io/addon-framework/pkg/agent open-cluster-management.io/addon-framework/pkg/assets open-cluster-management.io/addon-framework/pkg/index open-cluster-management.io/addon-framework/pkg/utils -# open-cluster-management.io/api v0.16.2-0.20250416130057-11622a5f2170 +# open-cluster-management.io/api v0.16.2-0.20250422072120-cadf714c3055 ## explicit; go 1.23.6 open-cluster-management.io/api/addon/v1alpha1 open-cluster-management.io/api/client/addon/clientset/versioned diff --git a/vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml b/vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml index acd44f13e..ec7dabab5 100644 --- a/vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml +++ b/vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml @@ -251,6 +251,24 @@ spec: ClusterAnnotations is annotations with the reserve prefix "agent.open-cluster-management.io" set on ManagedCluster when creating only, other actors can update it afterwards. type: object + clusterClaimConfiguration: + description: |- + ClusterClaimConfiguration represents the configuration of ClusterClaim + Effective only when the `ClusterClaim` feature gate is enabled. + properties: + maxCustomClusterClaims: + default: 20 + description: Maximum number of custom ClusterClaims allowed. + format: int32 + type: integer + reservedClusterClaimSuffixes: + description: Custom suffixes for reserved ClusterClaims. + items: + type: string + type: array + required: + - maxCustomClusterClaims + type: object featureGates: description: "FeatureGates represents the list of feature gates for registration\nIf it is set empty, default feature gates diff --git a/vendor/open-cluster-management.io/api/operator/v1/types_klusterlet.go b/vendor/open-cluster-management.io/api/operator/v1/types_klusterlet.go index 524b350d3..706db8901 100644 --- a/vendor/open-cluster-management.io/api/operator/v1/types_klusterlet.go +++ b/vendor/open-cluster-management.io/api/operator/v1/types_klusterlet.go @@ -176,6 +176,24 @@ type RegistrationConfiguration struct { // This provides driver details required to register with hub // +optional RegistrationDriver RegistrationDriver `json:"registrationDriver,omitempty"` + + // ClusterClaimConfiguration represents the configuration of ClusterClaim + // Effective only when the `ClusterClaim` feature gate is enabled. + // +optional + ClusterClaimConfiguration *ClusterClaimConfiguration `json:"clusterClaimConfiguration,omitempty"` +} + +// ClusterClaimConfiguration represents the configuration of ClusterClaim +type ClusterClaimConfiguration struct { + // Maximum number of custom ClusterClaims allowed. + // +kubebuilder:validation:Required + // +kubebuilder:default:=20 + // +required + MaxCustomClusterClaims int32 `json:"maxCustomClusterClaims"` + + // Custom suffixes for reserved ClusterClaims. + // +optional + ReservedClusterClaimSuffixes []string `json:"reservedClusterClaimSuffixes,omitempty"` } type RegistrationDriver struct { diff --git a/vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go index 1cfb0760a..240612641 100644 --- a/vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go +++ b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.deepcopy.go @@ -116,6 +116,27 @@ func (in *CSRConfig) DeepCopy() *CSRConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterClaimConfiguration) DeepCopyInto(out *ClusterClaimConfiguration) { + *out = *in + if in.ReservedClusterClaimSuffixes != nil { + in, out := &in.ReservedClusterClaimSuffixes, &out.ReservedClusterClaimSuffixes + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaimConfiguration. +func (in *ClusterClaimConfiguration) DeepCopy() *ClusterClaimConfiguration { + if in == nil { + return nil + } + out := new(ClusterClaimConfiguration) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterManager) DeepCopyInto(out *ClusterManager) { *out = *in @@ -574,6 +595,11 @@ func (in *RegistrationConfiguration) DeepCopyInto(out *RegistrationConfiguration } in.BootstrapKubeConfigs.DeepCopyInto(&out.BootstrapKubeConfigs) in.RegistrationDriver.DeepCopyInto(&out.RegistrationDriver) + if in.ClusterClaimConfiguration != nil { + in, out := &in.ClusterClaimConfiguration, &out.ClusterClaimConfiguration + *out = new(ClusterClaimConfiguration) + (*in).DeepCopyInto(*out) + } return } diff --git a/vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go index d3b34fd11..f4af98601 100644 --- a/vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go +++ b/vendor/open-cluster-management.io/api/operator/v1/zz_generated.swagger_doc_generated.go @@ -210,6 +210,16 @@ func (BootstrapKubeConfigs) SwaggerDoc() map[string]string { return map_BootstrapKubeConfigs } +var map_ClusterClaimConfiguration = map[string]string{ + "": "ClusterClaimConfiguration represents the configuration of ClusterClaim", + "maxCustomClusterClaims": "Maximum number of custom ClusterClaims allowed.", + "reservedClusterClaimSuffixes": "Custom suffixes for reserved ClusterClaims.", +} + +func (ClusterClaimConfiguration) SwaggerDoc() map[string]string { + return map_ClusterClaimConfiguration +} + var map_HubApiServerHostAlias = map[string]string{ "": "HubApiServerHostAlias holds the mapping between IP and hostname that will be injected as an entry in the pod's hosts file.", "ip": "IP address of the host file entry.", @@ -307,6 +317,7 @@ var map_RegistrationConfiguration = map[string]string{ "kubeAPIBurst": "KubeAPIBurst indicates the maximum burst of the throttle while talking with apiserver of hub cluster from the spoke cluster. If it is set empty, use the default value: 100", "bootstrapKubeConfigs": "BootstrapKubeConfigs defines the ordered list of bootstrap kubeconfigs. The order decides which bootstrap kubeconfig to use first when rebootstrap.\n\nWhen the agent loses the connection to the current hub over HubConnectionTimeoutSeconds, or the managedcluster CR is set `hubAcceptsClient=false` on the hub, the controller marks the related bootstrap kubeconfig as \"failed\".\n\nA failed bootstrapkubeconfig won't be used for the duration specified by SkipFailedBootstrapKubeConfigSeconds. But if the user updates the content of a failed bootstrapkubeconfig, the \"failed\" mark will be cleared.", "registrationDriver": "This provides driver details required to register with hub", + "clusterClaimConfiguration": "ClusterClaimConfiguration represents the configuration of ClusterClaim Effective only when the `ClusterClaim` feature gate is enabled.", } func (RegistrationConfiguration) SwaggerDoc() map[string]string {