diff --git a/PROJECT b/PROJECT index 028a31a537..6c4d9b2f06 100644 --- a/PROJECT +++ b/PROJECT @@ -3,5 +3,5 @@ repo: github.com/scylladb/scylla-operator resources: - group: scylla kind: ScyllaCluster - version: v1alpha1 + version: v1 version: "2" diff --git a/config/manager/cluster/cluster.yaml b/config/manager/cluster/cluster.yaml index 3ceb21d932..faba965c3b 100644 --- a/config/manager/cluster/cluster.yaml +++ b/config/manager/cluster/cluster.yaml @@ -63,7 +63,7 @@ subjects: --- # Scylla Manager Cluster -apiVersion: scylla.scylladb.com/v1alpha1 +apiVersion: scylla.scylladb.com/v1 kind: ScyllaCluster metadata: name: cluster diff --git a/config/manager/default/kustomization.yaml b/config/manager/default/kustomization.yaml index d26443b0e7..4d95273969 100644 --- a/config/manager/default/kustomization.yaml +++ b/config/manager/default/kustomization.yaml @@ -16,7 +16,7 @@ vars: objref: group: scylla.scylladb.com kind: ScyllaCluster - version: v1alpha1 + version: v1 name: cluster fieldref: fieldpath: metadata.name @@ -24,7 +24,7 @@ vars: objref: kind: ScyllaCluster group: scylla.scylladb.com - version: v1alpha1 + version: v1 name: cluster fieldref: fieldpath: spec.datacenter.name @@ -32,7 +32,7 @@ vars: objref: kind: ScyllaCluster group: scylla.scylladb.com - version: v1alpha1 + version: v1 name: cluster fieldref: fieldpath: spec.datacenter.racks[0].name @@ -40,7 +40,7 @@ vars: objref: kind: ScyllaCluster group: scylla.scylladb.com - version: v1alpha1 + version: v1 name: cluster fieldref: fieldpath: metadata.namespace \ No newline at end of file diff --git a/config/operator/crd/bases/scylla.scylladb.com_scyllaclusters.yaml b/config/operator/crd/bases/scylla.scylladb.com_scyllaclusters.yaml index 03aa83c2cb..cc26bfe377 100644 --- a/config/operator/crd/bases/scylla.scylladb.com_scyllaclusters.yaml +++ b/config/operator/crd/bases/scylla.scylladb.com_scyllaclusters.yaml @@ -1705,9 +1705,9 @@ spec: type: object type: object type: object - version: v1alpha1 + version: v1 versions: - - name: v1alpha1 + - name: v1 served: true storage: true status: diff --git a/config/operator/webhook/manifests.yaml b/config/operator/webhook/manifests.yaml index 9d7816de6b..caa9257e0d 100644 --- a/config/operator/webhook/manifests.yaml +++ b/config/operator/webhook/manifests.yaml @@ -11,14 +11,14 @@ webhooks: service: name: webhook-service namespace: system - path: /mutate-scylla-scylladb-com-v1alpha1-scyllacluster + path: /mutate-scylla-scylladb-com-v1-scyllacluster failurePolicy: Fail name: webhook.scylla.scylladb.com rules: - apiGroups: - scylla.scylladb.com apiVersions: - - v1alpha1 + - v1 operations: - CREATE - UPDATE @@ -37,14 +37,14 @@ webhooks: service: name: webhook-service namespace: system - path: /validate-scylla-scylladb-com-v1alpha1-scyllacluster + path: /validate-scylla-scylladb-com-v1-scyllacluster failurePolicy: Fail name: webhook.scylla.scylladb.com rules: - apiGroups: - scylla.scylladb.com apiVersions: - - v1alpha1 + - v1 operations: - CREATE - UPDATE diff --git a/docs/source/scylla_cluster_crd.md b/docs/source/scylla_cluster_crd.md index c463b5f944..178314b2de 100644 --- a/docs/source/scylla_cluster_crd.md +++ b/docs/source/scylla_cluster_crd.md @@ -8,7 +8,7 @@ This page will explain all the available configuration options on the Scylla CRD ## Sample ```yaml -apiVersion: scylla.scylladb.com/v1alpha1 +apiVersion: scylla.scylladb.com/v1 kind: ScyllaCluster metadata: name: simple-cluster diff --git a/examples/common/manager.yaml b/examples/common/manager.yaml index d441229d97..88e18c0ccc 100644 --- a/examples/common/manager.yaml +++ b/examples/common/manager.yaml @@ -248,7 +248,7 @@ spec: name: scylla-manager-manager-config-2tfggm9842 name: scylla-manager-config-volume --- -apiVersion: scylla.scylladb.com/v1alpha1 +apiVersion: scylla.scylladb.com/v1 kind: ScyllaCluster metadata: name: scylla-manager-cluster diff --git a/examples/common/operator.yaml b/examples/common/operator.yaml index d895fdc1a2..98325e66c1 100644 --- a/examples/common/operator.yaml +++ b/examples/common/operator.yaml @@ -1720,9 +1720,9 @@ spec: type: object type: object type: object - version: v1alpha1 + version: v1 versions: - - name: v1alpha1 + - name: v1 served: true storage: true status: @@ -1745,14 +1745,14 @@ webhooks: service: name: scylla-operator-webhook-service namespace: scylla-operator-system - path: /mutate-scylla-scylladb-com-v1alpha1-scyllacluster + path: /mutate-scylla-scylladb-com-v1-scyllacluster failurePolicy: Fail name: webhook.scylla.scylladb.com rules: - apiGroups: - scylla.scylladb.com apiVersions: - - v1alpha1 + - v1 operations: - CREATE - UPDATE @@ -1985,14 +1985,14 @@ webhooks: service: name: scylla-operator-webhook-service namespace: scylla-operator-system - path: /validate-scylla-scylladb-com-v1alpha1-scyllacluster + path: /validate-scylla-scylladb-com-v1-scyllacluster failurePolicy: Fail name: webhook.scylla.scylladb.com rules: - apiGroups: - scylla.scylladb.com apiVersions: - - v1alpha1 + - v1 operations: - CREATE - UPDATE diff --git a/examples/eks/cluster.yaml b/examples/eks/cluster.yaml index bb3f061ccf..6d42bfb0fc 100644 --- a/examples/eks/cluster.yaml +++ b/examples/eks/cluster.yaml @@ -73,7 +73,7 @@ subjects: --- # Scylla Cluster -apiVersion: scylla.scylladb.com/v1alpha1 +apiVersion: scylla.scylladb.com/v1 kind: ScyllaCluster metadata: name: scylla-cluster diff --git a/examples/generic/cluster.yaml b/examples/generic/cluster.yaml index fd9a1a2483..aeb5ae39c1 100644 --- a/examples/generic/cluster.yaml +++ b/examples/generic/cluster.yaml @@ -73,7 +73,7 @@ subjects: --- # Simple Scylla Cluster -apiVersion: scylla.scylladb.com/v1alpha1 +apiVersion: scylla.scylladb.com/v1 kind: ScyllaCluster metadata: labels: diff --git a/examples/gke/cluster.yaml b/examples/gke/cluster.yaml index e808cbc5d4..c541447d04 100644 --- a/examples/gke/cluster.yaml +++ b/examples/gke/cluster.yaml @@ -73,7 +73,7 @@ subjects: --- # Scylla Cluster -apiVersion: scylla.scylladb.com/v1alpha1 +apiVersion: scylla.scylladb.com/v1 kind: ScyllaCluster metadata: labels: diff --git a/pkg/api/v1alpha1/cluster_types.go b/pkg/api/v1/cluster_types.go similarity index 99% rename from pkg/api/v1alpha1/cluster_types.go rename to pkg/api/v1/cluster_types.go index 9bfea71056..e83f8b3a90 100644 --- a/pkg/api/v1alpha1/cluster_types.go +++ b/pkg/api/v1/cluster_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( "github.com/blang/semver" @@ -314,6 +314,7 @@ const ( // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:storageversion // Cluster is the Schema for the clusters API type ScyllaCluster struct { diff --git a/pkg/api/v1alpha1/cluster_validation.go b/pkg/api/v1/cluster_validation.go similarity index 99% rename from pkg/api/v1alpha1/cluster_validation.go rename to pkg/api/v1/cluster_validation.go index 8dd2908206..37f6ea968b 100644 --- a/pkg/api/v1alpha1/cluster_validation.go +++ b/pkg/api/v1/cluster_validation.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 import ( "reflect" diff --git a/pkg/api/v1alpha1/cluster_validation_test.go b/pkg/api/v1/cluster_validation_test.go similarity index 83% rename from pkg/api/v1alpha1/cluster_validation_test.go rename to pkg/api/v1/cluster_validation_test.go index 5a5c4c576d..00cb983521 100644 --- a/pkg/api/v1alpha1/cluster_validation_test.go +++ b/pkg/api/v1/cluster_validation_test.go @@ -1,9 +1,9 @@ -package v1alpha1_test +package v1_test import ( "testing" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/test/unit" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" @@ -24,25 +24,25 @@ func TestCheckValues(t *testing.T) { sameName.Spec.Datacenter.Racks = append(sameName.Spec.Datacenter.Racks, sameName.Spec.Datacenter.Racks[0]) invalidIntensity := validCluster.DeepCopy() - invalidIntensity.Spec.Repairs = append(invalidIntensity.Spec.Repairs, v1alpha1.RepairTaskSpec{ + invalidIntensity.Spec.Repairs = append(invalidIntensity.Spec.Repairs, v1.RepairTaskSpec{ Intensity: pointer.StringPtr("100Mib"), }) nonUniqueManagerTaskNames := validCluster.DeepCopy() - nonUniqueManagerTaskNames.Spec.Backups = append(nonUniqueManagerTaskNames.Spec.Backups, v1alpha1.BackupTaskSpec{ - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + nonUniqueManagerTaskNames.Spec.Backups = append(nonUniqueManagerTaskNames.Spec.Backups, v1.BackupTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "task-name", }, }) - nonUniqueManagerTaskNames.Spec.Repairs = append(nonUniqueManagerTaskNames.Spec.Repairs, v1alpha1.RepairTaskSpec{ - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + nonUniqueManagerTaskNames.Spec.Repairs = append(nonUniqueManagerTaskNames.Spec.Repairs, v1.RepairTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "task-name", }, }) tests := []struct { name string - obj *v1alpha1.ScyllaCluster + obj *v1.ScyllaCluster allowed bool }{ { @@ -69,7 +69,7 @@ func TestCheckValues(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - err := v1alpha1.CheckValues(test.obj) + err := v1.CheckValues(test.obj) if test.allowed { require.NoError(t, err, "Wrong value returned from checkValues function. Message: '%s'", err) } else { @@ -82,8 +82,8 @@ func TestCheckValues(t *testing.T) { func TestCheckTransitions(t *testing.T) { tests := []struct { name string - old *v1alpha1.ScyllaCluster - new *v1alpha1.ScyllaCluster + old *v1.ScyllaCluster + new *v1.ScyllaCluster allowed bool }{ { @@ -151,7 +151,7 @@ func TestCheckTransitions(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { - err := v1alpha1.CheckTransitions(test.old, test.new) + err := v1.CheckTransitions(test.old, test.new) if test.allowed { require.NoError(t, err, "Wrong value returned from checkTransitions function. Message: '%s'", err) } else { @@ -161,24 +161,24 @@ func TestCheckTransitions(t *testing.T) { } } -func placementChanged(c *v1alpha1.ScyllaCluster) *v1alpha1.ScyllaCluster { - c.Spec.Datacenter.Racks[0].Placement = &v1alpha1.PlacementSpec{} +func placementChanged(c *v1.ScyllaCluster) *v1.ScyllaCluster { + c.Spec.Datacenter.Racks[0].Placement = &v1.PlacementSpec{} return c } -func resourceChanged(c *v1alpha1.ScyllaCluster) *v1alpha1.ScyllaCluster { +func resourceChanged(c *v1.ScyllaCluster) *v1.ScyllaCluster { c.Spec.Datacenter.Racks[0].Resources.Requests = map[corev1.ResourceName]resource.Quantity{ corev1.ResourceCPU: *resource.NewMilliQuantity(1000, resource.DecimalSI), } return c } -func rackDeleted(c *v1alpha1.ScyllaCluster) *v1alpha1.ScyllaCluster { +func rackDeleted(c *v1.ScyllaCluster) *v1.ScyllaCluster { c.Spec.Datacenter.Racks = nil return c } -func storageChanged(c *v1alpha1.ScyllaCluster) *v1alpha1.ScyllaCluster { +func storageChanged(c *v1.ScyllaCluster) *v1.ScyllaCluster { c.Spec.Datacenter.Racks[0].Storage.Capacity = "15Gi" return c } diff --git a/pkg/api/v1alpha1/cluster_webhook.go b/pkg/api/v1/cluster_webhook.go similarity index 92% rename from pkg/api/v1alpha1/cluster_webhook.go rename to pkg/api/v1/cluster_webhook.go index ba9640c788..b91aa3454b 100644 --- a/pkg/api/v1alpha1/cluster_webhook.go +++ b/pkg/api/v1/cluster_webhook.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1alpha1 +package v1 import ( "reflect" @@ -39,8 +39,8 @@ func (r *ScyllaCluster) SetupWebhookWithManager(mgr ctrl.Manager) error { Complete() } -// +kubebuilder:webhook:verbs=create;update,path=/mutate-scylla-scylladb-com-v1alpha1-scyllacluster,mutating=true,failurePolicy=fail,groups=scylla.scylladb.com,resources=scyllaclusters,versions=v1alpha1,name=webhook.scylla.scylladb.com -// +kubebuilder:webhook:verbs=create;update,path=/validate-scylla-scylladb-com-v1alpha1-scyllacluster,mutating=false,failurePolicy=fail,groups=scylla.scylladb.com,resources=scyllaclusters,versions=v1alpha1,name=webhook.scylla.scylladb.com +// +kubebuilder:webhook:verbs=create;update,path=/mutate-scylla-scylladb-com-v1-scyllacluster,mutating=true,failurePolicy=fail,groups=scylla.scylladb.com,resources=scyllaclusters,versions=v1,name=webhook.scylla.scylladb.com +// +kubebuilder:webhook:verbs=create;update,path=/validate-scylla-scylladb-com-v1-scyllacluster,mutating=false,failurePolicy=fail,groups=scylla.scylladb.com,resources=scyllaclusters,versions=v1,name=webhook.scylla.scylladb.com var _ webhook.Defaulter = &ScyllaCluster{} var _ webhook.Validator = &ScyllaCluster{} diff --git a/pkg/api/v1alpha1/export_test.go b/pkg/api/v1/export_test.go similarity index 91% rename from pkg/api/v1alpha1/export_test.go rename to pkg/api/v1/export_test.go index 302a9193bc..37edc49514 100644 --- a/pkg/api/v1alpha1/export_test.go +++ b/pkg/api/v1/export_test.go @@ -1,6 +1,6 @@ // Copyright (C) 2017 ScyllaDB -package v1alpha1 +package v1 func CheckValues(c *ScyllaCluster) error { return checkValues(c) diff --git a/pkg/api/v1alpha1/groupversion_info.go b/pkg/api/v1/groupversion_info.go similarity index 89% rename from pkg/api/v1alpha1/groupversion_info.go rename to pkg/api/v1/groupversion_info.go index 69eaf1f986..822d048e0d 100644 --- a/pkg/api/v1alpha1/groupversion_info.go +++ b/pkg/api/v1/groupversion_info.go @@ -14,10 +14,10 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 contains API Schema definitions for the scylla v1alpha1 API group +// Package v1 contains API Schema definitions for the scylla v1 API group // +kubebuilder:object:generate=true // +groupName=scylla.scylladb.com -package v1alpha1 +package v1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "scylla.scylladb.com", Version: "v1alpha1"} + GroupVersion = schema.GroupVersion{Group: "scylla.scylladb.com", Version: "v1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/pkg/api/v1alpha1/helpers.go b/pkg/api/v1/helpers.go similarity index 97% rename from pkg/api/v1alpha1/helpers.go rename to pkg/api/v1/helpers.go index d3c7f156b1..7885aaba54 100644 --- a/pkg/api/v1alpha1/helpers.go +++ b/pkg/api/v1/helpers.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 import corev1 "k8s.io/api/core/v1" diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1/zz_generated.deepcopy.go similarity index 99% rename from pkg/api/v1alpha1/zz_generated.deepcopy.go rename to pkg/api/v1/zz_generated.deepcopy.go index 4cb34be3f4..14781b036b 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1/zz_generated.deepcopy.go @@ -18,11 +18,11 @@ limitations under the License. // Code generated by controller-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -242,7 +242,7 @@ func (in *GenericUpgradeSpec) DeepCopyInto(out *GenericUpgradeSpec) { *out = *in if in.PollInterval != nil { in, out := &in.PollInterval, &out.PollInterval - *out = new(v1.Duration) + *out = new(metav1.Duration) **out = **in } } diff --git a/pkg/cmd/main.go b/pkg/cmd/main.go index 50b101c02b..40195485c6 100644 --- a/pkg/cmd/main.go +++ b/pkg/cmd/main.go @@ -4,7 +4,7 @@ import ( "context" "github.com/scylladb/go-log" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/spf13/cobra" "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -28,7 +28,7 @@ var ( func init() { _ = clientgoscheme.AddToScheme(scheme) - _ = scyllav1alpha1.AddToScheme(scheme) + _ = scyllav1.AddToScheme(scheme) // +kubebuilder:scaffold:scheme } diff --git a/pkg/cmd/operator.go b/pkg/cmd/operator.go index 71fb420602..bb83573f6b 100644 --- a/pkg/cmd/operator.go +++ b/pkg/cmd/operator.go @@ -4,7 +4,7 @@ import ( "context" "github.com/scylladb/go-log" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/cmd/options" "github.com/scylladb/scylla-operator/pkg/controllers/cluster" "github.com/spf13/cobra" @@ -55,7 +55,7 @@ func newOperatorCmd(ctx context.Context, logger log.Logger, level zap.AtomicLeve // Enable webhook if requested if opts.EnableAdmissionWebhook { - if err = (&v1alpha1.ScyllaCluster{}).SetupWebhookWithManager(mgr); err != nil { + if err = (&v1.ScyllaCluster{}).SetupWebhookWithManager(mgr); err != nil { logger.Fatal(ctx, "unable to add web hook to manager", "error", err) } } diff --git a/pkg/controllers/cluster/actions/create.go b/pkg/controllers/cluster/actions/create.go index 742b4a976e..b87cb47976 100644 --- a/pkg/controllers/cluster/actions/create.go +++ b/pkg/controllers/cluster/actions/create.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/resource" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" @@ -20,12 +20,12 @@ const RackCreateAction = "rack-create" var _ Action = &RackCreate{} type RackCreate struct { - Rack scyllav1alpha1.RackSpec - Cluster *scyllav1alpha1.ScyllaCluster + Rack scyllav1.RackSpec + Cluster *scyllav1.ScyllaCluster OperatorImage string } -func NewRackCreateAction(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster, image string) *RackCreate { +func NewRackCreateAction(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster, image string) *RackCreate { return &RackCreate{ Rack: r, Cluster: c, diff --git a/pkg/controllers/cluster/actions/replace.go b/pkg/controllers/cluster/actions/replace.go index 1f13d7ff6e..165049c78f 100644 --- a/pkg/controllers/cluster/actions/replace.go +++ b/pkg/controllers/cluster/actions/replace.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "github.com/scylladb/go-log" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" corev1 "k8s.io/api/core/v1" @@ -21,15 +21,15 @@ import ( const RackReplaceNodeAction = "rack-replace-node" type RackReplaceNode struct { - Rack scyllav1alpha1.RackSpec - Cluster *scyllav1alpha1.ScyllaCluster + Rack scyllav1.RackSpec + Cluster *scyllav1.ScyllaCluster Logger log.Logger } var _ Action = &RackReplaceNode{} // NewRackReplaceNodeAction returns action used for Scylla node replacement. -func NewRackReplaceNodeAction(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster, l log.Logger) *RackReplaceNode { +func NewRackReplaceNodeAction(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster, l log.Logger) *RackReplaceNode { return &RackReplaceNode{ Rack: r, Cluster: c, diff --git a/pkg/controllers/cluster/actions/scale_down.go b/pkg/controllers/cluster/actions/scale_down.go index 4ea1333a42..c1cf1e5579 100644 --- a/pkg/controllers/cluster/actions/scale_down.go +++ b/pkg/controllers/cluster/actions/scale_down.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" appsv1 "k8s.io/api/apps/v1" @@ -18,11 +18,11 @@ const RackScaleDownAction = "rack-scale-down" var _ Action = &RackScaleDown{} type RackScaleDown struct { - Rack scyllav1alpha1.RackSpec - Cluster *scyllav1alpha1.ScyllaCluster + Rack scyllav1.RackSpec + Cluster *scyllav1.ScyllaCluster } -func NewRackScaleDownAction(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) *RackScaleDown { +func NewRackScaleDownAction(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster) *RackScaleDown { return &RackScaleDown{ Rack: r, Cluster: c, diff --git a/pkg/controllers/cluster/actions/scale_up.go b/pkg/controllers/cluster/actions/scale_up.go index 700fbf073e..f768214a8a 100644 --- a/pkg/controllers/cluster/actions/scale_up.go +++ b/pkg/controllers/cluster/actions/scale_up.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" appsv1 "k8s.io/api/apps/v1" @@ -18,11 +18,11 @@ const RackScaleUpAction = "rack-scale-up" var _ Action = &RackScaleUp{} type RackScaleUp struct { - Rack scyllav1alpha1.RackSpec - Cluster *scyllav1alpha1.ScyllaCluster + Rack scyllav1.RackSpec + Cluster *scyllav1.ScyllaCluster } -func NewRackScaleUpAction(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) *RackScaleUp { +func NewRackScaleUpAction(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster) *RackScaleUp { return &RackScaleUp{ Rack: r, Cluster: c, diff --git a/pkg/controllers/cluster/actions/upgrade_version.go b/pkg/controllers/cluster/actions/upgrade_version.go index 1229fb2733..4c7cba598a 100644 --- a/pkg/controllers/cluster/actions/upgrade_version.go +++ b/pkg/controllers/cluster/actions/upgrade_version.go @@ -14,7 +14,7 @@ import ( "github.com/scylladb/go-log" "github.com/scylladb/go-set/strset" "github.com/scylladb/gocqlx/v2" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/resource" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" @@ -39,14 +39,14 @@ const ( ) type ClusterVersionUpgrade struct { - Cluster *scyllav1alpha1.ScyllaCluster + Cluster *scyllav1.ScyllaCluster ScyllaClient *scyllaclient.Client ClusterSession cqlSession ipMapping map[string]string pollInterval time.Duration - currentRack *scyllav1alpha1.RackSpec + currentRack *scyllav1.RackSpec currentNode *corev1.Pod cc client.Client @@ -55,7 +55,7 @@ type ClusterVersionUpgrade struct { logger log.Logger } -func NewClusterVersionUpgradeAction(c *scyllav1alpha1.ScyllaCluster, l log.Logger) *ClusterVersionUpgrade { +func NewClusterVersionUpgradeAction(c *scyllav1.ScyllaCluster, l log.Logger) *ClusterVersionUpgrade { return &ClusterVersionUpgrade{ Cluster: c, logger: l, @@ -141,7 +141,7 @@ func (a *ClusterVersionUpgrade) Execute(ctx context.Context, s *State) error { a.kubeClient = s.kubeclient a.recorder = s.recorder - a.pollInterval = scyllav1alpha1.DefaultGenericUpgradePollInterval + a.pollInterval = scyllav1.DefaultGenericUpgradePollInterval if a.Cluster.Spec.GenericUpgrade != nil { if a.Cluster.Spec.GenericUpgrade.PollInterval != nil { @@ -252,8 +252,8 @@ func (a *ClusterVersionUpgrade) beginUpgrade(ctx context.Context) (fsm.Event, er } now := timeutc.Now() - err := a.upgradeClusterStatus(ctx, func(status *scyllav1alpha1.ClusterStatus) { - status.Upgrade = &scyllav1alpha1.UpgradeStatus{ + err := a.upgradeClusterStatus(ctx, func(status *scyllav1.ClusterStatus) { + status.Upgrade = &scyllav1.UpgradeStatus{ State: string(BeginUpgrade), FromVersion: fromVersion, ToVersion: a.Cluster.Spec.Version, @@ -267,7 +267,7 @@ func (a *ClusterVersionUpgrade) beginUpgrade(ctx context.Context) (fsm.Event, er // Wait until patch is applied, other functions relies on Status.Upgrade being non-nil. err = wait.PollImmediate(a.pollInterval, actionTimeout, func() (done bool, err error) { - cluster := &scyllav1alpha1.ScyllaCluster{} + cluster := &scyllav1.ScyllaCluster{} if err := a.cc.Get(ctx, naming.NamespacedName(a.Cluster.Name, a.Cluster.Namespace), cluster); err != nil { return false, err } @@ -502,7 +502,7 @@ func (a *ClusterVersionUpgrade) updateRackSpec(ctx context.Context) (fsm.Event, return ActionSuccess, nil } -func (a *ClusterVersionUpgrade) nextRack(ctx context.Context) (*scyllav1alpha1.RackSpec, error) { +func (a *ClusterVersionUpgrade) nextRack(ctx context.Context) (*scyllav1.RackSpec, error) { for _, r := range a.Cluster.Spec.Datacenter.Racks { pods := &corev1.PodList{} if err := a.cc.List(ctx, pods, &client.ListOptions{ @@ -532,7 +532,7 @@ func (a *ClusterVersionUpgrade) findNextRack(ctx context.Context) (fsm.Event, er return ActionFailure, errors.Wrap(err, "find next rack") } - if err := a.upgradeClusterStatus(ctx, func(status *scyllav1alpha1.ClusterStatus) { + if err := a.upgradeClusterStatus(ctx, func(status *scyllav1.ClusterStatus) { if r == nil { status.Upgrade.CurrentRack = "" } else { @@ -554,9 +554,9 @@ func (a *ClusterVersionUpgrade) findNextRack(ctx context.Context) (fsm.Event, er return ActionSuccess, nil } -func (a *ClusterVersionUpgrade) getCurrentRack(ctx context.Context) (*scyllav1alpha1.RackSpec, error) { +func (a *ClusterVersionUpgrade) getCurrentRack(ctx context.Context) (*scyllav1.RackSpec, error) { if a.currentRack == nil { - cluster := &scyllav1alpha1.ScyllaCluster{} + cluster := &scyllav1.ScyllaCluster{} if err := a.cc.Get(ctx, naming.NamespacedName(a.Cluster.Name, a.Cluster.Namespace), cluster); err != nil { return nil, errors.Wrap(err, "refresh cluster") } @@ -574,7 +574,7 @@ func (a *ClusterVersionUpgrade) getCurrentRack(ctx context.Context) (*scyllav1al func (a *ClusterVersionUpgrade) getCurrentNode(ctx context.Context) (*corev1.Pod, error) { if a.currentNode == nil { - cluster := &scyllav1alpha1.ScyllaCluster{} + cluster := &scyllav1.ScyllaCluster{} if err := a.cc.Get(ctx, naming.NamespacedName(a.Cluster.Name, a.Cluster.Namespace), cluster); err != nil { return nil, errors.Wrap(err, "refresh cluster") } @@ -625,7 +625,7 @@ func (a *ClusterVersionUpgrade) findNextNode(ctx context.Context) (fsm.Event, er return ActionFailure, errors.Wrap(err, "find next node") } - if err := a.upgradeClusterStatus(ctx, func(status *scyllav1alpha1.ClusterStatus) { + if err := a.upgradeClusterStatus(ctx, func(status *scyllav1.ClusterStatus) { if n == nil { status.Upgrade.CurrentNode = "" } else { @@ -695,13 +695,13 @@ func (a *ClusterVersionUpgrade) nodeUpgradedConditionFunc(ctx context.Context) f } func (a *ClusterVersionUpgrade) validateUpgrade(ctx context.Context) (fsm.Event, error) { - failureStrategy := scyllav1alpha1.GenericUpgradeFailureStrategyRetry + failureStrategy := scyllav1.GenericUpgradeFailureStrategyRetry if a.Cluster.Spec.GenericUpgrade != nil { failureStrategy = a.Cluster.Spec.GenericUpgrade.FailureStrategy } switch failureStrategy { - case scyllav1alpha1.GenericUpgradeFailureStrategyRetry: + case scyllav1.GenericUpgradeFailureStrategyRetry: if err := wait.PollImmediateInfinite(a.pollInterval, a.nodeUpgradedConditionFunc(ctx)); err != nil { return ActionFailure, errors.Wrap(err, "validate node upgrade") } @@ -726,9 +726,9 @@ func (a *ClusterVersionUpgrade) clearSystemBackup(ctx context.Context) (fsm.Even return ActionSuccess, nil } -func (a *ClusterVersionUpgrade) upgradeClusterStatus(ctx context.Context, f func(cluster *scyllav1alpha1.ClusterStatus)) error { - cluster := &scyllav1alpha1.ScyllaCluster{} - patched := &scyllav1alpha1.ScyllaCluster{} +func (a *ClusterVersionUpgrade) upgradeClusterStatus(ctx context.Context, f func(cluster *scyllav1.ClusterStatus)) error { + cluster := &scyllav1.ScyllaCluster{} + patched := &scyllav1.ScyllaCluster{} resourceVersion := "" err := retry.RetryOnConflict(retry.DefaultRetry, func() error { @@ -771,7 +771,7 @@ func (a *ClusterVersionUpgrade) upgradeClusterStatus(ctx context.Context, f func func (a *ClusterVersionUpgrade) onStateTransition(ctx context.Context, currentState, nextState fsm.State, event fsm.Event) error { a.logger.Info(ctx, "Upgrade state transition", "event", event, "from", currentState, "to", nextState) - err := a.upgradeClusterStatus(ctx, func(status *scyllav1alpha1.ClusterStatus) { + err := a.upgradeClusterStatus(ctx, func(status *scyllav1.ClusterStatus) { status.Upgrade.State = string(nextState) }) if err != nil { @@ -783,7 +783,7 @@ func (a *ClusterVersionUpgrade) onStateTransition(ctx context.Context, currentSt func (a *ClusterVersionUpgrade) finishUpgrade(ctx context.Context) (fsm.Event, error) { err := retry.RetryOnConflict(retry.DefaultRetry, func() error { - cluster := &scyllav1alpha1.ScyllaCluster{} + cluster := &scyllav1.ScyllaCluster{} if err := a.cc.Get(ctx, naming.NamespacedName(a.Cluster.Name, a.Cluster.Namespace), cluster); err != nil { return err } @@ -804,7 +804,7 @@ func (a *ClusterVersionUpgrade) finishUpgrade(ctx context.Context) (fsm.Event, e return fsm.NoOp, nil } -func (a *ClusterVersionUpgrade) setRollingUpgradeStrategy(ctx context.Context, rack *scyllav1alpha1.RackSpec) error { +func (a *ClusterVersionUpgrade) setRollingUpgradeStrategy(ctx context.Context, rack *scyllav1.RackSpec) error { sts := &appsv1.StatefulSet{} err := a.cc.Get(ctx, naming.NamespacedName(naming.StatefulSetNameForRack(*rack, a.Cluster), a.Cluster.Namespace), sts) if err != nil { @@ -844,7 +844,7 @@ func (a *ClusterVersionUpgrade) restoreUpgradeStrategy(ctx context.Context) (fsm return ActionSuccess, nil } -func (a *ClusterVersionUpgrade) rackHosts(racks []scyllav1alpha1.RackSpec) []string { +func (a *ClusterVersionUpgrade) rackHosts(racks []scyllav1.RackSpec) []string { hosts := make([]string, 0, len(racks)) for _, r := range a.Cluster.Spec.Datacenter.Racks { for i := 0; i < int(r.Members); i++ { diff --git a/pkg/controllers/cluster/actions/upgrade_version_integration_test.go b/pkg/controllers/cluster/actions/upgrade_version_integration_test.go index 969413b496..64fc17def6 100644 --- a/pkg/controllers/cluster/actions/upgrade_version_integration_test.go +++ b/pkg/controllers/cluster/actions/upgrade_version_integration_test.go @@ -23,7 +23,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/test/integration" ) @@ -44,7 +44,7 @@ var _ = Describe("Cluster controller", func() { Context("Cluster upgrade", func() { var ( - scylla *scyllav1alpha1.ScyllaCluster + scylla *scyllav1.ScyllaCluster sstStub *integration.StatefulSetOperatorStub originalActionsNewSessionFunc func(hosts []string) (actions.CQLSession, error) @@ -53,7 +53,7 @@ var _ = Describe("Cluster controller", func() { BeforeEach(func() { scylla = testEnv.SingleRackCluster(ns) - scylla.Spec.GenericUpgrade = &scyllav1alpha1.GenericUpgradeSpec{ + scylla.Spec.GenericUpgrade = &scyllav1.GenericUpgradeSpec{ PollInterval: &metav1.Duration{Duration: 200 * time.Millisecond}, } @@ -138,7 +138,7 @@ var _ = Describe("Cluster controller", func() { Expect(testEnv.Update(ctx, scylla)).To(Succeed()) By("Then: Cluster status should contain upgrade status") - Eventually(func() *scyllav1alpha1.UpgradeStatus { + Eventually(func() *scyllav1.UpgradeStatus { Expect(testEnv.Refresh(ctx, scylla)).To(Succeed()) return scylla.Status.Upgrade }, shortWait).ShouldNot(BeNil()) @@ -247,7 +247,7 @@ var _ = Describe("Cluster controller", func() { Eventually(scyllaFake.KeyspaceSnapshots, shortWait).Should(BeEmpty()) By("Then: upgrade status is cleared out") - Eventually(func() *scyllav1alpha1.UpgradeStatus { + Eventually(func() *scyllav1.UpgradeStatus { Expect(testEnv.Refresh(ctx, scylla)).To(Succeed()) return scylla.Status.Upgrade }, shortWait).Should(BeNil()) diff --git a/pkg/controllers/cluster/cleanup.go b/pkg/controllers/cluster/cleanup.go index 4ba6f6fa4a..55cee14ff7 100644 --- a/pkg/controllers/cluster/cleanup.go +++ b/pkg/controllers/cluster/cleanup.go @@ -4,7 +4,7 @@ import ( "context" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" "github.com/scylladb/scylla-operator/pkg/util/nodeaffinity" @@ -15,7 +15,7 @@ import ( ) // cleanup deletes all resources remaining because of cluster scale downs -func (cc *ClusterReconciler) cleanup(ctx context.Context, c *scyllav1alpha1.ScyllaCluster) error { +func (cc *ClusterReconciler) cleanup(ctx context.Context, c *scyllav1.ScyllaCluster) error { svcList := &corev1.ServiceList{} sts := &appsv1.StatefulSet{} logger := cc.Logger.With("cluster", c.Namespace+"/"+c.Name, "resourceVersion", c.ResourceVersion) @@ -61,7 +61,7 @@ func (cc *ClusterReconciler) cleanup(ctx context.Context, c *scyllav1alpha1.Scyl // due to orphaned affinity. // Operator checks if any Pod PVC is orphaned, and if so, mark member service as // a replacement candidate. -func (cc *ClusterReconciler) orphanedCleanup(ctx context.Context, c *scyllav1alpha1.ScyllaCluster, svcs *corev1.ServiceList) error { +func (cc *ClusterReconciler) orphanedCleanup(ctx context.Context, c *scyllav1.ScyllaCluster, svcs *corev1.ServiceList) error { nodes := &corev1.NodeList{} if err := cc.List(ctx, nodes); err != nil { return errors.Wrap(err, "list nodes") @@ -112,7 +112,7 @@ func (cc *ClusterReconciler) orphanedCleanup(ctx context.Context, c *scyllav1alp return nil } -func (cc *ClusterReconciler) decommissionCleanup(ctx context.Context, c *scyllav1alpha1.ScyllaCluster, sts *appsv1.StatefulSet, svcs *corev1.ServiceList) error { +func (cc *ClusterReconciler) decommissionCleanup(ctx context.Context, c *scyllav1.ScyllaCluster, sts *appsv1.StatefulSet, svcs *corev1.ServiceList) error { memberCount := *sts.Spec.Replicas memberServiceCount := int32(len(svcs.Items)) // If there are more services than members, some services need to be cleaned up @@ -141,7 +141,7 @@ func (cc *ClusterReconciler) decommissionCleanup(ctx context.Context, c *scyllav // Currently those are : // - A PVC // - A ClusterIP Service -func (cc *ClusterReconciler) cleanupMemberResources(ctx context.Context, memberService *corev1.Service, c *scyllav1alpha1.ScyllaCluster) error { +func (cc *ClusterReconciler) cleanupMemberResources(ctx context.Context, memberService *corev1.Service, c *scyllav1.ScyllaCluster) error { memberName := memberService.Name logger := util.LoggerForCluster(c) logger.Info(ctx, "Cleaning up resources for member", "name", memberName) diff --git a/pkg/controllers/cluster/cluster_controller.go b/pkg/controllers/cluster/cluster_controller.go index c4a726c492..0618621870 100644 --- a/pkg/controllers/cluster/cluster_controller.go +++ b/pkg/controllers/cluster/cluster_controller.go @@ -41,7 +41,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" ) const concurrency = 1 @@ -103,7 +103,7 @@ func (cc *ClusterReconciler) Reconcile(request ctrl.Request) (ctrl.Result, error ctx := log.WithNewTraceID(context.Background()) cc.Logger.Debug(ctx, "Reconcile request", "request", request.String()) // Fetch the Cluster instance - c := &scyllav1alpha1.ScyllaCluster{} + c := &scyllav1.ScyllaCluster{} err := cc.UncachedClient.Get(ctx, request.NamespacedName, c) if err != nil { if apierrors.IsNotFound(err) { @@ -157,8 +157,8 @@ func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { ////////////////////////////////// clusterSpecChangedPredicate := predicate.Funcs{ UpdateFunc: func(e event.UpdateEvent) bool { - oldCluster := e.ObjectOld.(*scyllav1alpha1.ScyllaCluster) - newCluster := e.ObjectNew.(*scyllav1alpha1.ScyllaCluster) + oldCluster := e.ObjectOld.(*scyllav1.ScyllaCluster) + newCluster := e.ObjectNew.(*scyllav1.ScyllaCluster) if reflect.DeepEqual(oldCluster, newCluster) { return false } @@ -167,7 +167,7 @@ func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { } err = c.Watch( - &source.Kind{Type: &scyllav1alpha1.ScyllaCluster{}}, + &source.Kind{Type: &scyllav1.ScyllaCluster{}}, &handler.EnqueueRequestForObject{}, predicate.ResourceVersionChangedPredicate{}, clusterSpecChangedPredicate, @@ -184,7 +184,7 @@ func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { &source.Kind{Type: &appsv1.StatefulSet{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &scyllav1alpha1.ScyllaCluster{}, + OwnerType: &scyllav1.ScyllaCluster{}, }, predicate.ResourceVersionChangedPredicate{}, ) @@ -200,7 +200,7 @@ func (r *ClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { &source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &scyllav1alpha1.ScyllaCluster{}, + OwnerType: &scyllav1.ScyllaCluster{}, }, predicate.ResourceVersionChangedPredicate{}, ) diff --git a/pkg/controllers/cluster/controller_integration_test.go b/pkg/controllers/cluster/controller_integration_test.go index 8682321e9c..ad44034e67 100644 --- a/pkg/controllers/cluster/controller_integration_test.go +++ b/pkg/controllers/cluster/controller_integration_test.go @@ -9,7 +9,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/naming" "github.com/scylladb/scylla-operator/pkg/test/integration" corev1 "k8s.io/api/core/v1" @@ -104,7 +104,7 @@ var _ = Describe("Cluster controller", func() { Context("Node replace", func() { var ( - scylla *scyllav1alpha1.ScyllaCluster + scylla *scyllav1.ScyllaCluster sstStub *integration.StatefulSetOperatorStub ) @@ -222,7 +222,7 @@ var _ = Describe("Cluster controller", func() { }) }) -func rackMemberService(namespace string, rack scyllav1alpha1.RackSpec, cluster *scyllav1alpha1.ScyllaCluster) ([]corev1.Service, error) { +func rackMemberService(namespace string, rack scyllav1.RackSpec, cluster *scyllav1.ScyllaCluster) ([]corev1.Service, error) { services := &corev1.ServiceList{} Expect(wait.PollImmediate(retryInterval, timeout, func() (bool, error) { err := testEnv.List(ctx, services, &client.ListOptions{ @@ -238,7 +238,7 @@ func rackMemberService(namespace string, rack scyllav1alpha1.RackSpec, cluster * return services.Items, nil } -func nonSeedServices(namespace string, rack scyllav1alpha1.RackSpec, cluster *scyllav1alpha1.ScyllaCluster) ([]corev1.Service, error) { +func nonSeedServices(namespace string, rack scyllav1.RackSpec, cluster *scyllav1.ScyllaCluster) ([]corev1.Service, error) { services, err := rackMemberService(namespace, rack, cluster) if err != nil { return nil, err @@ -254,7 +254,7 @@ func nonSeedServices(namespace string, rack scyllav1alpha1.RackSpec, cluster *sc return nonSeedServices, nil } -func seedServices(namespace string, rack scyllav1alpha1.RackSpec, cluster *scyllav1alpha1.ScyllaCluster) ([]corev1.Service, error) { +func seedServices(namespace string, rack scyllav1.RackSpec, cluster *scyllav1.ScyllaCluster) ([]corev1.Service, error) { services, err := rackMemberService(namespace, rack, cluster) if err != nil { return nil, err @@ -270,23 +270,23 @@ func seedServices(namespace string, rack scyllav1alpha1.RackSpec, cluster *scyll return seedServices, nil } -func singleNodeCluster(ns *corev1.Namespace) *scyllav1alpha1.ScyllaCluster { - return &scyllav1alpha1.ScyllaCluster{ +func singleNodeCluster(ns *corev1.Namespace) *scyllav1.ScyllaCluster { + return &scyllav1.ScyllaCluster{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: ns.Name, }, - Spec: scyllav1alpha1.ClusterSpec{ + Spec: scyllav1.ClusterSpec{ Version: "4.2.0", AgentVersion: pointer.StringPtr("2.2.0"), DeveloperMode: true, - Datacenter: scyllav1alpha1.DatacenterSpec{ + Datacenter: scyllav1.DatacenterSpec{ Name: "dc1", - Racks: []scyllav1alpha1.RackSpec{ + Racks: []scyllav1.RackSpec{ { Name: "rack1", Members: 1, - Storage: scyllav1alpha1.StorageSpec{ + Storage: scyllav1.StorageSpec{ Capacity: "10M", }, Resources: corev1.ResourceRequirements{ @@ -306,9 +306,9 @@ func singleNodeCluster(ns *corev1.Namespace) *scyllav1alpha1.ScyllaCluster { } } -func assertClusterStatusReflectsSpec(ctx context.Context, spec *scyllav1alpha1.ScyllaCluster) error { +func assertClusterStatusReflectsSpec(ctx context.Context, spec *scyllav1.ScyllaCluster) error { return wait.Poll(retryInterval, timeout, func() (bool, error) { - cluster := &scyllav1alpha1.ScyllaCluster{} + cluster := &scyllav1.ScyllaCluster{} if err := testEnv.Get(ctx, naming.NamespacedName(spec.Name, spec.Namespace), cluster); err != nil { return false, err } diff --git a/pkg/controllers/cluster/resource/resource.go b/pkg/controllers/cluster/resource/resource.go index 146a239c99..1135a5882c 100644 --- a/pkg/controllers/cluster/resource/resource.go +++ b/pkg/controllers/cluster/resource/resource.go @@ -5,7 +5,7 @@ import ( "path" "strings" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" appsv1 "k8s.io/api/apps/v1" @@ -20,7 +20,7 @@ const ( officialScyllaManagerAgentRepo = "scylladb/scylla-manager-agent" ) -func HeadlessServiceForCluster(c *scyllav1alpha1.ScyllaCluster) *corev1.Service { +func HeadlessServiceForCluster(c *scyllav1.ScyllaCluster) *corev1.Service { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: naming.HeadlessServiceNameForCluster(c), @@ -42,7 +42,7 @@ func HeadlessServiceForCluster(c *scyllav1alpha1.ScyllaCluster) *corev1.Service } } -func MemberServiceForPod(pod *corev1.Pod, cluster *scyllav1alpha1.ScyllaCluster) *corev1.Service { +func MemberServiceForPod(pod *corev1.Pod, cluster *scyllav1.ScyllaCluster) *corev1.Service { labels := naming.ClusterLabels(cluster) labels[naming.DatacenterNameLabel] = pod.Labels[naming.DatacenterNameLabel] labels[naming.RackNameLabel] = pod.Labels[naming.RackNameLabel] @@ -70,7 +70,7 @@ func MemberServiceForPod(pod *corev1.Pod, cluster *scyllav1alpha1.ScyllaCluster) } } -func memberServicePorts(cluster *scyllav1alpha1.ScyllaCluster) []corev1.ServicePort { +func memberServicePorts(cluster *scyllav1.ScyllaCluster) []corev1.ServicePort { ports := []corev1.ServicePort{ { Name: "inter-node-communication", @@ -109,11 +109,11 @@ func memberServicePorts(cluster *scyllav1alpha1.ScyllaCluster) []corev1.ServiceP return ports } -func StatefulSetForRack(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster, sidecarImage string) *appsv1.StatefulSet { +func StatefulSetForRack(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster, sidecarImage string) *appsv1.StatefulSet { rackLabels := naming.RackLabels(r, c) placement := r.Placement if placement == nil { - placement = &scyllav1alpha1.PlacementSpec{} + placement = &scyllav1.PlacementSpec{} } opt := true sts := &appsv1.StatefulSet{ @@ -365,7 +365,7 @@ func StatefulSetForRack(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaClust return sts } -func containerPorts(c *scyllav1alpha1.ScyllaCluster) []corev1.ContainerPort { +func containerPorts(c *scyllav1.ScyllaCluster) []corev1.ContainerPort { ports := []corev1.ContainerPort{ { Name: "intra-node", @@ -436,7 +436,7 @@ func sysctlInitContainer(sysctls []string) *corev1.Container { } } -func agentContainer(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) corev1.Container { +func agentContainer(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster) corev1.Container { cnt := corev1.Container{ Name: "scylla-manager-agent", Image: agentImageForCluster(c), @@ -474,7 +474,7 @@ func agentContainer(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) return cnt } -func ImageForCluster(c *scyllav1alpha1.ScyllaCluster) string { +func ImageForCluster(c *scyllav1.ScyllaCluster) string { repo := officialScyllaRepo if c.Spec.Repository != nil { repo = *c.Spec.Repository @@ -482,7 +482,7 @@ func ImageForCluster(c *scyllav1alpha1.ScyllaCluster) string { return fmt.Sprintf("%s:%s", repo, c.Spec.Version) } -func agentImageForCluster(c *scyllav1alpha1.ScyllaCluster) string { +func agentImageForCluster(c *scyllav1.ScyllaCluster) string { repo := officialScyllaManagerAgentRepo if c.Spec.AgentRepository != nil { repo = *c.Spec.AgentRepository diff --git a/pkg/controllers/cluster/service.go b/pkg/controllers/cluster/service.go index 7c52f90b47..346568afa3 100644 --- a/pkg/controllers/cluster/service.go +++ b/pkg/controllers/cluster/service.go @@ -4,7 +4,7 @@ import ( "context" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/resource" "github.com/scylladb/scylla-operator/pkg/naming" corev1 "k8s.io/api/core/v1" @@ -15,7 +15,7 @@ import ( // syncClusterHeadlessService checks if a Headless Service exists // for the given Cluster, in order for the StatefulSets to utilize it. // If it doesn't exists, then create it. -func (cc *ClusterReconciler) syncClusterHeadlessService(ctx context.Context, c *scyllav1alpha1.ScyllaCluster) error { +func (cc *ClusterReconciler) syncClusterHeadlessService(ctx context.Context, c *scyllav1.ScyllaCluster) error { clusterHeadlessService := resource.HeadlessServiceForCluster(c) _, err := controllerutil.CreateOrUpdate(ctx, cc.Client, clusterHeadlessService, serviceMutateFn(ctx, clusterHeadlessService, cc.Client)) if err != nil { @@ -29,7 +29,7 @@ func (cc *ClusterReconciler) syncClusterHeadlessService(ctx context.Context, c * // which will serve as a static ip. // If it doesn't exist, it creates it. // It also assigns the first two members of each rack as seeds. -func (cc *ClusterReconciler) syncMemberServices(ctx context.Context, c *scyllav1alpha1.ScyllaCluster) error { +func (cc *ClusterReconciler) syncMemberServices(ctx context.Context, c *scyllav1.ScyllaCluster) error { podlist := &corev1.PodList{} // For every Pod of the cluster that exists, check that a diff --git a/pkg/controllers/cluster/status.go b/pkg/controllers/cluster/status.go index dc4fae2c19..42d84f4ee5 100644 --- a/pkg/controllers/cluster/status.go +++ b/pkg/controllers/cluster/status.go @@ -7,7 +7,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" appsv1 "k8s.io/api/apps/v1" @@ -17,9 +17,9 @@ import ( // UpdateStatus updates the status of the given Scylla Cluster. // It doesn't post the result to the API Server yet. // That will be done at the end of the sync loop. -func (cc *ClusterReconciler) updateStatus(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster) error { +func (cc *ClusterReconciler) updateStatus(ctx context.Context, cluster *scyllav1.ScyllaCluster) error { if cluster.Status.Racks == nil { - cluster.Status.Racks = map[string]scyllav1alpha1.RackStatus{} + cluster.Status.Racks = map[string]scyllav1.RackStatus{} } sts := &appsv1.StatefulSet{} @@ -45,7 +45,7 @@ func (cc *ClusterReconciler) updateStatus(ctx context.Context, cluster *scyllav1 // Update each rack status for _, rack := range cluster.Spec.Datacenter.Racks { - rackStatus := scyllav1alpha1.RackStatus{ + rackStatus := scyllav1.RackStatus{ ReplaceAddressFirstBoot: make(map[string]string), } // ReplaceAddress may keep address of non-existing service. @@ -103,7 +103,7 @@ func (cc *ClusterReconciler) updateStatus(ctx context.Context, cluster *scyllav1 actualRackVersion := rackStatus.Version if desiredRackVersion != actualRackVersion { cc.Logger.Info(ctx, "Rack should be upgraded", "actual_version", actualRackVersion, "desired_version", desiredRackVersion, "rack", rack.Name) - scyllav1alpha1.SetRackCondition(&rackStatus, scyllav1alpha1.RackConditionTypeUpgrading) + scyllav1.SetRackCondition(&rackStatus, scyllav1.RackConditionTypeUpgrading) } // Update Scaling Down condition @@ -116,7 +116,7 @@ func (cc *ClusterReconciler) updateStatus(ctx context.Context, cluster *scyllav1 // Check if there is a decommission in progress if _, ok := svc.Labels[naming.DecommissionLabel]; ok { // Add MemberLeaving Condition to rack status - scyllav1alpha1.SetRackCondition(&rackStatus, scyllav1alpha1.RackConditionTypeMemberLeaving) + scyllav1.SetRackCondition(&rackStatus, scyllav1.RackConditionTypeMemberLeaving) // Sanity check. Only the last member should be decommissioning. index, err := naming.IndexFromName(svc.Name) if err != nil { @@ -134,7 +134,7 @@ func (cc *ClusterReconciler) updateStatus(ctx context.Context, cluster *scyllav1 rackStatus.ReplaceAddressFirstBoot[svc.Name] = svc.Spec.ClusterIP } cc.Logger.Info(ctx, "Rack member is being replaced", "rack", rack.Name, "member", svc.Name) - scyllav1alpha1.SetRackCondition(&rackStatus, scyllav1alpha1.RackConditionTypeMemberReplacing) + scyllav1.SetRackCondition(&rackStatus, scyllav1.RackConditionTypeMemberReplacing) } } diff --git a/pkg/controllers/cluster/sync.go b/pkg/controllers/cluster/sync.go index 10d4300e55..f4969c2e34 100644 --- a/pkg/controllers/cluster/sync.go +++ b/pkg/controllers/cluster/sync.go @@ -6,7 +6,7 @@ import ( "github.com/pkg/errors" "github.com/scylladb/go-log" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/actions" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" "github.com/scylladb/scylla-operator/pkg/naming" @@ -24,7 +24,7 @@ const ( // sync attempts to sync the given Scylla Cluster. // NOTE: the Cluster Object is a DeepCopy. Modify at will. -func (cc *ClusterReconciler) sync(c *scyllav1alpha1.ScyllaCluster) error { +func (cc *ClusterReconciler) sync(c *scyllav1.ScyllaCluster) error { ctx := log.WithNewTraceID(context.Background()) logger := cc.Logger.With("cluster", c.Namespace+"/"+c.Name, "resourceVersion", c.ResourceVersion) logger.Info(ctx, "Starting reconciliation...") @@ -80,7 +80,7 @@ func (cc *ClusterReconciler) sync(c *scyllav1alpha1.ScyllaCluster) error { return nil } -func (cc *ClusterReconciler) nextAction(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster) actions.Action { +func (cc *ClusterReconciler) nextAction(ctx context.Context, cluster *scyllav1.ScyllaCluster) actions.Action { logger := cc.Logger.With("cluster", cluster.Namespace+"/"+cluster.Name, "resourceVersion", cluster.ResourceVersion) // Check if any rack isn't created @@ -99,13 +99,13 @@ func (cc *ClusterReconciler) nextAction(ctx context.Context, cluster *scyllav1al // Check if there is a scale-down in progress for _, rack := range cluster.Spec.Datacenter.Racks { rackStatus := cluster.Status.Racks[rack.Name] - if scyllav1alpha1.IsRackConditionTrue(&rackStatus, scyllav1alpha1.RackConditionTypeMemberReplacing) { + if scyllav1.IsRackConditionTrue(&rackStatus, scyllav1.RackConditionTypeMemberReplacing) { // Perform node replace logger.Info(ctx, "Next Action: Node replace rack", "name", rack.Name) return actions.NewRackReplaceNodeAction(rack, cluster, logger.Named("replace")) } - if scyllav1alpha1.IsRackConditionTrue(&rackStatus, scyllav1alpha1.RackConditionTypeMemberLeaving) { + if scyllav1.IsRackConditionTrue(&rackStatus, scyllav1.RackConditionTypeMemberLeaving) { // Resume scale down logger.Info(ctx, "Next Action: Scale-Down rack", "name", rack.Name) return actions.NewRackScaleDownAction(rack, cluster) @@ -116,7 +116,7 @@ func (cc *ClusterReconciler) nextAction(ctx context.Context, cluster *scyllav1al for _, rack := range cluster.Spec.Datacenter.Racks { rackStatus := cluster.Status.Racks[rack.Name] if cluster.Status.Upgrade != nil || - scyllav1alpha1.IsRackConditionTrue(&rackStatus, scyllav1alpha1.RackConditionTypeUpgrading) { + scyllav1.IsRackConditionTrue(&rackStatus, scyllav1.RackConditionTypeUpgrading) { return actions.NewClusterVersionUpgradeAction(cluster, logger) } } diff --git a/pkg/controllers/cluster/sync_test.go b/pkg/controllers/cluster/sync_test.go index 2e090bd566..9820d5f57a 100644 --- a/pkg/controllers/cluster/sync_test.go +++ b/pkg/controllers/cluster/sync_test.go @@ -6,7 +6,7 @@ import ( "github.com/blang/semver" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/actions" "github.com/scylladb/scylla-operator/pkg/test/unit" ) @@ -19,27 +19,27 @@ func TestNextAction(t *testing.T) { clusterNewRackCreate := cluster.DeepCopy() clusterNewRackCreate.Spec.Datacenter.Racks = append( clusterNewRackCreate.Spec.Datacenter.Racks, - scyllav1alpha1.RackSpec{ + scyllav1.RackSpec{ Name: "new-rack", Members: 2, }, ) clusterExistingRackScaleUp := cluster.DeepCopy() - clusterExistingRackScaleUp.Status.Racks["test-rack"] = scyllav1alpha1.RackStatus{ + clusterExistingRackScaleUp.Status.Racks["test-rack"] = scyllav1.RackStatus{ Members: members - 1, ReadyMembers: members - 1, } clusterBeginRackScaleDown := cluster.DeepCopy() - clusterBeginRackScaleDown.Status.Racks["test-rack"] = scyllav1alpha1.RackStatus{ + clusterBeginRackScaleDown.Status.Racks["test-rack"] = scyllav1.RackStatus{ Members: members + 1, ReadyMembers: members + 1, } clusterResumeRackScaleDown := cluster.DeepCopy() testRackStatus := clusterResumeRackScaleDown.Status.Racks["test-rack"] - scyllav1alpha1.SetRackCondition(&testRackStatus, scyllav1alpha1.RackConditionTypeMemberLeaving) + scyllav1.SetRackCondition(&testRackStatus, scyllav1.RackConditionTypeMemberLeaving) clusterResumeRackScaleDown.Status.Racks["test-rack"] = testRackStatus clusterBeginVersionUpgrade := cluster.DeepCopy() @@ -49,12 +49,12 @@ func TestNextAction(t *testing.T) { clusterResumeVersionUpgrade := cluster.DeepCopy() testRackStatus = clusterResumeVersionUpgrade.Status.Racks["test-rack"] - scyllav1alpha1.SetRackCondition(&testRackStatus, scyllav1alpha1.RackConditionTypeUpgrading) + scyllav1.SetRackCondition(&testRackStatus, scyllav1.RackConditionTypeUpgrading) clusterResumeVersionUpgrade.Status.Racks["test-rack"] = testRackStatus tests := []struct { name string - cluster *scyllav1alpha1.ScyllaCluster + cluster *scyllav1.ScyllaCluster expectedAction string expectNoAction bool }{ diff --git a/pkg/controllers/cluster/util/util.go b/pkg/controllers/cluster/util/util.go index ad9fbf7245..9ebb787148 100644 --- a/pkg/controllers/cluster/util/util.go +++ b/pkg/controllers/cluster/util/util.go @@ -8,7 +8,7 @@ import ( "github.com/pkg/errors" "github.com/scylladb/go-log" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/naming" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -20,7 +20,7 @@ import ( // LoggerForCluster returns a logger that will log with context // about the current cluster -func LoggerForCluster(c *scyllav1alpha1.ScyllaCluster) log.Logger { +func LoggerForCluster(c *scyllav1.ScyllaCluster) log.Logger { l, _ := log.NewProduction(log.Config{ Level: zapcore.DebugLevel, }) @@ -31,7 +31,7 @@ func LoggerForCluster(c *scyllav1alpha1.ScyllaCluster) log.Logger { // have been observed by the StatefulSet controller. // If they haven't, their status might be stale, so it's better to wait // and process them later. -func AreStatefulSetStatusesStale(ctx context.Context, c *scyllav1alpha1.ScyllaCluster, client client.Client) (bool, error) { +func AreStatefulSetStatusesStale(ctx context.Context, c *scyllav1.ScyllaCluster, client client.Client) (bool, error) { sts := &appsv1.StatefulSet{} for _, r := range c.Spec.Datacenter.Racks { err := client.Get(ctx, naming.NamespacedName(naming.StatefulSetNameForRack(r, c), c.Namespace), sts) @@ -48,7 +48,7 @@ func AreStatefulSetStatusesStale(ctx context.Context, c *scyllav1alpha1.ScyllaCl return false, nil } -func GetMemberServicesForRack(ctx context.Context, r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster, cl client.Client) ([]corev1.Service, error) { +func GetMemberServicesForRack(ctx context.Context, r scyllav1.RackSpec, c *scyllav1.ScyllaCluster, cl client.Client) ([]corev1.Service, error) { svcList := &corev1.ServiceList{} err := cl.List(ctx, svcList, &client.ListOptions{ LabelSelector: naming.RackSelector(r, c), @@ -90,10 +90,10 @@ func VerifyOwner(obj, owner metav1.Object) error { // NewControllerRef returns an OwnerReference to // the provided Cluster Object -func NewControllerRef(c *scyllav1alpha1.ScyllaCluster) metav1.OwnerReference { +func NewControllerRef(c *scyllav1.ScyllaCluster) metav1.OwnerReference { return *metav1.NewControllerRef(c, schema.GroupVersionKind{ Group: "scylla.scylladb.com", - Version: "v1alpha1", + Version: "v1", Kind: "ScyllaCluster", }) } diff --git a/pkg/controllers/manager/manager_controller.go b/pkg/controllers/manager/manager_controller.go index 21fa760dfb..b55ca269da 100644 --- a/pkg/controllers/manager/manager_controller.go +++ b/pkg/controllers/manager/manager_controller.go @@ -11,12 +11,12 @@ import ( "github.com/pkg/errors" "github.com/scylladb/go-log" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/mermaidclient" "github.com/scylladb/scylla-operator/pkg/naming" "go.uber.org/multierr" "gopkg.in/yaml.v2" - v1 "k8s.io/api/core/v1" + corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" @@ -79,7 +79,7 @@ func discoverManager(ctx context.Context, mgr mgr.Manager) (*mermaidclient.Clien return nil, errors.Wrap(err, "get dynamic client") } - svcList := &v1.ServiceList{} + svcList := &corev1.ServiceList{} err = cl.List(ctx, svcList, &client.ListOptions{ LabelSelector: naming.ManagerSelector(), }) @@ -121,7 +121,7 @@ func (r *Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) { return ctrl.Result{}, nil } - var cluster v1alpha1.ScyllaCluster + var cluster scyllav1.ScyllaCluster if err := r.UncachedClient.Get(ctx, req.NamespacedName, &cluster); err != nil { if apierrors.IsNotFound(err) { // Object not found, return. Created objects are automatically garbage collected. @@ -257,9 +257,9 @@ func (r *Reconciler) managerState(ctx context.Context, clusterID string) (*state }, nil } -func (r *Reconciler) getAuthToken(ctx context.Context, cluster *v1alpha1.ScyllaCluster) (string, error) { +func (r *Reconciler) getAuthToken(ctx context.Context, cluster *scyllav1.ScyllaCluster) (string, error) { const agentConfigKey = "scylla-manager-agent.yaml" - secret := &v1.Secret{} + secret := &corev1.Secret{} agentSecretName := cluster.Spec.Datacenter.Racks[0].ScyllaAgentConfig secretKey := client.ObjectKey{ Name: agentSecretName, @@ -284,6 +284,6 @@ func (r *Reconciler) getAuthToken(ctx context.Context, cluster *v1alpha1.ScyllaC func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&v1alpha1.ScyllaCluster{}). + For(&scyllav1.ScyllaCluster{}). Complete(r) } diff --git a/pkg/controllers/manager/sync.go b/pkg/controllers/manager/sync.go index 97ad7bed80..4bb5cd968b 100644 --- a/pkg/controllers/manager/sync.go +++ b/pkg/controllers/manager/sync.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "github.com/scylladb/go-set/strset" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/mermaidclient" "github.com/scylladb/scylla-operator/pkg/naming" "github.com/scylladb/scylla-operator/pkg/util/uuid" @@ -21,7 +21,7 @@ type state struct { BackupTasks []*BackupTask } -func sync(ctx context.Context, cluster *v1alpha1.ScyllaCluster, authToken string, state *state) ([]action, bool, error) { +func sync(ctx context.Context, cluster *v1.ScyllaCluster, authToken string, state *state) ([]action, bool, error) { var actions []action requeue := false clusterID := "" @@ -76,7 +76,7 @@ func sync(ctx context.Context, cluster *v1alpha1.ScyllaCluster, authToken string return actions, requeue, nil } -func syncTasks(clusterID string, cluster *v1alpha1.ScyllaCluster, state *state) ([]action, error) { +func syncTasks(clusterID string, cluster *v1.ScyllaCluster, state *state) ([]action, error) { syncer := newStateCache(cluster, state) var actions []action @@ -116,7 +116,7 @@ func syncTasks(clusterID string, cluster *v1alpha1.ScyllaCluster, state *state) return actions, nil } -func syncBackupTasks(clusterID string, cluster *v1alpha1.ScyllaCluster, syncer stateCache, managerState *state) ([]action, error) { +func syncBackupTasks(clusterID string, cluster *v1.ScyllaCluster, syncer stateCache, managerState *state) ([]action, error) { var actions []action for _, bt := range cluster.Spec.Backups { @@ -159,7 +159,7 @@ func syncBackupTasks(clusterID string, cluster *v1alpha1.ScyllaCluster, syncer s return actions, nil } -func syncRepairTasks(clusterID string, cluster *v1alpha1.ScyllaCluster, syncer stateCache, managerState *state) ([]action, error) { +func syncRepairTasks(clusterID string, cluster *v1.ScyllaCluster, syncer stateCache, managerState *state) ([]action, error) { var actions []action for _, rt := range cluster.Spec.Repairs { @@ -208,7 +208,7 @@ type stateCache struct { statusIDNameMapping map[string]string } -func newStateCache(cluster *v1alpha1.ScyllaCluster, state *state) stateCache { +func newStateCache(cluster *v1.ScyllaCluster, state *state) stateCache { s := stateCache{ stateTasks: strset.New(), specTasks: strset.New(), @@ -274,7 +274,7 @@ func (s stateCache) taskID(taskName string) string { } type action interface { - Execute(ctx context.Context, client *mermaidclient.Client, status *v1alpha1.ClusterStatus) error + Execute(ctx context.Context, client *mermaidclient.Client, status *v1.ClusterStatus) error } type addClusterAction struct { @@ -282,7 +282,7 @@ type addClusterAction struct { clusterID string } -func (a *addClusterAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1alpha1.ClusterStatus) error { +func (a *addClusterAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1.ClusterStatus) error { id, err := client.CreateCluster(ctx, a.cluster) if err != nil { return err @@ -301,7 +301,7 @@ type updateClusterAction struct { cluster *mermaidclient.Cluster } -func (a *updateClusterAction) Execute(ctx context.Context, client *mermaidclient.Client, _ *v1alpha1.ClusterStatus) error { +func (a *updateClusterAction) Execute(ctx context.Context, client *mermaidclient.Client, _ *v1.ClusterStatus) error { return client.UpdateCluster(ctx, a.cluster) } @@ -313,7 +313,7 @@ type deleteClusterAction struct { clusterID string } -func (a *deleteClusterAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1alpha1.ClusterStatus) error { +func (a *deleteClusterAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1.ClusterStatus) error { return client.DeleteCluster(ctx, a.clusterID) } @@ -327,7 +327,7 @@ type deleteTaskAction struct { taskID string } -func (a *deleteTaskAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1alpha1.ClusterStatus) error { +func (a *deleteTaskAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1.ClusterStatus) error { err := client.DeleteTask(ctx, a.clusterID, a.taskType, uuid.MustParse(a.taskID)) if a.taskType == "repair" { @@ -372,12 +372,12 @@ func (a addTaskAction) String() string { return fmt.Sprintf("add task %+v", a.task) } -func (a *addTaskAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1alpha1.ClusterStatus) error { +func (a *addTaskAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1.ClusterStatus) error { id, err := client.CreateTask(ctx, a.clusterID, a.task) if a.task.Type == "repair" { - rt := v1alpha1.RepairTaskStatus{ - RepairTaskSpec: a.taskSpec.(v1alpha1.RepairTaskSpec), + rt := v1.RepairTaskStatus{ + RepairTaskSpec: a.taskSpec.(v1.RepairTaskSpec), ID: id.String(), } if err != nil { @@ -397,8 +397,8 @@ func (a *addTaskAction) Execute(ctx context.Context, client *mermaidclient.Clien } } if a.task.Type == "backup" { - bt := v1alpha1.BackupTaskStatus{ - BackupTaskSpec: a.taskSpec.(v1alpha1.BackupTaskSpec), + bt := v1.BackupTaskStatus{ + BackupTaskSpec: a.taskSpec.(v1.BackupTaskSpec), ID: id.String(), } if err != nil { @@ -431,13 +431,13 @@ func (a updateTaskAction) String() string { return fmt.Sprintf("update task %+v", a.task) } -func (a *updateTaskAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1alpha1.ClusterStatus) error { +func (a *updateTaskAction) Execute(ctx context.Context, client *mermaidclient.Client, status *v1.ClusterStatus) error { err := client.UpdateTask(ctx, a.clusterID, a.task) if a.task.Type == "repair" { for i, repairStatus := range status.Repairs { if a.task.ID == repairStatus.ID { - status.Repairs[i].RepairTaskSpec = a.taskSpec.(v1alpha1.RepairTaskSpec) + status.Repairs[i].RepairTaskSpec = a.taskSpec.(v1.RepairTaskSpec) if err != nil { status.Repairs[i].Error = mermaidclient.MessageOf(err) } @@ -448,7 +448,7 @@ func (a *updateTaskAction) Execute(ctx context.Context, client *mermaidclient.Cl if a.task.Type == "backup" { for i, backupStatus := range status.Backups { if a.task.ID == backupStatus.ID { - status.Backups[i].BackupTaskSpec = a.taskSpec.(v1alpha1.BackupTaskSpec) + status.Backups[i].BackupTaskSpec = a.taskSpec.(v1.BackupTaskSpec) if err != nil { status.Backups[i].Error = mermaidclient.MessageOf(err) } diff --git a/pkg/controllers/manager/sync_test.go b/pkg/controllers/manager/sync_test.go index 7b30074625..76b7d72c7c 100644 --- a/pkg/controllers/manager/sync_test.go +++ b/pkg/controllers/manager/sync_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/mermaidclient" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" @@ -24,8 +24,8 @@ func TestManagerSynchronization(t *testing.T) { tcs := []struct { Name string - Spec v1alpha1.ClusterSpec - Status v1alpha1.ClusterStatus + Spec v1.ClusterSpec + Status v1.ClusterStatus State state Actions []action @@ -33,8 +33,8 @@ func TestManagerSynchronization(t *testing.T) { }{ { Name: "Empty manager, empty spec, add cluster and requeue", - Spec: v1alpha1.ClusterSpec{}, - Status: v1alpha1.ClusterStatus{}, + Spec: v1.ClusterSpec{}, + Status: v1.ClusterStatus{}, State: state{}, Requeue: true, @@ -42,10 +42,10 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Empty manager, task in spec, add cluster and requeue", - Spec: v1alpha1.ClusterSpec{ - Repairs: []v1alpha1.RepairTaskSpec{}, + Spec: v1.ClusterSpec{ + Repairs: []v1.RepairTaskSpec{}, }, - Status: v1alpha1.ClusterStatus{}, + Status: v1.ClusterStatus{}, State: state{}, Requeue: true, @@ -53,8 +53,8 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Cluster registered in manager do nothing", - Spec: v1alpha1.ClusterSpec{}, - Status: v1alpha1.ClusterStatus{}, + Spec: v1.ClusterSpec{}, + Status: v1.ClusterStatus{}, State: state{ Clusters: []*mermaidclient.Cluster{{ Name: clusterName, @@ -67,8 +67,8 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Cluster registered in manager but auth token is different, update and requeue", - Spec: v1alpha1.ClusterSpec{}, - Status: v1alpha1.ClusterStatus{ + Spec: v1.ClusterSpec{}, + Status: v1.ClusterStatus{ ManagerID: pointer.StringPtr(clusterID), }, State: state{ @@ -84,8 +84,8 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Name collision, delete old one, add new and requeue", - Spec: v1alpha1.ClusterSpec{}, - Status: v1alpha1.ClusterStatus{ + Spec: v1.ClusterSpec{}, + Status: v1.ClusterStatus{ ManagerID: pointer.StringPtr(clusterID), }, State: state{ @@ -103,10 +103,10 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Schedule repair task", - Spec: v1alpha1.ClusterSpec{ - Repairs: []v1alpha1.RepairTaskSpec{ + Spec: v1.ClusterSpec{ + Repairs: []v1.RepairTaskSpec{ { - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "my-repair", }, DC: []string{"dc1"}, @@ -116,7 +116,7 @@ func TestManagerSynchronization(t *testing.T) { }, }, }, - Status: v1alpha1.ClusterStatus{ + Status: v1.ClusterStatus{ ManagerID: pointer.StringPtr(clusterID), }, State: state{ @@ -131,10 +131,10 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Schedule backup task", - Spec: v1alpha1.ClusterSpec{ - Backups: []v1alpha1.BackupTaskSpec{ + Spec: v1.ClusterSpec{ + Backups: []v1.BackupTaskSpec{ { - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "my-backup", }, DC: []string{"dc1"}, @@ -147,7 +147,7 @@ func TestManagerSynchronization(t *testing.T) { }, }, }, - Status: v1alpha1.ClusterStatus{ + Status: v1.ClusterStatus{ ManagerID: pointer.StringPtr(clusterID), }, State: state{ @@ -162,22 +162,22 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Update repair if it's already registered in Manager", - Spec: v1alpha1.ClusterSpec{ - Repairs: []v1alpha1.RepairTaskSpec{ + Spec: v1.ClusterSpec{ + Repairs: []v1.RepairTaskSpec{ { - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "repair", }, }, }, }, - Status: v1alpha1.ClusterStatus{ + Status: v1.ClusterStatus{ ManagerID: pointer.StringPtr(clusterID), - Repairs: []v1alpha1.RepairTaskStatus{ + Repairs: []v1.RepairTaskStatus{ { ID: "repair-id", - RepairTaskSpec: v1alpha1.RepairTaskSpec{ - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + RepairTaskSpec: v1.RepairTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "repair", }, Intensity: pointer.StringPtr("666"), @@ -193,8 +193,8 @@ func TestManagerSynchronization(t *testing.T) { }}, RepairTasks: []*RepairTask{ { - RepairTaskSpec: v1alpha1.RepairTaskSpec{ - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + RepairTaskSpec: v1.RepairTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "repair", }, Intensity: pointer.StringPtr("123"), @@ -208,23 +208,23 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Do not update task when it didn't change", - Spec: v1alpha1.ClusterSpec{ - Repairs: []v1alpha1.RepairTaskSpec{ + Spec: v1.ClusterSpec{ + Repairs: []v1.RepairTaskSpec{ { - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "repair", }, Intensity: pointer.StringPtr("666"), }, }, }, - Status: v1alpha1.ClusterStatus{ + Status: v1.ClusterStatus{ ManagerID: pointer.StringPtr(clusterID), - Repairs: []v1alpha1.RepairTaskStatus{ + Repairs: []v1.RepairTaskStatus{ { ID: "repair-id", - RepairTaskSpec: v1alpha1.RepairTaskSpec{ - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + RepairTaskSpec: v1.RepairTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "repair", }, Intensity: pointer.StringPtr("666"), @@ -240,8 +240,8 @@ func TestManagerSynchronization(t *testing.T) { }}, RepairTasks: []*RepairTask{ { - RepairTaskSpec: v1alpha1.RepairTaskSpec{ - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + RepairTaskSpec: v1.RepairTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "repair", }, Intensity: pointer.StringPtr("666"), @@ -255,8 +255,8 @@ func TestManagerSynchronization(t *testing.T) { }, { Name: "Delete tasks from Manager unknown to spec", - Spec: v1alpha1.ClusterSpec{}, - Status: v1alpha1.ClusterStatus{ + Spec: v1.ClusterSpec{}, + Status: v1.ClusterStatus{ ManagerID: pointer.StringPtr(clusterID), }, State: state{ @@ -267,8 +267,8 @@ func TestManagerSynchronization(t *testing.T) { }}, RepairTasks: []*RepairTask{ { - RepairTaskSpec: v1alpha1.RepairTaskSpec{ - SchedulerTaskSpec: v1alpha1.SchedulerTaskSpec{ + RepairTaskSpec: v1.RepairTaskSpec{ + SchedulerTaskSpec: v1.SchedulerTaskSpec{ Name: "other-repair", }, }, @@ -285,7 +285,7 @@ func TestManagerSynchronization(t *testing.T) { test := tcs[i] t.Run(test.Name, func(t *testing.T) { ctx := context.Background() - cluster := &v1alpha1.ScyllaCluster{ + cluster := &v1.ScyllaCluster{ ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace}, Spec: test.Spec, Status: test.Status, diff --git a/pkg/controllers/manager/types.go b/pkg/controllers/manager/types.go index 22d2ed78e2..c6b3f9c657 100644 --- a/pkg/controllers/manager/types.go +++ b/pkg/controllers/manager/types.go @@ -8,13 +8,13 @@ import ( "github.com/mitchellh/mapstructure" "github.com/pkg/errors" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/mermaidclient" "github.com/scylladb/scylla-operator/pkg/util/duration" "k8s.io/utils/pointer" ) -type RepairTask v1alpha1.RepairTaskStatus +type RepairTask v1.RepairTaskStatus func (r RepairTask) ToManager() (*mermaidclient.Task, error) { t := &mermaidclient.Task{ @@ -98,7 +98,7 @@ func (r *RepairTask) FromManager(t *mermaidclient.ExtendedTask) error { return nil } -type BackupTask v1alpha1.BackupTaskStatus +type BackupTask v1.BackupTaskStatus func (b BackupTask) ToManager() (*mermaidclient.Task, error) { t := &mermaidclient.Task{ diff --git a/pkg/controllers/sidecar/config/config.go b/pkg/controllers/sidecar/config/config.go index 89e32b9500..9393ce6453 100644 --- a/pkg/controllers/sidecar/config/config.go +++ b/pkg/controllers/sidecar/config/config.go @@ -17,7 +17,7 @@ import ( "github.com/magiconair/properties" "github.com/pkg/errors" "github.com/scylladb/go-log" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/cmd/options" "github.com/scylladb/scylla-operator/pkg/controllers/sidecar/identity" "github.com/scylladb/scylla-operator/pkg/naming" @@ -196,7 +196,7 @@ func (s *ScyllaConfig) setupEntrypoint(ctx context.Context) (*exec.Cmd, error) { // Check if we need to run in developer mode devMode := "0" - cluster := &v1alpha1.ScyllaCluster{} + cluster := &v1.ScyllaCluster{} err = s.Get(ctx, naming.NamespacedName(s.member.Cluster, s.member.Namespace), cluster) if err != nil { return nil, errors.Wrap(err, "error getting cluster") @@ -249,7 +249,7 @@ func (s *ScyllaConfig) setupEntrypoint(ctx context.Context) (*exec.Cmd, error) { if err != nil { s.logger.Info(ctx, "This scylla version might not support ScyllaArgs", "version", cluster.Spec.Version) appendScyllaArguments(ctx, s, cluster.Spec.ScyllaArgs, args) - } else if version.LT(v1alpha1.ScyllaVersionThatSupportsArgs) { + } else if version.LT(v1.ScyllaVersionThatSupportsArgs) { s.logger.Info(ctx, "This scylla version does not support ScyllaArgs. ScyllaArgs is ignored", "version", cluster.Spec.Version) } else { appendScyllaArguments(ctx, s, cluster.Spec.ScyllaArgs, args) diff --git a/pkg/controllers/sidecar/config/config_test.go b/pkg/controllers/sidecar/config/config_test.go index 8bcd9300b7..d7dd66cfc9 100644 --- a/pkg/controllers/sidecar/config/config_test.go +++ b/pkg/controllers/sidecar/config/config_test.go @@ -12,7 +12,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/magiconair/properties" "github.com/scylladb/go-log" - "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/cmd/options" "github.com/scylladb/scylla-operator/pkg/controllers/sidecar/identity" "github.com/scylladb/scylla-operator/pkg/naming" @@ -274,7 +274,7 @@ func TestReplaceNodeLabelInMemberService(t *testing.T) { logger, _ := log.NewProduction(log.Config{ Level: atom, }) - if err := v1alpha1.AddToScheme(scheme.Scheme); err != nil { + if err := scyllav1.AddToScheme(scheme.Scheme); err != nil { t.Fatal(err) } @@ -298,7 +298,7 @@ func TestReplaceNodeLabelInMemberService(t *testing.T) { }, }, } - fakeCluster := &v1alpha1.ScyllaCluster{ + fakeCluster := &scyllav1.ScyllaCluster{ ObjectMeta: v1.ObjectMeta{ Name: m.Cluster, Namespace: m.Namespace, diff --git a/pkg/naming/labels.go b/pkg/naming/labels.go index 0f8fd0859d..7208e49024 100644 --- a/pkg/naming/labels.go +++ b/pkg/naming/labels.go @@ -3,14 +3,14 @@ package naming import ( "fmt" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/labels" ) // ClusterLabels returns a map of label keys and values // for the given Cluster. -func ClusterLabels(c *scyllav1alpha1.ScyllaCluster) map[string]string { +func ClusterLabels(c *scyllav1.ScyllaCluster) map[string]string { labels := recommendedLabels() labels[ClusterNameLabel] = c.Name return labels @@ -18,7 +18,7 @@ func ClusterLabels(c *scyllav1alpha1.ScyllaCluster) map[string]string { // DatacenterLabels returns a map of label keys and values // for the given Datacenter. -func DatacenterLabels(c *scyllav1alpha1.ScyllaCluster) map[string]string { +func DatacenterLabels(c *scyllav1.ScyllaCluster) map[string]string { recLabels := recommendedLabels() dcLabels := ClusterLabels(c) dcLabels[DatacenterNameLabel] = c.Spec.Datacenter.Name @@ -28,7 +28,7 @@ func DatacenterLabels(c *scyllav1alpha1.ScyllaCluster) map[string]string { // RackLabels returns a map of label keys and values // for the given Rack. -func RackLabels(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) map[string]string { +func RackLabels(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster) map[string]string { recLabels := recommendedLabels() rackLabels := DatacenterLabels(c) rackLabels[RackNameLabel] = r.Name @@ -45,7 +45,7 @@ func StatefulSetPodLabel(name string) map[string]string { } // RackSelector returns a LabelSelector for the given rack. -func RackSelector(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) labels.Selector { +func RackSelector(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster) labels.Selector { rackLabelsSet := labels.Set(RackLabels(r, c)) sel := labels.SelectorFromSet(rackLabelsSet) diff --git a/pkg/naming/names.go b/pkg/naming/names.go index df00f4ea5b..71cd99a077 100644 --- a/pkg/naming/names.go +++ b/pkg/naming/names.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -26,7 +26,7 @@ func NamespacedNameForObject(obj metav1.Object) client.ObjectKey { } } -func StatefulSetNameForRack(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster) string { +func StatefulSetNameForRack(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster) string { return fmt.Sprintf("%s-%s-%s", c.Name, c.Spec.Datacenter.Name, r.Name) } @@ -35,27 +35,27 @@ func ServiceNameFromPod(pod *corev1.Pod) string { return pod.Name } -func MemberServiceName(r scyllav1alpha1.RackSpec, c *scyllav1alpha1.ScyllaCluster, idx int) string { +func MemberServiceName(r scyllav1.RackSpec, c *scyllav1.ScyllaCluster, idx int) string { return fmt.Sprintf("%s-%d", StatefulSetNameForRack(r, c), idx) } -func ServiceDNSName(service string, c *scyllav1alpha1.ScyllaCluster) string { +func ServiceDNSName(service string, c *scyllav1.ScyllaCluster) string { return fmt.Sprintf("%s.%s", service, CrossNamespaceServiceNameForCluster(c)) } -func ServiceAccountNameForMembers(c *scyllav1alpha1.ScyllaCluster) string { +func ServiceAccountNameForMembers(c *scyllav1.ScyllaCluster) string { return fmt.Sprintf("%s-member", c.Name) } -func HeadlessServiceNameForCluster(c *scyllav1alpha1.ScyllaCluster) string { +func HeadlessServiceNameForCluster(c *scyllav1.ScyllaCluster) string { return fmt.Sprintf("%s-client", c.Name) } -func CrossNamespaceServiceNameForCluster(c *scyllav1alpha1.ScyllaCluster) string { +func CrossNamespaceServiceNameForCluster(c *scyllav1.ScyllaCluster) string { return fmt.Sprintf("%s.%s.svc.cluster.local", HeadlessServiceNameForCluster(c), c.Namespace) } -func ManagerClusterName(c *scyllav1alpha1.ScyllaCluster) string { +func ManagerClusterName(c *scyllav1.ScyllaCluster) string { return c.Namespace + "/" + c.Name } diff --git a/pkg/test/integration/client.go b/pkg/test/integration/client.go index cf69aeee2d..c6d393fdb3 100644 --- a/pkg/test/integration/client.go +++ b/pkg/test/integration/client.go @@ -7,7 +7,7 @@ import ( "time" "github.com/pkg/errors" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/util/wait" @@ -20,7 +20,7 @@ type Client struct { client.Client } -func (c *Client) UpdateScyllaCluster(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster, opts ...client.UpdateOption) error { +func (c *Client) UpdateScyllaCluster(ctx context.Context, cluster *scyllav1.ScyllaCluster, opts ...client.UpdateOption) error { rv := cluster.ResourceVersion if err := c.Client.Update(ctx, cluster, opts...); err != nil { @@ -28,7 +28,7 @@ func (c *Client) UpdateScyllaCluster(ctx context.Context, cluster *scyllav1alpha } return wait.Poll(c.RetryInterval, c.Timeout, func() (bool, error) { - newCluster := &scyllav1alpha1.ScyllaCluster{} + newCluster := &scyllav1.ScyllaCluster{} key := client.ObjectKey{ Namespace: cluster.Namespace, Name: cluster.Name, diff --git a/pkg/test/integration/envtest.go b/pkg/test/integration/envtest.go index ed33ef6488..24237031c7 100644 --- a/pkg/test/integration/envtest.go +++ b/pkg/test/integration/envtest.go @@ -17,7 +17,7 @@ import ( "github.com/pkg/errors" "github.com/scylladb/go-log" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" utilyaml "github.com/scylladb/scylla-operator/pkg/util/yaml" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,7 +43,7 @@ func rootPath() string { func init() { // Register the scheme. - utilruntime.Must(scyllav1alpha1.AddToScheme(scheme.Scheme)) + utilruntime.Must(scyllav1.AddToScheme(scheme.Scheme)) root := rootPath() env = &envtest.Environment{ @@ -118,7 +118,7 @@ func NewTestEnvironment(logger log.Logger, options ...EnvOption) (*TestEnvironme return nil, errors.Wrap(err, "start testenv manager") } - if err := (&scyllav1alpha1.ScyllaCluster{}).SetupWebhookWithManager(mgr); err != nil { + if err := (&scyllav1.ScyllaCluster{}).SetupWebhookWithManager(mgr); err != nil { return nil, errors.Wrap(err, "create webhook") } diff --git a/pkg/test/integration/statefulset.go b/pkg/test/integration/statefulset.go index b0978b739d..c76570ff70 100644 --- a/pkg/test/integration/statefulset.go +++ b/pkg/test/integration/statefulset.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/scylladb/go-log" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/naming" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -46,11 +46,11 @@ func WithPodCondition(condition corev1.PodCondition) func(pod *corev1.Pod) { type PodOption func(pod *corev1.Pod) -func (s *StatefulSetOperatorStub) CreatePods(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster, options ...PodOption) error { +func (s *StatefulSetOperatorStub) CreatePods(ctx context.Context, cluster *scyllav1.ScyllaCluster, options ...PodOption) error { return s.CreatePodsPartition(ctx, cluster, 0, options...) } -func (s *StatefulSetOperatorStub) CreatePodsPartition(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster, partition int, options ...PodOption) error { +func (s *StatefulSetOperatorStub) CreatePodsPartition(ctx context.Context, cluster *scyllav1.ScyllaCluster, partition int, options ...PodOption) error { for _, rack := range cluster.Spec.Datacenter.Racks { sts := &appsv1.StatefulSet{} @@ -140,7 +140,7 @@ func WithPVNodeAffinity(matchExpressions []corev1.NodeSelectorRequirement) func( type PVOption func(pv *corev1.PersistentVolume) -func (s *StatefulSetOperatorStub) CreatePVCs(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster, pvOptions ...PVOption) error { +func (s *StatefulSetOperatorStub) CreatePVCs(ctx context.Context, cluster *scyllav1.ScyllaCluster, pvOptions ...PVOption) error { for _, rack := range cluster.Spec.Datacenter.Racks { sts := &appsv1.StatefulSet{} @@ -213,7 +213,7 @@ func (s *StatefulSetOperatorStub) CreatePVCs(ctx context.Context, cluster *scyll return nil } -func (s *StatefulSetOperatorStub) SyncStatus(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster) error { +func (s *StatefulSetOperatorStub) SyncStatus(ctx context.Context, cluster *scyllav1.ScyllaCluster) error { for _, rack := range cluster.Spec.Datacenter.Racks { sts := &appsv1.StatefulSet{} diff --git a/pkg/test/integration/utils.go b/pkg/test/integration/utils.go index b155a51826..af291eb283 100644 --- a/pkg/test/integration/utils.go +++ b/pkg/test/integration/utils.go @@ -5,7 +5,7 @@ package integration import ( "context" - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/naming" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" @@ -17,23 +17,23 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -func (t *TestEnvironment) SingleRackCluster(ns *corev1.Namespace) *scyllav1alpha1.ScyllaCluster { - return &scyllav1alpha1.ScyllaCluster{ +func (t *TestEnvironment) SingleRackCluster(ns *corev1.Namespace) *scyllav1.ScyllaCluster { + return &scyllav1.ScyllaCluster{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-", Namespace: ns.Name, }, - Spec: scyllav1alpha1.ClusterSpec{ + Spec: scyllav1.ClusterSpec{ Version: "4.2.0", AgentVersion: pointer.StringPtr("2.2.0"), DeveloperMode: true, - Datacenter: scyllav1alpha1.DatacenterSpec{ + Datacenter: scyllav1.DatacenterSpec{ Name: "dc1", - Racks: []scyllav1alpha1.RackSpec{ + Racks: []scyllav1.RackSpec{ { Name: "rack1", Members: 3, - Storage: scyllav1alpha1.StorageSpec{ + Storage: scyllav1.StorageSpec{ Capacity: "10M", }, Resources: corev1.ResourceRequirements{ @@ -53,7 +53,7 @@ func (t *TestEnvironment) SingleRackCluster(ns *corev1.Namespace) *scyllav1alpha } } -func (t *TestEnvironment) WaitForCluster(ctx context.Context, cluster *scyllav1alpha1.ScyllaCluster) error { +func (t *TestEnvironment) WaitForCluster(ctx context.Context, cluster *scyllav1.ScyllaCluster) error { return wait.Poll(t.RetryInterval, t.Timeout, func() (bool, error) { err := t.Get(ctx, naming.NamespacedName(cluster.Name, cluster.Namespace), cluster) if apierrors.IsNotFound(err) { @@ -74,7 +74,7 @@ func (t *TestEnvironment) ClusterScaleSteps(desiredNodeCount int32) []int32 { return steps } -func (t *TestEnvironment) StatefulSetOfRack(ctx context.Context, rack scyllav1alpha1.RackSpec, cluster *scyllav1alpha1.ScyllaCluster) (*appsv1.StatefulSet, error) { +func (t *TestEnvironment) StatefulSetOfRack(ctx context.Context, rack scyllav1.RackSpec, cluster *scyllav1.ScyllaCluster) (*appsv1.StatefulSet, error) { sts := &appsv1.StatefulSet{} return sts, wait.Poll(t.RetryInterval, t.Timeout, func() (bool, error) { err := t.Get(ctx, naming.NamespacedName(naming.StatefulSetNameForRack(rack, cluster), cluster.Namespace), sts) @@ -87,7 +87,7 @@ func (t *TestEnvironment) StatefulSetOfRack(ctx context.Context, rack scyllav1al }) } -func (t *TestEnvironment) AssertRackScaled(ctx context.Context, rack scyllav1alpha1.RackSpec, cluster *scyllav1alpha1.ScyllaCluster, replicas int32) error { +func (t *TestEnvironment) AssertRackScaled(ctx context.Context, rack scyllav1.RackSpec, cluster *scyllav1.ScyllaCluster, replicas int32) error { return wait.Poll(t.RetryInterval, t.Timeout, func() (bool, error) { sts, err := t.StatefulSetOfRack(ctx, rack, cluster) if err != nil { @@ -97,7 +97,7 @@ func (t *TestEnvironment) AssertRackScaled(ctx context.Context, rack scyllav1alp }) } -func (t *TestEnvironment) RackMemberServices(ctx context.Context, namespace string, rack scyllav1alpha1.RackSpec, cluster *scyllav1alpha1.ScyllaCluster) ([]corev1.Service, error) { +func (t *TestEnvironment) RackMemberServices(ctx context.Context, namespace string, rack scyllav1.RackSpec, cluster *scyllav1.ScyllaCluster) ([]corev1.Service, error) { services := &corev1.ServiceList{} err := wait.PollImmediate(t.RetryInterval, t.Timeout, func() (bool, error) { err := t.List(ctx, services, &client.ListOptions{ diff --git a/pkg/test/unit/helpers.go b/pkg/test/unit/helpers.go index f5acc772ff..f270742c5d 100644 --- a/pkg/test/unit/helpers.go +++ b/pkg/test/unit/helpers.go @@ -1,39 +1,39 @@ package unit import ( - scyllav1alpha1 "github.com/scylladb/scylla-operator/pkg/api/v1alpha1" + scyllav1 "github.com/scylladb/scylla-operator/pkg/api/v1" "github.com/scylladb/scylla-operator/pkg/controllers/cluster/util" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -func NewSingleRackCluster(members int32) *scyllav1alpha1.ScyllaCluster { +func NewSingleRackCluster(members int32) *scyllav1.ScyllaCluster { return NewDetailedSingleRackCluster("test-cluster", "test-ns", "repo", "2.3.1", "test-dc", "test-rack", members) } -func NewDetailedSingleRackCluster(name, namespace, repo, version, dc, rack string, members int32) *scyllav1alpha1.ScyllaCluster { - return &scyllav1alpha1.ScyllaCluster{ +func NewDetailedSingleRackCluster(name, namespace, repo, version, dc, rack string, members int32) *scyllav1.ScyllaCluster { + return &scyllav1.ScyllaCluster{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: scyllav1alpha1.ClusterSpec{ + Spec: scyllav1.ClusterSpec{ Repository: util.RefFromString(repo), Version: version, - Datacenter: scyllav1alpha1.DatacenterSpec{ + Datacenter: scyllav1.DatacenterSpec{ Name: dc, - Racks: []scyllav1alpha1.RackSpec{ + Racks: []scyllav1.RackSpec{ { Name: rack, Members: members, - Storage: scyllav1alpha1.StorageSpec{ + Storage: scyllav1.StorageSpec{ Capacity: "5Gi", }, }, }, }, }, - Status: scyllav1alpha1.ClusterStatus{ - Racks: map[string]scyllav1alpha1.RackStatus{ + Status: scyllav1.ClusterStatus{ + Racks: map[string]scyllav1.RackStatus{ rack: { Version: version, Members: members,