Skip to content

Commit

Permalink
Add Conditions and ClusterDomain fields into ScyllaOperatorConfig
Browse files Browse the repository at this point in the history
Cluster domain can be used as a Kubernetes cluster indentifier.
Conditions may carry information regarding reconcilation of ClusterDomain automation.
  • Loading branch information
zimnx committed Nov 6, 2024
1 parent 0963a6e commit 897a379
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/api/scylla/v1alpha1/types_operatorconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type ScyllaOperatorConfigSpec struct {
// Setting this field renders your cluster unsupported. Use at your own risk.
// +optional
UnsupportedPrometheusVersionOverride *string `json:"unsupportedPrometheusVersionOverride,omitempty"`

// clusterDomainOverride allows to adjust Kubernetes cluster domain used by the operator as a cluster identifier.
// +optional
ClusterDomainOverride *string `json:"clusterDomainOverride,omitempty"`
}

type ScyllaOperatorConfigStatus struct {
Expand All @@ -33,6 +37,9 @@ type ScyllaOperatorConfigStatus struct {
// +optional
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`

// conditions hold conditions describing ScyllaOperatorConfig state.
Conditions []metav1.Condition `json:"conditions,omitempty"`

// scyllaDBUtilsImage is the ScyllaDB image used for running ScyllaDB utilities.
// +optional
ScyllaDBUtilsImage *string `json:"scyllaDBUtilsImage"`
Expand All @@ -48,6 +55,9 @@ type ScyllaOperatorConfigStatus struct {
// prometheusVersion is the Prometheus version used by the operator to create a Prometheus instance.
// +optional
PrometheusVersion *string `json:"prometheusVersion"`

// clusterDomain is the Kubernetes cluster domain used by the operator as a cluster identifier.
ClusterDomain *string `json:"clusterDomain,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
14 changes: 13 additions & 1 deletion pkg/controller/scyllaoperatorconfig/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/scylla/v1alpha1"
"github.com/scylladb/scylla-operator/pkg/controllerhelpers"
"github.com/scylladb/scylla-operator/pkg/naming"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -44,5 +45,16 @@ func (opc *Controller) sync(ctx context.Context) error {

status := opc.calculateStatus(soc)

return opc.updateStatus(ctx, soc, status)
// Aggregate conditions.
err := controllerhelpers.SetAggregatedWorkloadConditions(&status.Conditions, soc.Generation)
if err != nil {
return fmt.Errorf("can't aggregate workload conditions: %w", err)
}

err = opc.updateStatus(ctx, soc, status)
if err != nil {
return fmt.Errorf("can't update status of ScyllaOperatorConfig %q: %w", naming.SingletonName, err)
}

return nil
}

0 comments on commit 897a379

Please sign in to comment.