From 07d741ee5a7385b9112366aedb2d9a3719c3b5d7 Mon Sep 17 00:00:00 2001 From: Zeid Adabel Date: Wed, 4 Sep 2024 13:19:45 +0200 Subject: [PATCH 1/6] Exposing scale subresource to enable HPA's to modify the replicas of the Infinispan CR --- config/crd/bases/infinispan.org_infinispans.yaml | 3 +++ .../bases/infinispan-operator.clusterserviceversion.yaml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/config/crd/bases/infinispan.org_infinispans.yaml b/config/crd/bases/infinispan.org_infinispans.yaml index 4db43ccac..47ea0129c 100644 --- a/config/crd/bases/infinispan.org_infinispans.yaml +++ b/config/crd/bases/infinispan.org_infinispans.yaml @@ -2464,4 +2464,7 @@ spec: served: true storage: true subresources: + scale: + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas status: {} diff --git a/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml b/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml index b9c4bdd7a..da2d75ca7 100644 --- a/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml @@ -136,6 +136,8 @@ spec: path: replicas x-descriptors: - urn:alm:descriptor:com.tectonic.ui:podCount + - displayName: Replicas + path: Replicas - description: A secret that contains CredentialStore alias and password combinations displayName: CredentialStore Secret path: security.credentialStoreSecretName From b6d496e83adc3dd19451ca47d0519168ead82fe1 Mon Sep 17 00:00:00 2001 From: Zeid Adabel Date: Wed, 4 Sep 2024 13:19:45 +0200 Subject: [PATCH 2/6] Adding kubebuilder field --- api/v1/infinispan_types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/api/v1/infinispan_types.go b/api/v1/infinispan_types.go index 69905f41d..7209665ba 100644 --- a/api/v1/infinispan_types.go +++ b/api/v1/infinispan_types.go @@ -663,6 +663,7 @@ type Operator struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas // +operator-sdk:csv:customresourcedefinitions:displayName="Infinispan Cluster" // Infinispan is the Schema for the infinispans API From da838d6b9531099206429b4696d551ae55f727cf Mon Sep 17 00:00:00 2001 From: Zeid Adabel Date: Wed, 4 Sep 2024 13:20:34 +0200 Subject: [PATCH 3/6] Updated controller-gen to 0.15.0 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e5d093537..2fbaa78c2 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize MOCKGEN ?= $(LOCALBIN)/mockgen ## Tool Versions -CONTROLLER_TOOLS_VERSION ?= v0.14.0 +CONTROLLER_TOOLS_VERSION ?= v0.15.0 GO_JUNIT_REPORT_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.59.1 KUSTOMIZE_VERSION ?= v3.8.7 From c35359e6fcd99825b31596063fe1f91344667b24 Mon Sep 17 00:00:00 2001 From: Zeid Adabel Date: Wed, 4 Sep 2024 13:20:34 +0200 Subject: [PATCH 4/6] Fix missing label selector on HPA --- api/v1/infinispan_types.go | 5 ++++- config/crd/bases/infinispan.org_infinispans.yaml | 4 ++++ .../pipeline/infinispan/handler/provision/statefulsets.go | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/api/v1/infinispan_types.go b/api/v1/infinispan_types.go index 7209665ba..fe0766d29 100644 --- a/api/v1/infinispan_types.go +++ b/api/v1/infinispan_types.go @@ -611,6 +611,9 @@ type InfinispanStatus struct { // +optional // +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Operator Status" Operator Operator `json:"operator,omitempty"` + // The Operator Selector + // +optional + Selector string `json:"selector"` } type OperandPhase string @@ -663,7 +666,7 @@ type Operator struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status -// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas +// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector // +operator-sdk:csv:customresourcedefinitions:displayName="Infinispan Cluster" // Infinispan is the Schema for the infinispans API diff --git a/config/crd/bases/infinispan.org_infinispans.yaml b/config/crd/bases/infinispan.org_infinispans.yaml index 47ea0129c..7c885d300 100644 --- a/config/crd/bases/infinispan.org_infinispans.yaml +++ b/config/crd/bases/infinispan.org_infinispans.yaml @@ -2457,6 +2457,9 @@ spec: description: The secret that contains user credentials. type: string type: object + selector: + description: The Operator Selector + type: string statefulSetName: type: string type: object @@ -2465,6 +2468,7 @@ spec: storage: true subresources: scale: + labelSelectorPath: .status.selector specReplicasPath: .spec.replicas statusReplicasPath: .status.replicas status: {} diff --git a/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go b/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go index 348ca39aa..b9b07ed4d 100644 --- a/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go +++ b/pkg/reconcile/pipeline/infinispan/handler/provision/statefulsets.go @@ -60,9 +60,16 @@ func ClusterStatefulSet(i *ispnv1.Infinispan, ctx pipeline.Context) { return } + selector, err := metav1.LabelSelectorAsSelector(statefulSet.Spec.Selector) + + if err != nil { + ctx.Requeue(fmt.Errorf("error retrieving StatefulSet labels: %w", err)) + return + } _ = ctx.UpdateInfinispan(func() { i.Status.Replicas = &i.Spec.Replicas i.Status.StatefulSetName = statefulSet.Name + i.Status.Selector = selector.String() }) } From 40ef01d297fe87f994d9dadfd9f23c1f86449325 Mon Sep 17 00:00:00 2001 From: Zeid Adabel Date: Wed, 4 Sep 2024 13:21:43 +0200 Subject: [PATCH 5/6] Revert "Updated controller-gen to 0.15.0" This reverts commit da838d6b9531099206429b4696d551ae55f727cf. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2fbaa78c2..e5d093537 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ KUSTOMIZE ?= $(LOCALBIN)/kustomize MOCKGEN ?= $(LOCALBIN)/mockgen ## Tool Versions -CONTROLLER_TOOLS_VERSION ?= v0.15.0 +CONTROLLER_TOOLS_VERSION ?= v0.14.0 GO_JUNIT_REPORT_VERSION ?= latest GOLANGCI_LINT_VERSION ?= v1.59.1 KUSTOMIZE_VERSION ?= v3.8.7 From 6afdd5dada06dd2936544ebfa62c3047bd504e93 Mon Sep 17 00:00:00 2001 From: Zeid Adabel Date: Mon, 9 Sep 2024 16:08:45 +0200 Subject: [PATCH 6/6] Fix review comments --- api/v1/infinispan_types.go | 2 +- .../bases/infinispan-operator.clusterserviceversion.yaml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/api/v1/infinispan_types.go b/api/v1/infinispan_types.go index fe0766d29..c29e67dce 100644 --- a/api/v1/infinispan_types.go +++ b/api/v1/infinispan_types.go @@ -611,7 +611,7 @@ type InfinispanStatus struct { // +optional // +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Operator Status" Operator Operator `json:"operator,omitempty"` - // The Operator Selector + // The Selector used to identify Infinispan cluster pods // +optional Selector string `json:"selector"` } diff --git a/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml b/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml index da2d75ca7..b9c4bdd7a 100644 --- a/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/infinispan-operator.clusterserviceversion.yaml @@ -136,8 +136,6 @@ spec: path: replicas x-descriptors: - urn:alm:descriptor:com.tectonic.ui:podCount - - displayName: Replicas - path: Replicas - description: A secret that contains CredentialStore alias and password combinations displayName: CredentialStore Secret path: security.credentialStoreSecretName