Skip to content

Commit

Permalink
Merge pull request #545 from openshift-cherrypick-robot/cherry-pick-5…
Browse files Browse the repository at this point in the history
…42-to-18.0-fr1

[18.0-fr1] Ensure nodeSelector logic is consistent for all operators
  • Loading branch information
openshift-merge-bot[bot] authored Nov 22, 2024
2 parents 013bf1f + 34245ef commit 2ef48ec
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/bases/telemetry.openstack.org_autoscalings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
notifierImage:
type: string
override:
Expand Down
6 changes: 6 additions & 0 deletions api/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
notificationImage:
type: string
passwordSelector:
Expand Down
18 changes: 18 additions & 0 deletions api/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes
running this service
type: object
notifierImage:
type: string
override:
Expand Down Expand Up @@ -474,6 +480,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
notificationImage:
type: string
passwordSelector:
Expand Down Expand Up @@ -1829,6 +1841,12 @@ spec:
type: string
type: object
type: object
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
type: object
status:
description: TelemetryStatus defines the observed state of Telemetry
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/autoscaling_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ type AodhCore struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// TLS - Parameters related to the TLS
TLS tls.API `json:"tls,omitempty"`

// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this service
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
}

// APIOverrideSpec to override the generated manifest of several child resources.
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/ceilometer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ type CeilometerSpecCore struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// KSMTLS - Parameters related to the TLS for kube-state-metrics
KSMTLS tls.SimpleService `json:"ksmTls,omitempty"`

// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this service
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
}

// CeilometerStatus defines the observed state of Ceilometer
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/telemetry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ type TelemetrySpecBase struct {
// +kubebuilder:validation:Optional
// Logging - Parameters related to the logging
Logging LoggingSection `json:"logging,omitempty"`

// +kubebuilder:validation:Optional
// NodeSelector to target subset of worker nodes running this service
NodeSelector *map[string]string `json:"nodeSelector,omitempty"`
}

// CeilometerSection defines the desired state of the ceilometer service
Expand Down
33 changes: 33 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions config/crd/bases/telemetry.openstack.org_autoscalings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
notifierImage:
type: string
override:
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
notificationImage:
type: string
passwordSelector:
Expand Down
18 changes: 18 additions & 0 deletions config/crd/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes
running this service
type: object
notifierImage:
type: string
override:
Expand Down Expand Up @@ -474,6 +480,12 @@ spec:
items:
type: string
type: array
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
notificationImage:
type: string
passwordSelector:
Expand Down Expand Up @@ -1829,6 +1841,12 @@ spec:
type: string
type: object
type: object
nodeSelector:
additionalProperties:
type: string
description: NodeSelector to target subset of worker nodes running
this service
type: object
type: object
status:
description: TelemetryStatus defines the observed state of Telemetry
Expand Down
8 changes: 8 additions & 0 deletions controllers/telemetry_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ func (r TelemetryReconciler) reconcileCeilometer(ctx context.Context, instance *
return ctrl.Result{}, nil
}

if instance.Spec.Ceilometer.NodeSelector == nil {
instance.Spec.Ceilometer.NodeSelector = instance.Spec.NodeSelector
}

helper.GetLogger().Info("Reconciling Ceilometer", ceilometerNamespaceLabel, instance.Namespace, ceilometerNameLabel, ceilometer.ServiceName)
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), ceilometerInstance, func() error {
instance.Spec.Ceilometer.CeilometerSpec.DeepCopyInto(&ceilometerInstance.Spec)
Expand Down Expand Up @@ -328,6 +332,10 @@ func (r TelemetryReconciler) reconcileAutoscaling(ctx context.Context, instance
return ctrl.Result{}, nil
}

if instance.Spec.Autoscaling.Aodh.NodeSelector == nil {
instance.Spec.Autoscaling.Aodh.NodeSelector = instance.Spec.NodeSelector
}

helper.GetLogger().Info("Reconciling Autoscaling", autoscalingNamespaceLabel, instance.Namespace, autoscalingNameLabel, autoscalingName)
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), autoscalingInstance, func() error {
instance.Spec.Autoscaling.AutoscalingSpec.DeepCopyInto(&autoscalingInstance.Spec)
Expand Down
4 changes: 4 additions & 0 deletions pkg/autoscaling/aodh_statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ func AodhStatefulSet(
},
}

if instance.Spec.Aodh.NodeSelector != nil {
pod.Spec.NodeSelector = *instance.Spec.Aodh.NodeSelector
}

statefulset := &appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: ServiceName,
Expand Down
4 changes: 4 additions & 0 deletions pkg/autoscaling/dbsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,9 @@ func DbSyncJob(instance *autoscalingv1beta1.Autoscaling, labels map[string]strin
},
}

if instance.Spec.Aodh.NodeSelector != nil {
job.Spec.Template.Spec.NodeSelector = *instance.Spec.Aodh.NodeSelector
}

return job
}
4 changes: 4 additions & 0 deletions pkg/availability/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,9 @@ func KSMStatefulSet(
},
}

if instance.Spec.NodeSelector != nil {
ss.Spec.Template.Spec.NodeSelector = *instance.Spec.NodeSelector
}

return ss, nil
}
4 changes: 4 additions & 0 deletions pkg/ceilometer/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ func StatefulSet(
},
}

if instance.Spec.NodeSelector != nil {
pod.Spec.NodeSelector = *instance.Spec.NodeSelector
}

statefulset := &appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: ServiceName,
Expand Down

0 comments on commit 2ef48ec

Please sign in to comment.