Skip to content

Commit

Permalink
Fix missing label selector on HPA
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeidH committed Sep 4, 2024
1 parent da838d6 commit c35359e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/v1/infinispan_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/infinispan.org_infinispans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -2465,6 +2468,7 @@ spec:
storage: true
subresources:
scale:
labelSelectorPath: .status.selector
specReplicasPath: .spec.replicas
statusReplicasPath: .status.replicas
status: {}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
}

Expand Down

0 comments on commit c35359e

Please sign in to comment.