diff --git a/README.md b/README.md index 4fd211993..442635f9b 100644 --- a/README.md +++ b/README.md @@ -70,14 +70,14 @@ $ kubectl describe storageoscluster/example-storageos Name: example-storageos Namespace: default Labels: -Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storageos.com/v1alpha1","kind":"StorageOSCluster","metadata":{"annotations":{},"name":"example-storageos","namespace":"default"},"spec":{"... -API Version: storageos.com/v1alpha1 +Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storageos.com/v1","kind":"StorageOSCluster","metadata":{"annotations":{},"name":"example-storageos","namespace":"default"},"spec":{"... +API Version: storageos.com/v1 Kind: StorageOSCluster Metadata: Creation Timestamp: 2018-07-21T12:57:11Z Generation: 1 Resource Version: 10939030 - Self Link: /apis/storageos.com/v1alpha1/namespaces/default/storageosclusters/example-storageos + Self Link: /apis/storageos.com/v1/namespaces/default/storageosclusters/example-storageos UID: 955b24a4-8ce5-11e8-956a-1866da35eee2 Spec: Join: test07 @@ -145,7 +145,7 @@ An existing StorageOS cluster can be upgraded to a new version of StorageOS by creating an Upgrade Configuration. The cluster-operator takes care of downloading the new container image and updating all the nodes with new version of StorageOS. -An example of `StorageOSUpgrade` resource is [storageos_v1alpha1_storageosupgrade_cr.yaml](/deploy/crds/storageos_v1alpha1_storageosupgrade_cr.yaml). +An example of `StorageOSUpgrade` resource is [storageos_v1_storageosupgrade_cr.yaml](/deploy/crds/storageos_v1_storageosupgrade_cr.yaml). Only offline upgrade is supported for now by cluster-operator. During the upgrade, StorageOS maintenance mode is enabled, the applications that use @@ -164,8 +164,8 @@ $ kubectl describe storageosupgrades example-storageosupgrade Name: example-storageosupgrade Namespace: default Labels: -Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storageos.com/v1alpha1","kind":"StorageOSUpgrade","metadata":{"annotations":{},"name":"example-storageosupgrade","namespace":"default"},... -API Version: storageos.com/v1alpha1 +Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"storageos.com/v1","kind":"StorageOSUpgrade","metadata":{"annotations":{},"name":"example-storageosupgrade","namespace":"default"},... +API Version: storageos.com/v1 Kind: StorageOSUpgrade ... Spec: @@ -208,7 +208,7 @@ all nodes or on selected nodes. This can be used to easily perform cleanup task. An example would be to create a `Job` resource: ```yaml -apiVersion: storageos.com/v1alpha1 +apiVersion: storageos.com/v1 kind: Job metadata: name: cleanup-job @@ -352,7 +352,7 @@ To enable CSI, set `csi.enable` to `true` in the `StorageOSCluster` resource config. ```yaml -apiVersion: "storageos.com/v1alpha1" +apiVersion: "storageos.com/v1" kind: "StorageOSCluster" metadata: name: "example-storageos" @@ -371,7 +371,7 @@ To enable CSI Credentials, ensure that CSI is enabled by setting `csi.enable` to `true`: ```yaml -apiVersion: "storageos.com/v1alpha1" +apiVersion: "storageos.com/v1" kind: "StorageOSCluster" metadata: name: "example-storageos" diff --git a/deploy/crds/storageos_v1alpha1_job_cr.yaml b/deploy/crds/storageos_v1_job_cr.yaml similarity index 83% rename from deploy/crds/storageos_v1alpha1_job_cr.yaml rename to deploy/crds/storageos_v1_job_cr.yaml index 7d9a954d0..8a7cf8548 100644 --- a/deploy/crds/storageos_v1alpha1_job_cr.yaml +++ b/deploy/crds/storageos_v1_job_cr.yaml @@ -1,4 +1,4 @@ -apiVersion: storageos.com/v1alpha1 +apiVersion: storageos.com/v1 kind: Job metadata: name: example-job diff --git a/deploy/crds/storageos_v1alpha1_job_crd.yaml b/deploy/crds/storageos_v1_job_crd.yaml similarity index 92% rename from deploy/crds/storageos_v1alpha1_job_crd.yaml rename to deploy/crds/storageos_v1_job_crd.yaml index b2b4b81ba..2d7660858 100644 --- a/deploy/crds/storageos_v1alpha1_job_crd.yaml +++ b/deploy/crds/storageos_v1_job_crd.yaml @@ -10,4 +10,4 @@ spec: plural: jobs singular: job scope: Namespaced - version: v1alpha1 + version: v1 diff --git a/deploy/crds/storageos_v1alpha1_storageoscluster_cr.yaml b/deploy/crds/storageos_v1_storageoscluster_cr.yaml similarity index 98% rename from deploy/crds/storageos_v1alpha1_storageoscluster_cr.yaml rename to deploy/crds/storageos_v1_storageoscluster_cr.yaml index 96ba51cda..9885f51cb 100644 --- a/deploy/crds/storageos_v1alpha1_storageoscluster_cr.yaml +++ b/deploy/crds/storageos_v1_storageoscluster_cr.yaml @@ -1,4 +1,4 @@ -apiVersion: storageos.com/v1alpha1 +apiVersion: storageos.com/v1 kind: StorageOSCluster metadata: name: example-storageoscluster diff --git a/deploy/crds/storageos_v1alpha1_storageoscluster_crd.yaml b/deploy/crds/storageos_v1_storageoscluster_crd.yaml similarity index 99% rename from deploy/crds/storageos_v1alpha1_storageoscluster_crd.yaml rename to deploy/crds/storageos_v1_storageoscluster_crd.yaml index 8baffb2bb..00f6d038e 100644 --- a/deploy/crds/storageos_v1alpha1_storageoscluster_crd.yaml +++ b/deploy/crds/storageos_v1_storageoscluster_crd.yaml @@ -12,7 +12,7 @@ spec: shortNames: - stos scope: Namespaced - version: v1alpha1 + version: v1 additionalPrinterColumns: - name: Ready type: string diff --git a/deploy/crds/storageos_v1alpha1_storageosupgrade_cr.yaml b/deploy/crds/storageos_v1_storageosupgrade_cr.yaml similarity index 75% rename from deploy/crds/storageos_v1alpha1_storageosupgrade_cr.yaml rename to deploy/crds/storageos_v1_storageosupgrade_cr.yaml index fdc41c939..1696e318e 100644 --- a/deploy/crds/storageos_v1alpha1_storageosupgrade_cr.yaml +++ b/deploy/crds/storageos_v1_storageosupgrade_cr.yaml @@ -1,4 +1,4 @@ -apiVersion: storageos.com/v1alpha1 +apiVersion: storageos.com/v1 kind: StorageOSUpgrade metadata: name: example-storageosupgrade diff --git a/deploy/crds/storageos_v1alpha1_storageosupgrade_crd.yaml b/deploy/crds/storageos_v1_storageosupgrade_crd.yaml similarity index 93% rename from deploy/crds/storageos_v1alpha1_storageosupgrade_crd.yaml rename to deploy/crds/storageos_v1_storageosupgrade_crd.yaml index a18f77bfc..615498fb6 100644 --- a/deploy/crds/storageos_v1alpha1_storageosupgrade_crd.yaml +++ b/deploy/crds/storageos_v1_storageosupgrade_crd.yaml @@ -10,4 +10,4 @@ spec: plural: storageosupgrades singular: storageosupgrade scope: Namespaced - version: v1alpha1 + version: v1 diff --git a/deploy/storageos-operators.configmap.yaml b/deploy/storageos-operators.configmap.yaml index 820864972..63fbd1bf6 100644 --- a/deploy/storageos-operators.configmap.yaml +++ b/deploy/storageos-operators.configmap.yaml @@ -23,7 +23,7 @@ data: shortNames: - stos scope: Namespaced - version: v1alpha1 + version: v1 additionalPrinterColumns: - name: Ready type: string @@ -139,7 +139,7 @@ data: plural: jobs singular: job scope: Namespaced - version: v1alpha1 + version: v1 - apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: @@ -152,7 +152,7 @@ data: plural: storageosupgrades singular: storageosupgrade scope: Namespaced - version: v1alpha1 + version: v1 clusterServiceVersions: |- @@ -165,7 +165,7 @@ data: annotations: capabilities: Full Lifecycle categories: "Storage" - alm-examples: '[{"apiVersion":"storageos.com/v1alpha1","kind":"StorageOSCluster","metadata":{"name":"example-storageos","namespace":"default"},"spec":{"secretRefName":"storageos-api","secretRefNamespace":"default"}},{"apiVersion":"storageos.com/v1alpha1","kind":"Job","metadata":{"name":"example-job","namespace":"default"},"spec":{"image":"storageos/cluster-operator:latest","args":["/var/lib/storageos"],"mountPath":"/var/lib","hostPath":"/var/lib","completionWord":"done"}},{"apiVersion":"storageos.com/v1alpha1","kind":"StorageOSUpgrade","metadata":{"name":"example-upgrade","namespace":"default"},"spec":{"newImage":"storageos/node:latest"}}]' + alm-examples: '[{"apiVersion":"storageos.com/v1","kind":"StorageOSCluster","metadata":{"name":"example-storageos","namespace":"default"},"spec":{"secretRefName":"storageos-api","secretRefNamespace":"default"}},{"apiVersion":"storageos.com/v1","kind":"Job","metadata":{"name":"example-job","namespace":"default"},"spec":{"image":"storageos/cluster-operator:latest","args":["/var/lib/storageos"],"mountPath":"/var/lib","hostPath":"/var/lib","completionWord":"done"}},{"apiVersion":"storageos.com/v1","kind":"StorageOSUpgrade","metadata":{"name":"example-upgrade","namespace":"default"},"spec":{"newImage":"storageos/node:latest"}}]' description: Cloud-native, persistent storage for containers. containerImage: storageos/cluster-operator:test repository: https://github.com/storageos/cluster-operator @@ -420,7 +420,7 @@ data: customresourcedefinitions: owned: - name: storageosclusters.storageos.com - version: v1alpha1 + version: v1 kind: StorageOSCluster displayName: StorageOS Cluster description: StorageOS Cluster installs StorageOS in the cluster. It contains all the configuration for setting up a StorageOS cluster and also shows the status of the running StorageOS cluster. @@ -449,12 +449,12 @@ data: displayName: Ready path: ready - name: jobs.storageos.com - version: v1alpha1 + version: v1 kind: Job displayName: StorageOS Job description: StorageOS Job creates special pods that run on all the node and perform an administrative task. This could be used for cluster maintenance tasks. - name: storageosupgrades.storageos.com - version: v1alpha1 + version: v1 kind: StorageOSUpgrade displayName: StorageOS Upgrade description: StorageOS Upgrade automatically upgrades an existing StorageOS cluster as per the upgrade configuration. @@ -463,7 +463,7 @@ data: - packageName: storageos channels: - - name: alpha + - name: stable currentCSV: storageosoperator.0.0.0 diff --git a/deploy/storageos-operators.olm.cr.yaml b/deploy/storageos-operators.olm.cr.yaml index 1e1f91ee9..6baae4962 100644 --- a/deploy/storageos-operators.olm.cr.yaml +++ b/deploy/storageos-operators.olm.cr.yaml @@ -1,4 +1,4 @@ -apiVersion: storageos.com/v1alpha1 +apiVersion: storageos.com/v1 kind: StorageOSCluster metadata: name: example diff --git a/deploy/storageos-operators.subscription.yaml b/deploy/storageos-operators.subscription.yaml index 9a5697ddc..0e00fba96 100644 --- a/deploy/storageos-operators.subscription.yaml +++ b/deploy/storageos-operators.subscription.yaml @@ -7,4 +7,4 @@ spec: source: storageos-catalog sourceNamespace: olm name: storageos - channel: alpha + channel: stable diff --git a/pkg/apis/addtoscheme_storageos_v1.go b/pkg/apis/addtoscheme_storageos_v1.go new file mode 100644 index 000000000..3e7395752 --- /dev/null +++ b/pkg/apis/addtoscheme_storageos_v1.go @@ -0,0 +1,10 @@ +package apis + +import ( + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" +) + +func init() { + // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back + AddToSchemes = append(AddToSchemes, storageosv1.SchemeBuilder.AddToScheme) +} diff --git a/pkg/apis/addtoscheme_storageos_v1alpha1.go b/pkg/apis/addtoscheme_storageos_v1alpha1.go deleted file mode 100644 index e812fb15a..000000000 --- a/pkg/apis/addtoscheme_storageos_v1alpha1.go +++ /dev/null @@ -1,10 +0,0 @@ -package apis - -import ( - "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" -) - -func init() { - // Register the types with the Scheme so the components can map objects to GroupVersionKinds and back - AddToSchemes = append(AddToSchemes, v1alpha1.SchemeBuilder.AddToScheme) -} diff --git a/pkg/apis/storageos/v1/doc.go b/pkg/apis/storageos/v1/doc.go new file mode 100644 index 000000000..eb130d3d5 --- /dev/null +++ b/pkg/apis/storageos/v1/doc.go @@ -0,0 +1,4 @@ +// Package v1 contains API Schema definitions for the cluster v1 API group +// +k8s:deepcopy-gen=package,register +// +groupName=storageos.com +package v1 diff --git a/pkg/apis/storageos/v1alpha1/job_types.go b/pkg/apis/storageos/v1/job_types.go similarity index 99% rename from pkg/apis/storageos/v1alpha1/job_types.go rename to pkg/apis/storageos/v1/job_types.go index 090ec7767..b27063672 100644 --- a/pkg/apis/storageos/v1alpha1/job_types.go +++ b/pkg/apis/storageos/v1/job_types.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 import ( corev1 "k8s.io/api/core/v1" diff --git a/pkg/apis/storageos/v1alpha1/register.go b/pkg/apis/storageos/v1/register.go similarity index 80% rename from pkg/apis/storageos/v1alpha1/register.go rename to pkg/apis/storageos/v1/register.go index bc073398a..52f964f7f 100644 --- a/pkg/apis/storageos/v1alpha1/register.go +++ b/pkg/apis/storageos/v1/register.go @@ -1,9 +1,9 @@ // NOTE: Boilerplate only. Ignore this file. -// Package v1alpha1 contains API Schema definitions for the cluster v1alpha1 API group +// Package v1 contains API Schema definitions for the cluster v1 API group // +k8s:deepcopy-gen=package,register // +groupName=cluster.storageos.com -package v1alpha1 +package v1 import ( "k8s.io/apimachinery/pkg/runtime/schema" @@ -12,7 +12,7 @@ import ( var ( // SchemeGroupVersion is group version used to register these objects - SchemeGroupVersion = schema.GroupVersion{Group: "storageos.com", Version: "v1alpha1"} + SchemeGroupVersion = schema.GroupVersion{Group: "storageos.com", Version: "v1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} diff --git a/pkg/apis/storageos/v1alpha1/storageoscluster_types.go b/pkg/apis/storageos/v1/storageoscluster_types.go similarity index 99% rename from pkg/apis/storageos/v1alpha1/storageoscluster_types.go rename to pkg/apis/storageos/v1/storageoscluster_types.go index a87ff45b2..4bca23fee 100644 --- a/pkg/apis/storageos/v1alpha1/storageoscluster_types.go +++ b/pkg/apis/storageos/v1/storageoscluster_types.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 import ( "fmt" diff --git a/pkg/apis/storageos/v1alpha1/storageosupgrade_types.go b/pkg/apis/storageos/v1/storageosupgrade_types.go similarity index 98% rename from pkg/apis/storageos/v1alpha1/storageosupgrade_types.go rename to pkg/apis/storageos/v1/storageosupgrade_types.go index 5b237bcd8..27884a8fa 100644 --- a/pkg/apis/storageos/v1alpha1/storageosupgrade_types.go +++ b/pkg/apis/storageos/v1/storageosupgrade_types.go @@ -1,4 +1,4 @@ -package v1alpha1 +package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/apis/storageos/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/storageos/v1/zz_generated.deepcopy.go similarity index 99% rename from pkg/apis/storageos/v1alpha1/zz_generated.deepcopy.go rename to pkg/apis/storageos/v1/zz_generated.deepcopy.go index b03127c5c..29a90612a 100644 --- a/pkg/apis/storageos/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/storageos/v1/zz_generated.deepcopy.go @@ -18,7 +18,7 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1alpha1 +package v1 import ( v1 "k8s.io/api/core/v1" diff --git a/pkg/apis/storageos/v1alpha1/doc.go b/pkg/apis/storageos/v1alpha1/doc.go deleted file mode 100644 index a8d63c141..000000000 --- a/pkg/apis/storageos/v1alpha1/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package v1alpha1 contains API Schema definitions for the cluster v1alpha1 API group -// +k8s:deepcopy-gen=package,register -// +groupName=storageos.com -package v1alpha1 diff --git a/pkg/controller/job/job_controller.go b/pkg/controller/job/job_controller.go index 560e7f336..ae3c2c44d 100644 --- a/pkg/controller/job/job_controller.go +++ b/pkg/controller/job/job_controller.go @@ -3,13 +3,13 @@ package job import ( "bytes" "context" + "fmt" "io" "log" "strings" "time" - "fmt" - storageosv1alpha1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -50,7 +50,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to primary resource Job - err = c.Watch(&source.Kind{Type: &storageosv1alpha1.Job{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(&source.Kind{Type: &storageosv1.Job{}}, &handler.EnqueueRequestForObject{}) if err != nil { return err } @@ -58,7 +58,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { // Watch for changes to secondary resource DaemonSet and requeue the owner Job err = c.Watch(&source.Kind{Type: &appsv1.DaemonSet{}}, &handler.EnqueueRequestForOwner{ IsController: true, - OwnerType: &storageosv1alpha1.Job{}, + OwnerType: &storageosv1.Job{}, }) if err != nil { return err @@ -93,7 +93,7 @@ func (r *ReconcileJob) Reconcile(request reconcile.Request) (reconcile.Result, e reconcileResult := reconcile.Result{RequeueAfter: reconcilePeriod} // Fetch the Job instance - instance := &storageosv1alpha1.Job{} + instance := &storageosv1.Job{} err := r.client.Get(context.TODO(), request.NamespacedName, instance) if err != nil { if errors.IsNotFound(err) { @@ -164,7 +164,7 @@ func (r *ReconcileJob) Reconcile(request reconcile.Request) (reconcile.Result, e // checkPods checks the logs of all pods with the given label selector for the // completionWord and published a "JobCompleted" event when all the pods have // completed their task. -func checkPods(client kubernetes.Interface, cr *storageosv1alpha1.Job, recorder record.EventRecorder) (bool, error) { +func checkPods(client kubernetes.Interface, cr *storageosv1.Job, recorder record.EventRecorder) (bool, error) { podListOpts := metav1.ListOptions{ LabelSelector: cr.Spec.GetLabelSelector(), } @@ -225,7 +225,7 @@ func getPlainLogs(req *restclient.Request) (string, error) { } // newPodForCR returns a busybox pod with the same name/namespace as the cr -func newDaemonSetForCR(cr *storageosv1alpha1.Job) (*appsv1.DaemonSet, error) { +func newDaemonSetForCR(cr *storageosv1.Job) (*appsv1.DaemonSet, error) { defaultLabels := map[string]string{ "daemonset": cr.Name + "-daemonset-job", "job": cr.Name, @@ -291,7 +291,7 @@ func newDaemonSetForCR(cr *storageosv1alpha1.Job) (*appsv1.DaemonSet, error) { if len(tolerations) > 0 { dset.Spec.Template.Spec.Tolerations = cr.Spec.Tolerations } - + // Add node affinity if defined. if len(cr.Spec.NodeSelectorTerms) > 0 { dset.Spec.Template.Spec.Affinity = &corev1.Affinity{NodeAffinity: &corev1.NodeAffinity{ diff --git a/pkg/controller/storageoscluster/cluster.go b/pkg/controller/storageoscluster/cluster.go index bdc1fd9e2..671b647c1 100644 --- a/pkg/controller/storageoscluster/cluster.go +++ b/pkg/controller/storageoscluster/cluster.go @@ -1,7 +1,7 @@ package storageoscluster import ( - storageosv1alpha1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" "github.com/storageos/cluster-operator/pkg/storageos" ) @@ -9,7 +9,7 @@ import ( // cluster and the deployment together, ensuring deployment interacts with the // right cluster resource. type StorageOSCluster struct { - cluster *storageosv1alpha1.StorageOSCluster + cluster *storageosv1.StorageOSCluster // deployment implements storageoscluster.Deployment interface. This is // cached for a cluster to avoid recreating it without any change to the // cluster object. Every new cluster will create its unique deployment. @@ -17,7 +17,7 @@ type StorageOSCluster struct { } // NewStorageOSCluster creates a new StorageOSCluster object. -func NewStorageOSCluster(cluster *storageosv1alpha1.StorageOSCluster) *StorageOSCluster { +func NewStorageOSCluster(cluster *storageosv1.StorageOSCluster) *StorageOSCluster { return &StorageOSCluster{cluster: cluster} } @@ -34,7 +34,7 @@ func (c *StorageOSCluster) SetDeployment(r *ReconcileStorageOSCluster) { // IsCurrentCluster compares the cluster attributes to check if the given // cluster is the same as the current cluster. -func (c *StorageOSCluster) IsCurrentCluster(cluster *storageosv1alpha1.StorageOSCluster) bool { +func (c *StorageOSCluster) IsCurrentCluster(cluster *storageosv1.StorageOSCluster) bool { if (c.cluster.GetName() == cluster.GetName()) && (c.cluster.GetNamespace() == cluster.GetNamespace()) { return true diff --git a/pkg/controller/storageoscluster/storageoscluster_controller.go b/pkg/controller/storageoscluster/storageoscluster_controller.go index c2925fc38..ec78ebc77 100644 --- a/pkg/controller/storageoscluster/storageoscluster_controller.go +++ b/pkg/controller/storageoscluster/storageoscluster_controller.go @@ -7,7 +7,7 @@ import ( "strings" "time" - storageosv1alpha1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" @@ -56,7 +56,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to primary resource StorageOSCluster - err = c.Watch(&source.Kind{Type: &storageosv1alpha1.StorageOSCluster{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(&source.Kind{Type: &storageosv1.StorageOSCluster{}}, &handler.EnqueueRequestForObject{}) if err != nil { return err } @@ -79,14 +79,14 @@ type ReconcileStorageOSCluster struct { // SetCurrentClusterIfNone checks if there's any existing current cluster and // sets a new current cluster if it wasn't set before. -func (r *ReconcileStorageOSCluster) SetCurrentClusterIfNone(cluster *storageosv1alpha1.StorageOSCluster) { +func (r *ReconcileStorageOSCluster) SetCurrentClusterIfNone(cluster *storageosv1.StorageOSCluster) { if r.currentCluster == nil { r.SetCurrentCluster(cluster) } } // SetCurrentCluster sets the currently active cluster in the controller. -func (r *ReconcileStorageOSCluster) SetCurrentCluster(cluster *storageosv1alpha1.StorageOSCluster) { +func (r *ReconcileStorageOSCluster) SetCurrentCluster(cluster *storageosv1.StorageOSCluster) { r.currentCluster = NewStorageOSCluster(cluster) } @@ -106,7 +106,7 @@ func (r *ReconcileStorageOSCluster) Reconcile(request reconcile.Request) (reconc reconcileResult := reconcile.Result{RequeueAfter: reconcilePeriod} // Fetch the StorageOSCluster instance - instance := &storageosv1alpha1.StorageOSCluster{} + instance := &storageosv1.StorageOSCluster{} err := r.client.Get(context.TODO(), request.NamespacedName, instance) if err != nil { if errors.IsNotFound(err) { @@ -154,7 +154,7 @@ func (r *ReconcileStorageOSCluster) Reconcile(request reconcile.Request) (reconc return reconcileResult, nil } -func (r *ReconcileStorageOSCluster) reconcile(m *storageosv1alpha1.StorageOSCluster) error { +func (r *ReconcileStorageOSCluster) reconcile(m *storageosv1.StorageOSCluster) error { if m.Spec.Pause { // Do not reconcile, the operator is paused for the cluster. return nil @@ -251,7 +251,7 @@ func (r *ReconcileStorageOSCluster) reconcile(m *storageosv1alpha1.StorageOSClus // generateJoinToken performs node selection based on NodeSelectorTerms if // specified, and forms a join token by combining the node IPs. -func (r *ReconcileStorageOSCluster) generateJoinToken(m *storageosv1alpha1.StorageOSCluster) (string, error) { +func (r *ReconcileStorageOSCluster) generateJoinToken(m *storageosv1.StorageOSCluster) (string, error) { // Get a new list of all the nodes. nodeList := storageos.NodeList() if err := r.client.List(context.Background(), &client.ListOptions{}, nodeList); err != nil { diff --git a/pkg/controller/storageosupgrade/storageosupgrade_controller.go b/pkg/controller/storageosupgrade/storageosupgrade_controller.go index e6b48fa7d..a8405a94f 100644 --- a/pkg/controller/storageosupgrade/storageosupgrade_controller.go +++ b/pkg/controller/storageosupgrade/storageosupgrade_controller.go @@ -7,7 +7,7 @@ import ( "strings" "time" - storageosv1alpha1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" @@ -55,7 +55,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error { } // Watch for changes to primary resource StorageOSUpgrade - err = c.Watch(&source.Kind{Type: &storageosv1alpha1.StorageOSUpgrade{}}, &handler.EnqueueRequestForObject{}) + err = c.Watch(&source.Kind{Type: &storageosv1.StorageOSUpgrade{}}, &handler.EnqueueRequestForObject{}) if err != nil { return err } @@ -71,28 +71,28 @@ type ReconcileStorageOSUpgrade struct { // that reads objects from the cache and writes to the apiserver client client.Client scheme *runtime.Scheme - currentUpgrade *storageosv1alpha1.StorageOSUpgrade - currentCluster *storageosv1alpha1.StorageOSCluster - imagePuller *storageosv1alpha1.Job + currentUpgrade *storageosv1.StorageOSUpgrade + currentCluster *storageosv1.StorageOSCluster + imagePuller *storageosv1.Job recorder record.EventRecorder } // SetCurrentUpgradeIfNone checks if there's any existing current upgrade and // sets a new current upgrade if it wasn't set before. -func (r *ReconcileStorageOSUpgrade) SetCurrentUpgradeIfNone(upgrade *storageosv1alpha1.StorageOSUpgrade) { +func (r *ReconcileStorageOSUpgrade) SetCurrentUpgradeIfNone(upgrade *storageosv1.StorageOSUpgrade) { if r.currentUpgrade == nil { r.SetCurrentUpgrade(upgrade) } } // SetCurrentUpgrade sets the currently active upgrade in the controller. -func (r *ReconcileStorageOSUpgrade) SetCurrentUpgrade(upgrade *storageosv1alpha1.StorageOSUpgrade) { +func (r *ReconcileStorageOSUpgrade) SetCurrentUpgrade(upgrade *storageosv1.StorageOSUpgrade) { r.currentUpgrade = upgrade } // IsCurrentUpgrade compares a given upgrade with the current cluster to check // if they are the same. -func (r *ReconcileStorageOSUpgrade) IsCurrentUpgrade(upgrade *storageosv1alpha1.StorageOSUpgrade) bool { +func (r *ReconcileStorageOSUpgrade) IsCurrentUpgrade(upgrade *storageosv1.StorageOSUpgrade) bool { if upgrade == nil { return false } @@ -112,16 +112,16 @@ func (r *ReconcileStorageOSUpgrade) ResetCurrentUpgrade(request reconcile.Reques } // findCurrentCluster finds the running cluster. -func (r *ReconcileStorageOSUpgrade) findCurrentCluster() (*storageosv1alpha1.StorageOSCluster, error) { - clusterList := &storageosv1alpha1.StorageOSClusterList{} +func (r *ReconcileStorageOSUpgrade) findCurrentCluster() (*storageosv1.StorageOSCluster, error) { + clusterList := &storageosv1.StorageOSClusterList{} if err := r.client.List(context.TODO(), &client.ListOptions{}, clusterList); err != nil { return nil, fmt.Errorf("failed to list clusters: %v", err) } - var currentCluster *storageosv1alpha1.StorageOSCluster + var currentCluster *storageosv1.StorageOSCluster for _, cluster := range clusterList.Items { // The cluster with Phase "Running" is the only active cluster. - if cluster.Status.Phase == storageosv1alpha1.ClusterPhaseRunning { + if cluster.Status.Phase == storageosv1.ClusterPhaseRunning { currentCluster = &cluster break } @@ -217,7 +217,7 @@ func (r *ReconcileStorageOSUpgrade) Reconcile(request reconcile.Request) (reconc reconcileResult := reconcile.Result{RequeueAfter: reconcilePeriod} // Fetch the StorageOSUpgrade instance - instance := &storageosv1alpha1.StorageOSUpgrade{} + instance := &storageosv1.StorageOSUpgrade{} err := r.client.Get(context.TODO(), request.NamespacedName, instance) if err != nil { if errors.IsNotFound(err) { @@ -458,7 +458,7 @@ func (r *ReconcileStorageOSUpgrade) DisableClusterMaintenance() error { } // newJobForCR returns a job with the same name/namespace as the cr. -func newJobForCR(cr *storageosv1alpha1.StorageOSUpgrade) *batchv1.Job { +func newJobForCR(cr *storageosv1.StorageOSUpgrade) *batchv1.Job { labels := map[string]string{ "app": cr.Name, } @@ -494,7 +494,7 @@ func newJobForCR(cr *storageosv1alpha1.StorageOSUpgrade) *batchv1.Job { } } -func newServiceAccountForCR(name string, cr *storageosv1alpha1.StorageOSUpgrade) *corev1.ServiceAccount { +func newServiceAccountForCR(name string, cr *storageosv1.StorageOSUpgrade) *corev1.ServiceAccount { return &corev1.ServiceAccount{ TypeMeta: metav1.TypeMeta{ APIVersion: "v1", @@ -546,13 +546,13 @@ func newClusterRole(name string, rules []rbacv1.PolicyRule) *rbacv1.ClusterRole // newImagePullJob creates a jobs.storageos.com instance for pulling container // image and return. It uses the cluster instance to set the NodeSelectorTerm, // in order to pull the image only on the nodes that are part of the cluster. -func newImagePullJob(cr *storageosv1alpha1.StorageOSUpgrade, cluster *storageosv1alpha1.StorageOSCluster) *storageosv1alpha1.Job { - return &storageosv1alpha1.Job{ +func newImagePullJob(cr *storageosv1.StorageOSUpgrade, cluster *storageosv1.StorageOSCluster) *storageosv1.Job { + return &storageosv1.Job{ ObjectMeta: metav1.ObjectMeta{ Name: cr.Name + "-image-puller", Namespace: cr.Namespace, }, - Spec: storageosv1alpha1.JobSpec{ + Spec: storageosv1.JobSpec{ Image: operatorImage, Args: []string{"docker-puller.sh", cr.Spec.NewImage}, MountPath: "/var/run", diff --git a/pkg/storageos/deploy.go b/pkg/storageos/deploy.go index 907654616..e0ee48cb2 100644 --- a/pkg/storageos/deploy.go +++ b/pkg/storageos/deploy.go @@ -6,7 +6,7 @@ import ( "log" "github.com/blang/semver" - api "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -367,7 +367,7 @@ func addOwnerRefToObject(obj metav1.Object, ownerRef metav1.OwnerReference) { obj.SetOwnerReferences(append(obj.GetOwnerReferences(), ownerRef)) } -func asOwner(m *api.StorageOSCluster) metav1.OwnerReference { +func asOwner(m *storageosv1.StorageOSCluster) metav1.OwnerReference { trueVar := true return metav1.OwnerReference{ APIVersion: m.APIVersion, diff --git a/pkg/storageos/deploy_test.go b/pkg/storageos/deploy_test.go index 496e93b84..a09e7dc5a 100644 --- a/pkg/storageos/deploy_test.go +++ b/pkg/storageos/deploy_test.go @@ -21,12 +21,12 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/fake" storageosapis "github.com/storageos/cluster-operator/pkg/apis" - api "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + api "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" ) var gvk = schema.GroupVersionKind{ Group: "storageos.com", - Version: "v1alpha1", + Version: "v1", Kind: "StorageOSCluster", } diff --git a/pkg/storageos/deployment.go b/pkg/storageos/deployment.go index 398bd9118..cfbe304a2 100644 --- a/pkg/storageos/deployment.go +++ b/pkg/storageos/deployment.go @@ -1,7 +1,7 @@ package storageos import ( - api "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" @@ -11,7 +11,7 @@ import ( // resource creation and update. type Deployment struct { client client.Client - stos *api.StorageOSCluster + stos *storageosv1.StorageOSCluster recorder record.EventRecorder k8sVersion string scheme *runtime.Scheme @@ -20,7 +20,7 @@ type Deployment struct { // NewDeployment creates a new Deployment given a k8c client, storageos manifest // and an event broadcast recorder. -func NewDeployment(client client.Client, stos *api.StorageOSCluster, recorder record.EventRecorder, scheme *runtime.Scheme, version string, update bool) *Deployment { +func NewDeployment(client client.Client, stos *storageosv1.StorageOSCluster, recorder record.EventRecorder, scheme *runtime.Scheme, version string, update bool) *Deployment { return &Deployment{ client: client, stos: stos, diff --git a/pkg/storageos/update_status.go b/pkg/storageos/update_status.go index 4c7a6e2cd..900a618a5 100644 --- a/pkg/storageos/update_status.go +++ b/pkg/storageos/update_status.go @@ -10,13 +10,13 @@ import ( "strings" "time" - api "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" storageosapi "github.com/storageos/go-api" "github.com/storageos/go-api/types" "k8s.io/api/core/v1" ) -func (s *Deployment) updateStorageOSStatus(status *api.StorageOSClusterStatus) error { +func (s *Deployment) updateStorageOSStatus(status *storageosv1.StorageOSClusterStatus) error { if reflect.DeepEqual(s.stos.Status, *status) { return nil } @@ -42,14 +42,14 @@ func (s *Deployment) updateStorageOSStatus(status *api.StorageOSClusterStatus) e // getStorageOSStatus queries health of all the nodes in the join token and // returns the cluster status. -func (s *Deployment) getStorageOSStatus() (*api.StorageOSClusterStatus, error) { +func (s *Deployment) getStorageOSStatus() (*storageosv1.StorageOSClusterStatus, error) { nodeIPs := strings.Split(s.stos.Spec.Join, ",") totalNodes := len(nodeIPs) readyNodes := 0 - healthStatus := make(map[string]api.NodeHealth) - memberStatus := new(api.MembersStatus) + healthStatus := make(map[string]storageosv1.NodeHealth) + memberStatus := new(storageosv1.MembersStatus) for _, node := range nodeIPs { if status, err := getNodeHealth(node, 1); err == nil { @@ -65,12 +65,12 @@ func (s *Deployment) getStorageOSStatus() (*api.StorageOSClusterStatus, error) { } } - phase := api.ClusterPhaseInitial + phase := storageosv1.ClusterPhaseInitial if readyNodes == totalNodes { - phase = api.ClusterPhaseRunning + phase = storageosv1.ClusterPhaseRunning } - return &api.StorageOSClusterStatus{ + return &storageosv1.StorageOSClusterStatus{ Phase: phase, Nodes: nodeIPs, NodeHealthStatus: healthStatus, @@ -79,7 +79,7 @@ func (s *Deployment) getStorageOSStatus() (*api.StorageOSClusterStatus, error) { }, nil } -func isHealthy(health *api.NodeHealth) bool { +func isHealthy(health *storageosv1.NodeHealth) bool { if health.DirectfsInitiator+health.Director+health.KV+health.KVWrite+ health.Nats+health.Presentation+health.Rdb == strings.Repeat("alive", 7) { return true @@ -87,7 +87,7 @@ func isHealthy(health *api.NodeHealth) bool { return false } -func getNodeHealth(address string, timeout int) (*api.NodeHealth, error) { +func getNodeHealth(address string, timeout int) (*storageosv1.NodeHealth, error) { healthEndpointFormat := "http://%s:%s/v1/" + storageosapi.HealthAPIPrefix ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout)) @@ -111,7 +111,7 @@ func getNodeHealth(address string, timeout int) (*api.NodeHealth, error) { return nil, err } - return &api.NodeHealth{ + return &storageosv1.NodeHealth{ DirectfsInitiator: healthStatus.Submodules.DirectFSClient.Status, Director: healthStatus.Submodules.Director.Status, KV: healthStatus.Submodules.KV.Status, diff --git a/test/e2e/clusterCSI_test.go b/test/e2e/clusterCSI_test.go index 96a11e2e9..00e56efbe 100644 --- a/test/e2e/clusterCSI_test.go +++ b/test/e2e/clusterCSI_test.go @@ -8,7 +8,7 @@ import ( "testing" framework "github.com/operator-framework/operator-sdk/pkg/test" - storageos "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageos "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" deploy "github.com/storageos/cluster-operator/pkg/storageos" testutil "github.com/storageos/cluster-operator/test/e2e/util" corev1 "k8s.io/api/core/v1" diff --git a/test/e2e/clusterInTreePlugin_test.go b/test/e2e/clusterInTreePlugin_test.go index ff30c560c..7018adb6b 100644 --- a/test/e2e/clusterInTreePlugin_test.go +++ b/test/e2e/clusterInTreePlugin_test.go @@ -7,7 +7,7 @@ import ( "testing" framework "github.com/operator-framework/operator-sdk/pkg/test" - storageos "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageos "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" testutil "github.com/storageos/cluster-operator/test/e2e/util" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/test/e2e/util/cluster.go b/test/e2e/util/cluster.go index f7dbcd609..936eef35b 100644 --- a/test/e2e/util/cluster.go +++ b/test/e2e/util/cluster.go @@ -9,7 +9,7 @@ import ( framework "github.com/operator-framework/operator-sdk/pkg/test" "github.com/operator-framework/operator-sdk/pkg/test/e2eutil" "github.com/storageos/cluster-operator/pkg/apis" - storageos "github.com/storageos/cluster-operator/pkg/apis/storageos/v1alpha1" + storageos "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -32,7 +32,7 @@ func NewStorageOSCluster(namespace string, clusterSpec storageos.StorageOSCluste return &storageos.StorageOSCluster{ TypeMeta: metav1.TypeMeta{ Kind: "StorageOSCluster", - APIVersion: "storageos.com/v1alpha1", + APIVersion: "storageos.com/v1", }, ObjectMeta: metav1.ObjectMeta{ Name: "example-storageos", @@ -50,7 +50,7 @@ func SetupOperator(t *testing.T, ctx *framework.TestCtx) { clusterList := &storageos.StorageOSClusterList{ TypeMeta: metav1.TypeMeta{ Kind: "StorageOSCluster", - APIVersion: "storageos.com/v1alpha1", + APIVersion: "storageos.com/v1", }, } err := framework.AddToFrameworkScheme(apis.AddToScheme, clusterList)