diff --git a/pkg/operator/edgefs/cluster/cluster.go b/pkg/operator/edgefs/cluster/cluster.go index 10253746e..da9900f69 100644 --- a/pkg/operator/edgefs/cluster/cluster.go +++ b/pkg/operator/edgefs/cluster/cluster.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "reflect" "sort" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookv1alpha2 "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/edgefs/cluster/mgr" @@ -51,14 +51,14 @@ const ( type cluster struct { context *clusterd.Context Namespace string - Spec edgefsv1alpha1.ClusterSpec + Spec edgefsv1beta1.ClusterSpec ownerRef metav1.OwnerReference targets *target.Cluster mgrs *mgr.Cluster stopCh chan struct{} } -func newCluster(c *edgefsv1alpha1.Cluster, context *clusterd.Context) *cluster { +func newCluster(c *edgefsv1beta1.Cluster, context *clusterd.Context) *cluster { return &cluster{ context: context, @@ -157,7 +157,7 @@ func (c *cluster) createInstance(rookImage string) error { return nil } -func (c *cluster) prepareHostNodes(rookImage string, deploymentConfig edgefsv1alpha1.ClusterDeploymentConfig) error { +func (c *cluster) prepareHostNodes(rookImage string, deploymentConfig edgefsv1beta1.ClusterDeploymentConfig) error { prep := prepare.New(c.context, c.Namespace, "latest", c.Spec.ServiceAccount, edgefsv1beta1.GetPrepareAnnotations(c.Spec.Annotations), edgefsv1beta1.GetPreparePlacement(c.Spec.Placement), v1.ResourceRequirements{}, c.ownerRef) @@ -233,7 +233,7 @@ func (c *cluster) validateClusterSpec() error { return nil } -func clusterChanged(oldCluster, newCluster edgefsv1alpha1.ClusterSpec) bool { +func clusterChanged(oldCluster, newCluster edgefsv1beta1.ClusterSpec) bool { changeFound := false oldStorage := oldCluster.Storage newStorage := newCluster.Storage diff --git a/pkg/operator/edgefs/cluster/configmap.go b/pkg/operator/edgefs/cluster/configmap.go index 02539b9ed..a2ed3ceff 100644 --- a/pkg/operator/edgefs/cluster/configmap.go +++ b/pkg/operator/edgefs/cluster/configmap.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -19,7 +19,7 @@ package cluster import ( "encoding/json" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/operator/edgefs/cluster/target" "github.com/rook/rook/pkg/operator/k8sutil" @@ -38,9 +38,9 @@ const ( // As we relying on StatefulSet, we want to build global ConfigMap shared // to all the nodes in the cluster. This way configuration is simplified and // available to all subcomponents at any point it time. -func (c *cluster) createClusterConfigMap(nodes []rookalpha.Node, deploymentConfig edgefsv1alpha1.ClusterDeploymentConfig, resurrect bool) error { +func (c *cluster) createClusterConfigMap(nodes []rookalpha.Node, deploymentConfig edgefsv1beta1.ClusterDeploymentConfig, resurrect bool) error { - cm := make(map[string]edgefsv1alpha1.SetupNode) + cm := make(map[string]edgefsv1beta1.SetupNode) dnsRecords := make([]string, len(nodes)) for i := 0; i < len(nodes); i++ { @@ -70,7 +70,7 @@ func (c *cluster) createClusterConfigMap(nodes []rookalpha.Node, deploymentConfi rtlfsDevices := devConfig.Rtlfs.Devices rtlfsAutoDetectPath := "" - if deploymentConfig.DeploymentType == edgefsv1alpha1.DeploymentAutoRtlfs && + if deploymentConfig.DeploymentType == edgefsv1beta1.DeploymentAutoRtlfs && !devConfig.IsGatewayNode { rtlfsAutoDetectPath = "/data" } @@ -86,8 +86,8 @@ func (c *cluster) createClusterConfigMap(nodes []rookalpha.Node, deploymentConfi // same as before. Resurrection is "best effort" feature, we cannot // guarnatee that cluster can be reconfigured, but at least we do try. - rtDevices = make([]edgefsv1alpha1.RTDevice, 0) - rtlfsDevices = make([]edgefsv1alpha1.RtlfsDevice, 0) + rtDevices = make([]edgefsv1beta1.RTDevice, 0) + rtlfsDevices = make([]edgefsv1beta1.RtlfsDevice, 0) } // Set failureDomain to 2 if current node's zone > 0 failureDomain := 1 @@ -95,37 +95,37 @@ func (c *cluster) createClusterConfigMap(nodes []rookalpha.Node, deploymentConfi failureDomain = 2 } - nodeConfig := edgefsv1alpha1.SetupNode{ - Ccow: edgefsv1alpha1.CcowConf{ - Trlog: edgefsv1alpha1.CcowTrlog{ + nodeConfig := edgefsv1beta1.SetupNode{ + Ccow: edgefsv1beta1.CcowConf{ + Trlog: edgefsv1beta1.CcowTrlog{ Interval: defaultTrlogProcessingInterval, }, - Tenant: edgefsv1alpha1.CcowTenant{ + Tenant: edgefsv1beta1.CcowTenant{ FailureDomain: failureDomain, }, - Network: edgefsv1alpha1.CcowNetwork{ + Network: edgefsv1beta1.CcowNetwork{ BrokerInterfaces: brokerIfName, ServerUnixSocket: "/opt/nedge/var/run/sock/ccowd.sock", }, }, - Ccowd: edgefsv1alpha1.CcowdConf{ - BgConfig: edgefsv1alpha1.CcowdBgConfig{ + Ccowd: edgefsv1beta1.CcowdConf{ + BgConfig: edgefsv1beta1.CcowdBgConfig{ TrlogDeleteAfterHours: defaultTrlogKeepDays * 24, }, Zone: devConfig.Zone, - Network: edgefsv1alpha1.CcowdNetwork{ + Network: edgefsv1beta1.CcowdNetwork{ ServerInterfaces: serverIfName, ServerUnixSocket: "/opt/nedge/var/run/sock/ccowd.sock", }, Transport: []string{deploymentConfig.TransportKey}, }, - Auditd: edgefsv1alpha1.AuditdConf{ + Auditd: edgefsv1beta1.AuditdConf{ IsAggregator: 0, }, - Rtrd: edgefsv1alpha1.RTDevices{ + Rtrd: edgefsv1beta1.RTDevices{ Devices: rtDevices, }, - Rtlfs: edgefsv1alpha1.RtlfsDevices{ + Rtlfs: edgefsv1beta1.RtlfsDevices{ Devices: rtlfsDevices, }, Ipv4Autodetect: 1, diff --git a/pkg/operator/edgefs/cluster/controller.go b/pkg/operator/edgefs/cluster/controller.go index bb0e49adc..948c017bf 100644 --- a/pkg/operator/edgefs/cluster/controller.go +++ b/pkg/operator/edgefs/cluster/controller.go @@ -26,7 +26,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/edgefs/iscsi" "github.com/rook/rook/pkg/operator/edgefs/isgw" @@ -62,10 +62,10 @@ const ( var ClusterResource = opkit.CustomResource{ Name: CustomResourceName, Plural: CustomResourceNamePlural, - Group: edgefsv1alpha1.CustomResourceGroup, - Version: edgefsv1alpha1.Version, + Group: edgefsv1beta1.CustomResourceGroup, + Version: edgefsv1beta1.Version, Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(edgefsv1alpha1.Cluster{}).Name(), + Kind: reflect.TypeOf(edgefsv1beta1.Cluster{}).Name(), } type ClusterController struct { @@ -104,8 +104,8 @@ func (c *ClusterController) StartWatch(namespace string, stopCh chan struct{}) e } logger.Infof("start watching edgefs clusters in all namespaces") - watcher := opkit.NewWatcher(ClusterResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient()) - go watcher.Watch(&edgefsv1alpha1.Cluster{}, stopCh) + watcher := opkit.NewWatcher(ClusterResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1beta1().RESTClient()) + go watcher.Watch(&edgefsv1beta1.Cluster{}, stopCh) return nil } @@ -118,7 +118,7 @@ func (c *ClusterController) StopWatch() { } func (c *ClusterController) onAdd(obj interface{}) { - clusterObj := obj.(*edgefsv1alpha1.Cluster).DeepCopy() + clusterObj := obj.(*edgefsv1beta1.Cluster).DeepCopy() logger.Infof("new cluster %s added to namespace %s", clusterObj.Name, clusterObj.Namespace) cluster := newCluster(clusterObj, c.context) @@ -135,7 +135,7 @@ func (c *ClusterController) onAdd(obj interface{}) { if c.devicesInUse && cluster.Spec.Storage.AnyUseAllDevices() { message := "using all devices in more than one namespace not supported" logger.Error(message) - if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1alpha1.ClusterStateError, message); err != nil { + if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1beta1.ClusterStateError, message); err != nil { logger.Errorf("failed to update cluster status in namespace %s: %+v", cluster.Namespace, err) } return @@ -147,7 +147,7 @@ func (c *ClusterController) onAdd(obj interface{}) { // Start the Rook cluster components. Retry several times in case of failure. err := wait.Poll(clusterCreateInterval, clusterCreateTimeout, func() (bool, error) { - if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1alpha1.ClusterStateCreating, ""); err != nil { + if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1beta1.ClusterStateCreating, ""); err != nil { logger.Errorf("failed to update cluster status in namespace %s: %+v", cluster.Namespace, err) return false, nil } @@ -159,7 +159,7 @@ func (c *ClusterController) onAdd(obj interface{}) { } // cluster is created, update the cluster CRD status now - if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1alpha1.ClusterStateCreated, ""); err != nil { + if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1beta1.ClusterStateCreated, ""); err != nil { logger.Errorf("failed to update cluster status in namespace %s: %+v", cluster.Namespace, err) return false, nil } @@ -169,7 +169,7 @@ func (c *ClusterController) onAdd(obj interface{}) { if err != nil { message := fmt.Sprintf("giving up creating cluster in namespace %s after %s", cluster.Namespace, clusterCreateTimeout) logger.Error(message) - if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1alpha1.ClusterStateError, message); err != nil { + if err := c.updateClusterStatus(clusterObj.Namespace, clusterObj.Name, edgefsv1beta1.ClusterStateError, message); err != nil { logger.Errorf("failed to update cluster status in namespace %s: %+v", cluster.Namespace, err) } return @@ -181,7 +181,7 @@ func (c *ClusterController) onAdd(obj interface{}) { NFSController := nfs.NewNFSController(c.context, c.containerImage, isHostNetworkDefined(cluster.Spec.Network), cluster.Spec.DataDirHostPath, cluster.Spec.DataVolumeSize, - edgefsv1alpha1.GetTargetPlacement(cluster.Spec.Placement), + edgefsv1beta1.GetTargetPlacement(cluster.Spec.Placement), cluster.Spec.Resources, cluster.Spec.ResourceProfile, cluster.ownerRef) @@ -191,7 +191,7 @@ func (c *ClusterController) onAdd(obj interface{}) { S3Controller := s3.NewS3Controller(c.context, c.containerImage, isHostNetworkDefined(cluster.Spec.Network), cluster.Spec.DataDirHostPath, cluster.Spec.DataVolumeSize, - edgefsv1alpha1.GetTargetPlacement(cluster.Spec.Placement), + edgefsv1beta1.GetTargetPlacement(cluster.Spec.Placement), cluster.Spec.Resources, cluster.Spec.ResourceProfile, cluster.ownerRef) @@ -201,7 +201,7 @@ func (c *ClusterController) onAdd(obj interface{}) { SWIFTController := swift.NewSWIFTController(c.context, c.containerImage, isHostNetworkDefined(cluster.Spec.Network), cluster.Spec.DataDirHostPath, cluster.Spec.DataVolumeSize, - edgefsv1alpha1.GetTargetPlacement(cluster.Spec.Placement), + edgefsv1beta1.GetTargetPlacement(cluster.Spec.Placement), cluster.Spec.Resources, cluster.Spec.ResourceProfile, cluster.ownerRef) @@ -211,7 +211,7 @@ func (c *ClusterController) onAdd(obj interface{}) { S3XController := s3x.NewS3XController(c.context, c.containerImage, isHostNetworkDefined(cluster.Spec.Network), cluster.Spec.DataDirHostPath, cluster.Spec.DataVolumeSize, - edgefsv1alpha1.GetTargetPlacement(cluster.Spec.Placement), + edgefsv1beta1.GetTargetPlacement(cluster.Spec.Placement), cluster.Spec.Resources, cluster.Spec.ResourceProfile, cluster.ownerRef) @@ -221,7 +221,7 @@ func (c *ClusterController) onAdd(obj interface{}) { ISCSIController := iscsi.NewISCSIController(c.context, c.containerImage, isHostNetworkDefined(cluster.Spec.Network), cluster.Spec.DataDirHostPath, cluster.Spec.DataVolumeSize, - edgefsv1alpha1.GetTargetPlacement(cluster.Spec.Placement), + edgefsv1beta1.GetTargetPlacement(cluster.Spec.Placement), cluster.Spec.Resources, cluster.Spec.ResourceProfile, cluster.ownerRef) @@ -231,7 +231,7 @@ func (c *ClusterController) onAdd(obj interface{}) { ISGWController := isgw.NewISGWController(c.context, c.containerImage, isHostNetworkDefined(cluster.Spec.Network), cluster.Spec.DataDirHostPath, cluster.Spec.DataVolumeSize, - edgefsv1alpha1.GetTargetPlacement(cluster.Spec.Placement), + edgefsv1beta1.GetTargetPlacement(cluster.Spec.Placement), cluster.Spec.Resources, cluster.Spec.ResourceProfile, cluster.ownerRef) @@ -245,8 +245,8 @@ func (c *ClusterController) onAdd(obj interface{}) { } func (c *ClusterController) onUpdate(oldObj, newObj interface{}) { - oldCluster := oldObj.(*edgefsv1alpha1.Cluster).DeepCopy() - newCluster := newObj.(*edgefsv1alpha1.Cluster).DeepCopy() + oldCluster := oldObj.(*edgefsv1beta1.Cluster).DeepCopy() + newCluster := newObj.(*edgefsv1beta1.Cluster).DeepCopy() logger.Infof("update event for cluster %s", newCluster.Namespace) // Check if the cluster is being deleted. This code path is called when a finalizer is specified in the crd. @@ -293,7 +293,7 @@ func (c *ClusterController) onUpdate(oldObj, newObj interface{}) { if err != nil { message := fmt.Sprintf("giving up trying to update cluster in namespace %s after %s", cluster.Namespace, updateClusterTimeout) logger.Error(message) - if err := c.updateClusterStatus(newCluster.Namespace, newCluster.Name, edgefsv1alpha1.ClusterStateError, message); err != nil { + if err := c.updateClusterStatus(newCluster.Namespace, newCluster.Name, edgefsv1beta1.ClusterStateError, message); err != nil { logger.Errorf("failed to update cluster status in namespace %s: %+v", newCluster.Namespace, err) } return @@ -301,8 +301,8 @@ func (c *ClusterController) onUpdate(oldObj, newObj interface{}) { logger.Infof("cluster %s updated in namespace %s", newCluster.Name, newCluster.Namespace) } -func (c *ClusterController) handleUpdate(newClust *edgefsv1alpha1.Cluster, cluster *cluster) (bool, error) { - if err := c.updateClusterStatus(newClust.Namespace, newClust.Name, edgefsv1alpha1.ClusterStateUpdating, ""); err != nil { +func (c *ClusterController) handleUpdate(newClust *edgefsv1beta1.Cluster, cluster *cluster) (bool, error) { + if err := c.updateClusterStatus(newClust.Namespace, newClust.Name, edgefsv1beta1.ClusterStateUpdating, ""); err != nil { logger.Errorf("failed to update cluster status in namespace %s: %+v", newClust.Namespace, err) return false, nil } @@ -312,7 +312,7 @@ func (c *ClusterController) handleUpdate(newClust *edgefsv1alpha1.Cluster, clust return false, nil } - if err := c.updateClusterStatus(newClust.Namespace, newClust.Name, edgefsv1alpha1.ClusterStateCreated, ""); err != nil { + if err := c.updateClusterStatus(newClust.Namespace, newClust.Name, edgefsv1beta1.ClusterStateCreated, ""); err != nil { logger.Errorf("failed to update cluster status in namespace %s: %+v", newClust.Namespace, err) return false, nil } @@ -322,7 +322,7 @@ func (c *ClusterController) handleUpdate(newClust *edgefsv1alpha1.Cluster, clust } func (c *ClusterController) onDelete(obj interface{}) { - clust := obj.(*edgefsv1alpha1.Cluster).DeepCopy() + clust := obj.(*edgefsv1beta1.Cluster).DeepCopy() logger.Infof("delete event for cluster %s in namespace %s", clust.Name, clust.Namespace) @@ -339,7 +339,7 @@ func (c *ClusterController) onDelete(obj interface{}) { } } -func (c *ClusterController) handleDelete(clust *edgefsv1alpha1.Cluster, retryInterval time.Duration) error { +func (c *ClusterController) handleDelete(clust *edgefsv1beta1.Cluster, retryInterval time.Duration) error { cluster, ok := c.clusterMap[clust.Namespace] if !ok { @@ -361,33 +361,33 @@ func (c *ClusterController) handleDelete(clust *edgefsv1alpha1.Cluster, retryInt return nil } -func (c *ClusterController) updateClusterStatus(namespace, name string, state edgefsv1alpha1.ClusterState, message string) error { +func (c *ClusterController) updateClusterStatus(namespace, name string, state edgefsv1beta1.ClusterState, message string) error { // get the most recent cluster CRD object - cluster, err := c.context.RookClientset.EdgefsV1alpha1().Clusters(namespace).Get(name, metav1.GetOptions{}) + cluster, err := c.context.RookClientset.EdgefsV1beta1().Clusters(namespace).Get(name, metav1.GetOptions{}) if err != nil { return fmt.Errorf("failed to get cluster from namespace %s prior to updating its status: %+v", namespace, err) } // update the status on the retrieved cluster object - cluster.Status = edgefsv1alpha1.ClusterStatus{State: state, Message: message} - if _, err := c.context.RookClientset.EdgefsV1alpha1().Clusters(cluster.Namespace).Update(cluster); err != nil { + cluster.Status = edgefsv1beta1.ClusterStatus{State: state, Message: message} + if _, err := c.context.RookClientset.EdgefsV1beta1().Clusters(cluster.Namespace).Update(cluster); err != nil { return fmt.Errorf("failed to update cluster %s status: %+v", cluster.Namespace, err) } return nil } -func isHostNetworkDefined(hostNetworkSpec edgefsv1alpha1.NetworkSpec) bool { +func isHostNetworkDefined(hostNetworkSpec edgefsv1beta1.NetworkSpec) bool { if len(hostNetworkSpec.ServerIfName) > 0 || len(hostNetworkSpec.ServerIfName) > 0 { return true } return false } -func (c *ClusterController) addFinalizer(clust *edgefsv1alpha1.Cluster) error { +func (c *ClusterController) addFinalizer(clust *edgefsv1beta1.Cluster) error { // get the latest cluster object since we probably updated it before we got to this point (e.g. by updating its status) - clust, err := c.context.RookClientset.EdgefsV1alpha1().Clusters(clust.Namespace).Get(clust.Name, metav1.GetOptions{}) + clust, err := c.context.RookClientset.EdgefsV1beta1().Clusters(clust.Namespace).Get(clust.Name, metav1.GetOptions{}) if err != nil { return err } @@ -404,7 +404,7 @@ func (c *ClusterController) addFinalizer(clust *edgefsv1alpha1.Cluster) error { clust.Finalizers = append(clust.Finalizers, finalizerName) // update the crd - _, err = c.context.RookClientset.EdgefsV1alpha1().Clusters(clust.Namespace).Update(clust) + _, err = c.context.RookClientset.EdgefsV1beta1().Clusters(clust.Namespace).Update(clust) if err != nil { return fmt.Errorf("failed to add finalizer to cluster. %+v", err) } @@ -418,7 +418,7 @@ func (c *ClusterController) removeFinalizer(obj interface{}) { var objectMeta *metav1.ObjectMeta // first determine what type/version of cluster we are dealing with - if cl, ok := obj.(*edgefsv1alpha1.Cluster); ok { + if cl, ok := obj.(*edgefsv1beta1.Cluster); ok { fname = finalizerName objectMeta = &cl.ObjectMeta } else { @@ -445,8 +445,8 @@ func (c *ClusterController) removeFinalizer(obj interface{}) { retrySeconds := 5 * time.Second for i := 0; i < maxRetries; i++ { var err error - if cluster, ok := obj.(*edgefsv1alpha1.Cluster); ok { - _, err = c.context.RookClientset.EdgefsV1alpha1().Clusters(cluster.Namespace).Update(cluster) + if cluster, ok := obj.(*edgefsv1beta1.Cluster); ok { + _, err = c.context.RookClientset.EdgefsV1beta1().Clusters(cluster.Namespace).Update(cluster) } if err != nil { diff --git a/pkg/operator/edgefs/cluster/controller_test.go b/pkg/operator/edgefs/cluster/controller_test.go index 0ffc19c3e..9637fd2cd 100644 --- a/pkg/operator/edgefs/cluster/controller_test.go +++ b/pkg/operator/edgefs/cluster/controller_test.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -20,7 +20,7 @@ import ( "testing" "time" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" rookfake "github.com/rook/rook/pkg/client/clientset/versioned/fake" "github.com/rook/rook/pkg/clusterd" @@ -46,20 +46,20 @@ func TestClusterDelete(t *testing.T) { // create the cluster controller and tell it that the cluster has been deleted controller := NewClusterController(context, "") - clusterToDelete := &edgefsv1alpha1.Cluster{ObjectMeta: metav1.ObjectMeta{Namespace: clusterName}} + clusterToDelete := &edgefsv1beta1.Cluster{ObjectMeta: metav1.ObjectMeta{Namespace: clusterName}} controller.handleDelete(clusterToDelete, time.Microsecond) } func TestClusterChanged(t *testing.T) { // a new node added, should be a change - old := edgefsv1alpha1.ClusterSpec{ + old := edgefsv1beta1.ClusterSpec{ Storage: rookalpha.StorageScopeSpec{ Nodes: []rookalpha.Node{ {Name: "node1", Selection: rookalpha.Selection{Devices: []rookalpha.Device{{Name: "sda"}}}}, }, }, } - new := edgefsv1alpha1.ClusterSpec{ + new := edgefsv1beta1.ClusterSpec{ Storage: rookalpha.StorageScopeSpec{ Nodes: []rookalpha.Node{ {Name: "node1", Selection: rookalpha.Selection{Devices: []rookalpha.Device{{Name: "sda"}}}}, @@ -102,7 +102,7 @@ func TestRemoveFinalizer(t *testing.T) { // ***************************************** // start with a current version edgefs cluster // ***************************************** - cluster := &edgefsv1alpha1.Cluster{ + cluster := &edgefsv1beta1.Cluster{ ObjectMeta: metav1.ObjectMeta{ Name: "cluster-1893", Namespace: "namespace-6551", @@ -111,7 +111,7 @@ func TestRemoveFinalizer(t *testing.T) { } // create the cluster initially so it exists in the k8s api - cluster, err := context.RookClientset.EdgefsV1alpha1().Clusters(cluster.Namespace).Create(cluster) + cluster, err := context.RookClientset.EdgefsV1beta1().Clusters(cluster.Namespace).Create(cluster) assert.NoError(t, err) assert.Len(t, cluster.Finalizers, 1) @@ -119,7 +119,7 @@ func TestRemoveFinalizer(t *testing.T) { controller.removeFinalizer(cluster) // verify the finalier was removed - cluster, err = context.RookClientset.EdgefsV1alpha1().Clusters(cluster.Namespace).Get(cluster.Name, metav1.GetOptions{}) + cluster, err = context.RookClientset.EdgefsV1beta1().Clusters(cluster.Namespace).Get(cluster.Name, metav1.GetOptions{}) assert.NoError(t, err) assert.NotNil(t, cluster) assert.Len(t, cluster.Finalizers, 0) diff --git a/pkg/operator/edgefs/cluster/mgr/mgr.go b/pkg/operator/edgefs/cluster/mgr/mgr.go index 0c14f1780..98ec4bb60 100644 --- a/pkg/operator/edgefs/cluster/mgr/mgr.go +++ b/pkg/operator/edgefs/cluster/mgr/mgr.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -24,7 +24,7 @@ import ( "strings" "github.com/coreos/pkg/capnslog" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" @@ -66,8 +66,8 @@ type Cluster struct { annotations rookalpha.Annotations placement rookalpha.Placement context *clusterd.Context - hostNetworkSpec edgefsv1alpha1.NetworkSpec - dashboardSpec edgefsv1alpha1.DashboardSpec + hostNetworkSpec edgefsv1beta1.NetworkSpec + dashboardSpec edgefsv1beta1.DashboardSpec resources v1.ResourceRequirements resourceProfile string ownerRef metav1.OwnerReference @@ -81,8 +81,8 @@ func New( dataVolumeSize resource.Quantity, annotations rookalpha.Annotations, placement rookalpha.Placement, - hostNetworkSpec edgefsv1alpha1.NetworkSpec, - dashboardSpec edgefsv1alpha1.DashboardSpec, + hostNetworkSpec edgefsv1beta1.NetworkSpec, + dashboardSpec edgefsv1beta1.DashboardSpec, resources v1.ResourceRequirements, resourceProfile string, ownerRef metav1.OwnerReference, @@ -112,7 +112,7 @@ func New( } } -func isHostNetworkDefined(hostNetworkSpec edgefsv1alpha1.NetworkSpec) bool { +func isHostNetworkDefined(hostNetworkSpec edgefsv1beta1.NetworkSpec) bool { if len(hostNetworkSpec.ServerIfName) > 0 || len(hostNetworkSpec.ServerIfName) > 0 { return true } diff --git a/pkg/operator/edgefs/cluster/mgr/mgr_test.go b/pkg/operator/edgefs/cluster/mgr/mgr_test.go index 678a7b25c..07a4eb5ce 100644 --- a/pkg/operator/edgefs/cluster/mgr/mgr_test.go +++ b/pkg/operator/edgefs/cluster/mgr/mgr_test.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "strconv" "testing" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" testop "github.com/rook/rook/pkg/operator/test" diff --git a/pkg/operator/edgefs/cluster/target/config/config.go b/pkg/operator/edgefs/cluster/target/config/config.go index 3922b869b..768b82210 100644 --- a/pkg/operator/edgefs/cluster/target/config/config.go +++ b/pkg/operator/edgefs/cluster/target/config/config.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/operator/edgefs/cluster/target/layout.go b/pkg/operator/edgefs/cluster/target/layout.go index 96b2f5b65..d3db10fde 100644 --- a/pkg/operator/edgefs/cluster/target/layout.go +++ b/pkg/operator/edgefs/cluster/target/layout.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "path/filepath" "strings" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/operator/edgefs/cluster/target/config" "github.com/rook/rook/pkg/util/sys" @@ -46,8 +46,8 @@ func getIdDevLinkName(dls string) (dl string) { return dl } -func GetRTDevices(nodeDisks []sys.LocalDisk, storeConfig *config.StoreConfig) (rtDevices []edgefsv1alpha1.RTDevice, err error) { - rtDevices = make([]edgefsv1alpha1.RTDevice, 0) +func GetRTDevices(nodeDisks []sys.LocalDisk, storeConfig *config.StoreConfig) (rtDevices []edgefsv1beta1.RTDevice, err error) { + rtDevices = make([]edgefsv1beta1.RTDevice, 0) if storeConfig == nil { return rtDevices, fmt.Errorf("no pointer to StoreConfig provided") } @@ -88,7 +88,7 @@ func GetRTDevices(nodeDisks []sys.LocalDisk, storeConfig *config.StoreConfig) (r if devices[i].Rotational { continue } - rtdev := edgefsv1alpha1.RTDevice{ + rtdev := edgefsv1beta1.RTDevice{ Name: getIdDevLinkName(devices[i].DevLinks), Device: "/dev/" + devices[i].Name, Psize: storeConfig.LmdbPageSize, @@ -115,7 +115,7 @@ func GetRTDevices(nodeDisks []sys.LocalDisk, storeConfig *config.StoreConfig) (r if !devices[i].Rotational { continue } - rtdev := edgefsv1alpha1.RTDevice{ + rtdev := edgefsv1beta1.RTDevice{ Name: getIdDevLinkName(devices[i].DevLinks), Device: "/dev/" + devices[i].Name, Psize: storeConfig.LmdbPageSize, @@ -155,7 +155,7 @@ func GetRTDevices(nodeDisks []sys.LocalDisk, storeConfig *config.StoreConfig) (r for i := range hdds_divided { for j := range hdds_divided[i] { - rtdev := edgefsv1alpha1.RTDevice{ + rtdev := edgefsv1beta1.RTDevice{ Name: getIdDevLinkName(hdds_divided[i][j].DevLinks), Device: "/dev/" + hdds_divided[i][j].Name, Psize: storeConfig.LmdbPageSize, @@ -184,10 +184,10 @@ func GetRTDevices(nodeDisks []sys.LocalDisk, storeConfig *config.StoreConfig) (r return rtDevices, nil } -func GetRtlfsDevices(directories []rookalpha.Directory, storeConfig *config.StoreConfig) []edgefsv1alpha1.RtlfsDevice { - rtlfsDevices := make([]edgefsv1alpha1.RtlfsDevice, 0) +func GetRtlfsDevices(directories []rookalpha.Directory, storeConfig *config.StoreConfig) []edgefsv1beta1.RtlfsDevice { + rtlfsDevices := make([]edgefsv1beta1.RtlfsDevice, 0) for _, dir := range directories { - rtlfsDevice := edgefsv1alpha1.RtlfsDevice{ + rtlfsDevice := edgefsv1beta1.RtlfsDevice{ Name: filepath.Base(dir.Path), Path: dir.Path, CheckMountpoint: 0, diff --git a/pkg/operator/edgefs/cluster/target/pod.go b/pkg/operator/edgefs/cluster/target/pod.go index 64dca8371..9a516fc1a 100644 --- a/pkg/operator/edgefs/cluster/target/pod.go +++ b/pkg/operator/edgefs/cluster/target/pod.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -17,7 +17,7 @@ limitations under the License. package target import ( - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/operator/edgefs/cluster/target/config" "github.com/rook/rook/pkg/operator/k8sutil" appsv1 "k8s.io/api/apps/v1" @@ -151,7 +151,7 @@ func (c *Cluster) makeAuditdContainer(containerImage string) v1.Container { } } -func (c *Cluster) makeDaemonContainer(containerImage string, dro edgefsv1alpha1.DevicesResurrectOptions, isInitContainer bool) v1.Container { +func (c *Cluster) makeDaemonContainer(containerImage string, dro edgefsv1beta1.DevicesResurrectOptions, isInitContainer bool) v1.Container { privileged := c.deploymentConfig.NeedPrivileges runAsUser := int64(0) @@ -196,9 +196,9 @@ func (c *Cluster) makeDaemonContainer(containerImage string, dro edgefsv1alpha1. // get cluster wide sync option, and apply for deploymentConfig clusterStorageConfig := config.ToStoreConfig(c.Storage.Config) - if c.deploymentConfig.DeploymentType == edgefsv1alpha1.DeploymentAutoRtlfs { + if c.deploymentConfig.DeploymentType == edgefsv1beta1.DeploymentAutoRtlfs { volumeMounts = append(volumeMounts, v1.VolumeMount{Name: dataVolumeName, MountPath: "/data"}) - } else if c.deploymentConfig.DeploymentType == edgefsv1alpha1.DeploymentRtlfs { + } else if c.deploymentConfig.DeploymentType == edgefsv1beta1.DeploymentRtlfs { rtlfsDevices := GetRtlfsDevices(c.Storage.Directories, &clusterStorageConfig) for _, device := range rtlfsDevices { volumeMounts = append(volumeMounts, v1.VolumeMount{Name: device.Name, MountPath: device.Path}) @@ -248,7 +248,7 @@ func (c *Cluster) makeDaemonContainer(containerImage string, dro edgefsv1alpha1. VolumeMounts: volumeMounts, } - cont.Env = append(cont.Env, edgefsv1alpha1.GetInitiatorEnvArr("target", + cont.Env = append(cont.Env, edgefsv1beta1.GetInitiatorEnvArr("target", c.resourceProfile == "embedded", c.chunkCacheSize, c.resources)...) return cont @@ -260,14 +260,14 @@ func (c *Cluster) configOverrideVolume() v1.Volume { return v1.Volume{Name: configVolumeName, VolumeSource: v1.VolumeSource{ConfigMap: cmSource}} } -func isHostNetworkDefined(hostNetworkSpec edgefsv1alpha1.NetworkSpec) bool { +func isHostNetworkDefined(hostNetworkSpec edgefsv1beta1.NetworkSpec) bool { if len(hostNetworkSpec.ServerIfName) > 0 || len(hostNetworkSpec.ServerIfName) > 0 { return true } return false } -func (c *Cluster) createPodSpec(rookImage string, dro edgefsv1alpha1.DevicesResurrectOptions) v1.PodSpec { +func (c *Cluster) createPodSpec(rookImage string, dro edgefsv1beta1.DevicesResurrectOptions) v1.PodSpec { terminationGracePeriodSeconds := int64(60) DNSPolicy := v1.DNSClusterFirst @@ -325,7 +325,7 @@ func (c *Cluster) createPodSpec(rookImage string, dro edgefsv1alpha1.DevicesResu }) } - if c.deploymentConfig.DeploymentType == edgefsv1alpha1.DeploymentRtlfs { + if c.deploymentConfig.DeploymentType == edgefsv1beta1.DeploymentRtlfs { // RTLFS with specified folders for _, folder := range c.deploymentConfig.Directories { volumes = append(volumes, v1.Volume{ @@ -395,7 +395,7 @@ func (c *Cluster) createPodSpec(rookImage string, dro edgefsv1alpha1.DevicesResu } } -func (c *Cluster) makeStatefulSet(replicas int32, rookImage string, dro edgefsv1alpha1.DevicesResurrectOptions) (*appsv1.StatefulSet, error) { +func (c *Cluster) makeStatefulSet(replicas int32, rookImage string, dro edgefsv1beta1.DevicesResurrectOptions) (*appsv1.StatefulSet, error) { statefulSet := &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Name: appName, diff --git a/pkg/operator/edgefs/cluster/target/pod_test.go b/pkg/operator/edgefs/cluster/target/pod_test.go index fcdbb605f..8aa7f6688 100644 --- a/pkg/operator/edgefs/cluster/target/pod_test.go +++ b/pkg/operator/edgefs/cluster/target/pod_test.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -19,7 +19,7 @@ package target import ( "testing" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/edgefs/cluster/target/config" @@ -63,7 +63,7 @@ func TestStorageSpecConfig(t *testing.T) { } clientset := fake.NewSimpleClientset() - deploymentConfig := edgefsv1alpha1.ClusterDeploymentConfig{} + deploymentConfig := edgefsv1beta1.ClusterDeploymentConfig{} c := New(&clusterd.Context{Clientset: clientset, ConfigDir: "/var/lib/rook", Executor: &exectest.MockExecutor{}}, "ns", "rook/rook:myversion", "", storageSpec, "", *resource.NewQuantity(100000.0, resource.BinarySI), rookalpha.Annotations{}, rookalpha.Placement{}, edgefsv1beta1.NetworkSpec{}, v1.ResourceRequirements{}, "", *resource.NewQuantity(0.0, resource.BinarySI), diff --git a/pkg/operator/edgefs/cluster/target/target.go b/pkg/operator/edgefs/cluster/target/target.go index fd64ba02a..ded30fe90 100644 --- a/pkg/operator/edgefs/cluster/target/target.go +++ b/pkg/operator/edgefs/cluster/target/target.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -20,7 +20,7 @@ import ( "os" "github.com/coreos/pkg/capnslog" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "k8s.io/api/core/v1" @@ -57,14 +57,14 @@ type Cluster struct { Storage rookalpha.StorageScopeSpec dataDirHostPath string dataVolumeSize resource.Quantity - HostNetworkSpec edgefsv1alpha1.NetworkSpec + HostNetworkSpec edgefsv1beta1.NetworkSpec Privileged bool resources v1.ResourceRequirements resourceProfile string chunkCacheSize resource.Quantity ownerRef metav1.OwnerReference serviceAccount string - deploymentConfig edgefsv1alpha1.ClusterDeploymentConfig + deploymentConfig edgefsv1beta1.ClusterDeploymentConfig } // New creates an instance of the Target manager @@ -78,12 +78,12 @@ func New( dataVolumeSize resource.Quantity, annotations rookalpha.Annotations, placement rookalpha.Placement, - hostNetworkSpec edgefsv1alpha1.NetworkSpec, + hostNetworkSpec edgefsv1beta1.NetworkSpec, resources v1.ResourceRequirements, resourceProfile string, chunkCacheSize resource.Quantity, ownerRef metav1.OwnerReference, - deploymentConfig edgefsv1alpha1.ClusterDeploymentConfig, + deploymentConfig edgefsv1beta1.ClusterDeploymentConfig, ) *Cluster { if serviceAccount == "" { @@ -112,7 +112,7 @@ func New( } // Start the target management -func (c *Cluster) Start(rookImage string, nodes []rookalpha.Node, dro edgefsv1alpha1.DevicesResurrectOptions) (err error) { +func (c *Cluster) Start(rookImage string, nodes []rookalpha.Node, dro edgefsv1beta1.DevicesResurrectOptions) (err error) { logger.Infof("start running targets in namespace %s", c.Namespace) logger.Infof("Target Image is %s", rookImage) diff --git a/pkg/operator/edgefs/cluster/utils.go b/pkg/operator/edgefs/cluster/utils.go index 6f735099e..c24394872 100644 --- a/pkg/operator/edgefs/cluster/utils.go +++ b/pkg/operator/edgefs/cluster/utils.go @@ -21,7 +21,7 @@ import ( "strings" "time" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/operator/discover" "github.com/rook/rook/pkg/operator/edgefs/cluster/target" @@ -40,8 +40,8 @@ const ( nodeTypeLabelFmt = "%s-nodetype" ) -func ParseDevicesResurrectMode(resurrectMode string) edgefsv1alpha1.DevicesResurrectOptions { - drm := edgefsv1alpha1.DevicesResurrectOptions{} +func ParseDevicesResurrectMode(resurrectMode string) edgefsv1beta1.DevicesResurrectOptions { + drm := edgefsv1beta1.DevicesResurrectOptions{} if len(resurrectMode) == 0 { return drm } @@ -82,14 +82,14 @@ func (c *cluster) getClusterNodes() ([]rookalpha.Node, error) { c.Spec.Storage.Nodes = append(c.Spec.Storage.Nodes, storageNode) } } - validNodes := k8sutil.GetValidNodes(c.Spec.Storage.Nodes, c.context.Clientset, edgefsv1alpha1.GetTargetPlacement(c.Spec.Placement)) + validNodes := k8sutil.GetValidNodes(c.Spec.Storage.Nodes, c.context.Clientset, edgefsv1beta1.GetTargetPlacement(c.Spec.Placement)) c.Spec.Storage.Nodes = validNodes return validNodes, nil } -func (c *cluster) createDeploymentConfig(nodes []rookalpha.Node, resurrect bool) (edgefsv1alpha1.ClusterDeploymentConfig, error) { +func (c *cluster) createDeploymentConfig(nodes []rookalpha.Node, resurrect bool) (edgefsv1beta1.ClusterDeploymentConfig, error) { - deploymentConfig := edgefsv1alpha1.ClusterDeploymentConfig{DevConfig: make(map[string]edgefsv1alpha1.DevicesConfig, 0)} + deploymentConfig := edgefsv1beta1.ClusterDeploymentConfig{DevConfig: make(map[string]edgefsv1beta1.DevicesConfig, 0)} //Fill deploymentConfig devices struct for _, node := range nodes { n := c.resolveNode(node.Name) @@ -99,9 +99,9 @@ func (c *cluster) createDeploymentConfig(nodes []rookalpha.Node, resurrect bool) return deploymentConfig, fmt.Errorf("node %s did not resolve to start target", node.Name) } - devicesConfig := edgefsv1alpha1.DevicesConfig{} - devicesConfig.Rtrd.Devices = make([]edgefsv1alpha1.RTDevice, 0) - devicesConfig.Rtlfs.Devices = make([]edgefsv1alpha1.RtlfsDevice, 0) + devicesConfig := edgefsv1beta1.DevicesConfig{} + devicesConfig.Rtrd.Devices = make([]edgefsv1beta1.RTDevice, 0) + devicesConfig.Rtlfs.Devices = make([]edgefsv1beta1.RtlfsDevice, 0) // Apply Node's zone value devicesConfig.Zone = storeConfig.Zone @@ -139,7 +139,7 @@ func (c *cluster) createDeploymentConfig(nodes []rookalpha.Node, resurrect bool) rtDevices, err := target.GetRTDevices(availDisks, &storeConfig) if err != nil { logger.Warningf("Can't get rtDevices for node %s due %v", n.Name, err) - rtDevices = make([]edgefsv1alpha1.RTDevice, 0) + rtDevices = make([]edgefsv1beta1.RTDevice, 0) } devicesConfig.Rtrd.Devices = rtDevices @@ -156,7 +156,7 @@ func (c *cluster) createDeploymentConfig(nodes []rookalpha.Node, resurrect bool) deploymentConfig.Directories = target.GetRtlfsDevices(c.Spec.Storage.Directories, &clusterStorageConfig) if len(c.Spec.Storage.Directories) > 0 && (len(c.Spec.DataDirHostPath) > 0 || c.Spec.DataVolumeSize.Value() != 0) { - deploymentConfig.DeploymentType = edgefsv1alpha1.DeploymentRtlfs + deploymentConfig.DeploymentType = edgefsv1beta1.DeploymentRtlfs deploymentConfig.TransportKey = "rtlfs" // Check directories devices count on all nodes @@ -185,11 +185,11 @@ func (c *cluster) createDeploymentConfig(nodes []rookalpha.Node, resurrect bool) return deploymentConfig, fmt.Errorf("Disk devices should be more then 3 on all nodes summary") } - deploymentConfig.DeploymentType = edgefsv1alpha1.DeploymentRtrd + deploymentConfig.DeploymentType = edgefsv1beta1.DeploymentRtrd deploymentConfig.TransportKey = "rtrd" deploymentConfig.NeedPrivileges = true } else if len(c.Spec.DataDirHostPath) == 0 || c.Spec.DataVolumeSize.Value() == 0 { - deploymentConfig.DeploymentType = edgefsv1alpha1.DeploymentAutoRtlfs + deploymentConfig.DeploymentType = edgefsv1beta1.DeploymentAutoRtlfs deploymentConfig.TransportKey = "rtlfs" } else { return deploymentConfig, fmt.Errorf("Unknown deployment type! Cluster spec:\n %+v", c) @@ -204,7 +204,7 @@ func (c *cluster) createDeploymentConfig(nodes []rookalpha.Node, resurrect bool) } // Validates all nodes in cluster that each one has valid zone number or all of them has zone == 0 -func ValidateZones(deploymentConfig *edgefsv1alpha1.ClusterDeploymentConfig) error { +func ValidateZones(deploymentConfig *edgefsv1beta1.ClusterDeploymentConfig) error { validZonesFound := 0 for _, nodeDevConfig := range deploymentConfig.DevConfig { if nodeDevConfig.Zone > 0 { diff --git a/pkg/operator/edgefs/iscsi/controller.go b/pkg/operator/edgefs/iscsi/controller.go index 20f58edd6..415f017d4 100644 --- a/pkg/operator/edgefs/iscsi/controller.go +++ b/pkg/operator/edgefs/iscsi/controller.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "k8s.io/api/core/v1" @@ -44,10 +44,10 @@ var logger = capnslog.NewPackageLogger("github.com/rook/rook", "edgefs-op-iscsi" var ISCSIResource = opkit.CustomResource{ Name: customResourceName, Plural: customResourceNamePlural, - Group: edgefsv1alpha1.CustomResourceGroup, - Version: edgefsv1alpha1.Version, + Group: edgefsv1beta1.CustomResourceGroup, + Version: edgefsv1beta1.Version, Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(edgefsv1alpha1.ISCSI{}).Name(), + Kind: reflect.TypeOf(edgefsv1beta1.ISCSI{}).Name(), } // ISCSIController represents a controller object for iscsi custom resources @@ -98,8 +98,8 @@ func (c *ISCSIController) StartWatch(namespace string, stopCh chan struct{}) err } logger.Infof("start watching iscsi resources in namespace %s", namespace) - watcher := opkit.NewWatcher(ISCSIResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient()) - go watcher.Watch(&edgefsv1alpha1.ISCSI{}, stopCh) + watcher := opkit.NewWatcher(ISCSIResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1beta1().RESTClient()) + go watcher.Watch(&edgefsv1beta1.ISCSI{}, stopCh) return nil } @@ -151,7 +151,7 @@ func (c *ISCSIController) onDelete(obj interface{}) { } } -func (c *ISCSIController) serviceOwners(service *edgefsv1alpha1.ISCSI) []metav1.OwnerReference { +func (c *ISCSIController) serviceOwners(service *edgefsv1beta1.ISCSI) []metav1.OwnerReference { // Only set the cluster crd as the owner of the ISCSI resources. // If the ISCSI crd is deleted, the operator will explicitly remove the ISCSI resources. // If the ISCSI crd still exists when the cluster crd is deleted, this will make sure the ISCSI @@ -159,13 +159,13 @@ func (c *ISCSIController) serviceOwners(service *edgefsv1alpha1.ISCSI) []metav1. return []metav1.OwnerReference{c.ownerRef} } -func serviceChanged(oldService, newService edgefsv1alpha1.ISCSISpec) bool { +func serviceChanged(oldService, newService edgefsv1beta1.ISCSISpec) bool { return false } -func getISCSIObject(obj interface{}) (iscsi *edgefsv1alpha1.ISCSI, err error) { +func getISCSIObject(obj interface{}) (iscsi *edgefsv1beta1.ISCSI, err error) { var ok bool - iscsi, ok = obj.(*edgefsv1alpha1.ISCSI) + iscsi, ok = obj.(*edgefsv1beta1.ISCSI) if ok { // the iscsi object is of the latest type, simply return it return iscsi.DeepCopy(), nil diff --git a/pkg/operator/edgefs/iscsi/iscsi.go b/pkg/operator/edgefs/iscsi/iscsi.go index 86c055c58..da85a2030 100644 --- a/pkg/operator/edgefs/iscsi/iscsi.go +++ b/pkg/operator/edgefs/iscsi/iscsi.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "encoding/json" "fmt" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" @@ -44,16 +44,16 @@ const ( ) // Start the ISCSI manager -func (c *ISCSIController) CreateService(s edgefsv1alpha1.ISCSI, ownerRefs []metav1.OwnerReference) error { +func (c *ISCSIController) CreateService(s edgefsv1beta1.ISCSI, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, false, ownerRefs) } -func (c *ISCSIController) UpdateService(s edgefsv1alpha1.ISCSI, ownerRefs []metav1.OwnerReference) error { +func (c *ISCSIController) UpdateService(s edgefsv1beta1.ISCSI, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, true, ownerRefs) } // Start the iscsi instance -func (c *ISCSIController) CreateOrUpdate(s edgefsv1alpha1.ISCSI, update bool, ownerRefs []metav1.OwnerReference) error { +func (c *ISCSIController) CreateOrUpdate(s edgefsv1beta1.ISCSI, update bool, ownerRefs []metav1.OwnerReference) error { logger.Infof("starting update=%v service=%s", update, s.Name) logger.Infof("ISCSI Base image is %s", c.rookImage) @@ -101,7 +101,7 @@ func (c *ISCSIController) CreateOrUpdate(s edgefsv1alpha1.ISCSI, update bool, ow return nil } -func (c *ISCSIController) makeISCSIService(name, svcname, namespace string, iscsiSpec edgefsv1alpha1.ISCSISpec) *v1.Service { +func (c *ISCSIController) makeISCSIService(name, svcname, namespace string, iscsiSpec edgefsv1beta1.ISCSISpec) *v1.Service { labels := getLabels(name, svcname, namespace) svc := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -123,7 +123,7 @@ func (c *ISCSIController) makeISCSIService(name, svcname, namespace string, iscs return svc } -func (c *ISCSIController) makeDeployment(svcname, namespace, rookImage string, iscsiSpec edgefsv1alpha1.ISCSISpec) *apps.Deployment { +func (c *ISCSIController) makeDeployment(svcname, namespace, rookImage string, iscsiSpec edgefsv1beta1.ISCSISpec) *apps.Deployment { name := instanceName(svcname) volumes := []v1.Volume{} @@ -193,7 +193,7 @@ func (c *ISCSIController) makeDeployment(svcname, namespace, rookImage string, i return d } -func (c *ISCSIController) iscsiContainer(svcname, name, containerImage string, iscsiSpec edgefsv1alpha1.ISCSISpec) v1.Container { +func (c *ISCSIController) iscsiContainer(svcname, name, containerImage string, iscsiSpec edgefsv1beta1.ISCSISpec) v1.Container { runAsUser := int64(0) readOnlyRootFilesystem := false @@ -266,7 +266,7 @@ func (c *ISCSIController) iscsiContainer(svcname, name, containerImage string, i VolumeMounts: volumeMounts, } - cont.Env = append(cont.Env, edgefsv1alpha1.GetInitiatorEnvArr("iscsi", + cont.Env = append(cont.Env, edgefsv1beta1.GetInitiatorEnvArr("iscsi", c.resourceProfile == "embedded" || iscsiSpec.ResourceProfile == "embedded", iscsiSpec.ChunkCacheSize, iscsiSpec.Resources)...) @@ -274,7 +274,7 @@ func (c *ISCSIController) iscsiContainer(svcname, name, containerImage string, i } // Delete ISCSI service and possibly some artifacts. -func (c *ISCSIController) DeleteService(s edgefsv1alpha1.ISCSI) error { +func (c *ISCSIController) DeleteService(s edgefsv1beta1.ISCSI) error { // check if service exists exists, err := serviceExists(c.context, s) if err != nil { @@ -317,7 +317,7 @@ func getLabels(name, svcname, namespace string) map[string]string { } // Validate the ISCSI arguments -func validateService(context *clusterd.Context, s edgefsv1alpha1.ISCSI) error { +func validateService(context *clusterd.Context, s edgefsv1beta1.ISCSI) error { if s.Name == "" { return fmt.Errorf("missing name") } @@ -333,7 +333,7 @@ func instanceName(svcname string) string { } // Check if the ISCSI service exists -func serviceExists(context *clusterd.Context, s edgefsv1alpha1.ISCSI) (bool, error) { +func serviceExists(context *clusterd.Context, s edgefsv1beta1.ISCSI) (bool, error) { _, err := context.Clientset.AppsV1().Deployments(s.Namespace).Get(instanceName(s.Name), metav1.GetOptions{}) if err == nil { // the deployment was found @@ -347,7 +347,7 @@ func serviceExists(context *clusterd.Context, s edgefsv1alpha1.ISCSI) (bool, err return false, nil } -func getTargetParamsJSON(params edgefsv1alpha1.TargetParametersSpec) string { +func getTargetParamsJSON(params edgefsv1beta1.TargetParametersSpec) string { result := make(map[string]uint) if params.MaxRecvDataSegmentLength > 0 { diff --git a/pkg/operator/edgefs/isgw/controller.go b/pkg/operator/edgefs/isgw/controller.go index c7c31b153..9601c659b 100644 --- a/pkg/operator/edgefs/isgw/controller.go +++ b/pkg/operator/edgefs/isgw/controller.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "k8s.io/api/core/v1" @@ -44,10 +44,10 @@ var logger = capnslog.NewPackageLogger("github.com/rook/rook", "edgefs-op-isgw") var ISGWResource = opkit.CustomResource{ Name: customResourceName, Plural: customResourceNamePlural, - Group: edgefsv1alpha1.CustomResourceGroup, - Version: edgefsv1alpha1.Version, + Group: edgefsv1beta1.CustomResourceGroup, + Version: edgefsv1beta1.Version, Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(edgefsv1alpha1.ISGW{}).Name(), + Kind: reflect.TypeOf(edgefsv1beta1.ISGW{}).Name(), } // ISGWController represents a controller object for isgw custom resources @@ -98,8 +98,8 @@ func (c *ISGWController) StartWatch(namespace string, stopCh chan struct{}) erro } logger.Infof("start watching isgw resources in namespace %s", namespace) - watcher := opkit.NewWatcher(ISGWResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient()) - go watcher.Watch(&edgefsv1alpha1.ISGW{}, stopCh) + watcher := opkit.NewWatcher(ISGWResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1beta1().RESTClient()) + go watcher.Watch(&edgefsv1beta1.ISGW{}, stopCh) return nil } @@ -151,7 +151,7 @@ func (c *ISGWController) onDelete(obj interface{}) { } } -func (c *ISGWController) serviceOwners(service *edgefsv1alpha1.ISGW) []metav1.OwnerReference { +func (c *ISGWController) serviceOwners(service *edgefsv1beta1.ISGW) []metav1.OwnerReference { // Only set the cluster crd as the owner of the ISGW resources. // If the ISGW crd is deleted, the operator will explicitly remove the ISGW resources. // If the ISGW crd still exists when the cluster crd is deleted, this will make sure the ISGW @@ -159,13 +159,13 @@ func (c *ISGWController) serviceOwners(service *edgefsv1alpha1.ISGW) []metav1.Ow return []metav1.OwnerReference{c.ownerRef} } -func serviceChanged(oldService, newService edgefsv1alpha1.ISGWSpec) bool { +func serviceChanged(oldService, newService edgefsv1beta1.ISGWSpec) bool { return false } -func getISGWObject(obj interface{}) (isgw *edgefsv1alpha1.ISGW, err error) { +func getISGWObject(obj interface{}) (isgw *edgefsv1beta1.ISGW, err error) { var ok bool - isgw, ok = obj.(*edgefsv1alpha1.ISGW) + isgw, ok = obj.(*edgefsv1beta1.ISGW) if ok { // the isgw object is of the latest type, simply return it return isgw.DeepCopy(), nil diff --git a/pkg/operator/edgefs/isgw/isgw.go b/pkg/operator/edgefs/isgw/isgw.go index 6cb7cf3a8..7e502e460 100644 --- a/pkg/operator/edgefs/isgw/isgw.go +++ b/pkg/operator/edgefs/isgw/isgw.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -22,7 +22,7 @@ import ( "net" "strconv" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" @@ -47,16 +47,16 @@ const ( ) // Start the ISGW manager -func (c *ISGWController) CreateService(s edgefsv1alpha1.ISGW, ownerRefs []metav1.OwnerReference) error { +func (c *ISGWController) CreateService(s edgefsv1beta1.ISGW, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, false, ownerRefs) } -func (c *ISGWController) UpdateService(s edgefsv1alpha1.ISGW, ownerRefs []metav1.OwnerReference) error { +func (c *ISGWController) UpdateService(s edgefsv1beta1.ISGW, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, true, ownerRefs) } // Start the isgw instance -func (c *ISGWController) CreateOrUpdate(s edgefsv1alpha1.ISGW, update bool, ownerRefs []metav1.OwnerReference) error { +func (c *ISGWController) CreateOrUpdate(s edgefsv1beta1.ISGW, update bool, ownerRefs []metav1.OwnerReference) error { logger.Infof("starting update=%v service=%s", update, s.Name) logger.Infof("ISGW Base image is %s", c.rookImage) @@ -112,7 +112,7 @@ func (c *ISGWController) CreateOrUpdate(s edgefsv1alpha1.ISGW, update bool, owne return nil } -func getDirection(isgwSpec edgefsv1alpha1.ISGWSpec) int { +func getDirection(isgwSpec edgefsv1beta1.ISGWSpec) int { direction := 0 if isgwSpec.Direction == "send" { direction = 1 @@ -124,7 +124,7 @@ func getDirection(isgwSpec edgefsv1alpha1.ISGWSpec) int { return direction } -func (c *ISGWController) makeISGWService(name, svcname, namespace string, isgwSpec edgefsv1alpha1.ISGWSpec) *v1.Service { +func (c *ISGWController) makeISGWService(name, svcname, namespace string, isgwSpec edgefsv1beta1.ISGWSpec) *v1.Service { direction := getDirection(isgwSpec) labels := getLabels(name, svcname, namespace) svc := &v1.Service{ @@ -165,7 +165,7 @@ func (c *ISGWController) makeISGWService(name, svcname, namespace string, isgwSp return svc } -func (c *ISGWController) makeDeployment(svcname, namespace, rookImage string, isgwSpec edgefsv1alpha1.ISGWSpec) *apps.Deployment { +func (c *ISGWController) makeDeployment(svcname, namespace, rookImage string, isgwSpec edgefsv1beta1.ISGWSpec) *apps.Deployment { name := instanceName(svcname) volumes := []v1.Volume{} @@ -232,7 +232,7 @@ func (c *ISGWController) makeDeployment(svcname, namespace, rookImage string, is return d } -func (c *ISGWController) isgwContainer(svcname, name, containerImage string, isgwSpec edgefsv1alpha1.ISGWSpec) v1.Container { +func (c *ISGWController) isgwContainer(svcname, name, containerImage string, isgwSpec edgefsv1beta1.ISGWSpec) v1.Container { runAsUser := int64(0) readOnlyRootFilesystem := false @@ -348,7 +348,7 @@ func (c *ISGWController) isgwContainer(svcname, name, containerImage string, isg cont.Ports = append(cont.Ports, v1.ContainerPort{Name: "dfport", ContainerPort: int32(isgwSpec.DynamicFetchPort), Protocol: v1.ProtocolTCP}) } - cont.Env = append(cont.Env, edgefsv1alpha1.GetInitiatorEnvArr("isgw", + cont.Env = append(cont.Env, edgefsv1beta1.GetInitiatorEnvArr("isgw", c.resourceProfile == "embedded" || isgwSpec.ResourceProfile == "embedded", isgwSpec.ChunkCacheSize, isgwSpec.Resources)...) @@ -356,7 +356,7 @@ func (c *ISGWController) isgwContainer(svcname, name, containerImage string, isg } // Delete ISGW service and possibly some artifacts. -func (c *ISGWController) DeleteService(s edgefsv1alpha1.ISGW) error { +func (c *ISGWController) DeleteService(s edgefsv1beta1.ISGW) error { // check if service exists exists, err := serviceExists(c.context, s) if err != nil { @@ -399,7 +399,7 @@ func getLabels(name, svcname, namespace string) map[string]string { } // Validate the ISGW arguments -func validateService(context *clusterd.Context, s edgefsv1alpha1.ISGW) error { +func validateService(context *clusterd.Context, s edgefsv1beta1.ISGW) error { if s.Name == "" { return fmt.Errorf("missing name") } @@ -415,7 +415,7 @@ func instanceName(svcname string) string { } // Check if the ISGW service exists -func serviceExists(context *clusterd.Context, s edgefsv1alpha1.ISGW) (bool, error) { +func serviceExists(context *clusterd.Context, s edgefsv1beta1.ISGW) (bool, error) { _, err := context.Clientset.AppsV1().Deployments(s.Namespace).Get(instanceName(s.Name), metav1.GetOptions{}) if err == nil { // the deployment was found diff --git a/pkg/operator/edgefs/nfs/controller.go b/pkg/operator/edgefs/nfs/controller.go index 11fba4f57..f4bb97135 100644 --- a/pkg/operator/edgefs/nfs/controller.go +++ b/pkg/operator/edgefs/nfs/controller.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -23,7 +23,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "k8s.io/api/core/v1" @@ -44,10 +44,10 @@ var logger = capnslog.NewPackageLogger("github.com/rook/rook", "edgefs-op-nfs") var NFSResource = opkit.CustomResource{ Name: customResourceName, Plural: customResourceNamePlural, - Group: edgefsv1alpha1.CustomResourceGroup, - Version: edgefsv1alpha1.Version, + Group: edgefsv1beta1.CustomResourceGroup, + Version: edgefsv1beta1.Version, Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(edgefsv1alpha1.NFS{}).Name(), + Kind: reflect.TypeOf(edgefsv1beta1.NFS{}).Name(), } // NFSController represents a controller object for nfs custom resources @@ -98,8 +98,8 @@ func (c *NFSController) StartWatch(namespace string, stopCh chan struct{}) error } logger.Infof("start watching nfs resources in namespace %s", namespace) - watcher := opkit.NewWatcher(NFSResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient()) - go watcher.Watch(&edgefsv1alpha1.NFS{}, stopCh) + watcher := opkit.NewWatcher(NFSResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1beta1().RESTClient()) + go watcher.Watch(&edgefsv1beta1.NFS{}, stopCh) return nil } @@ -151,7 +151,7 @@ func (c *NFSController) onDelete(obj interface{}) { } } -func (c *NFSController) serviceOwners(service *edgefsv1alpha1.NFS) []metav1.OwnerReference { +func (c *NFSController) serviceOwners(service *edgefsv1beta1.NFS) []metav1.OwnerReference { // Only set the cluster crd as the owner of the NFS resources. // If the NFS crd is deleted, the operator will explicitly remove the NFS resources. // If the NFS crd still exists when the cluster crd is deleted, this will make sure the NFS @@ -159,13 +159,13 @@ func (c *NFSController) serviceOwners(service *edgefsv1alpha1.NFS) []metav1.Owne return []metav1.OwnerReference{c.ownerRef} } -func serviceChanged(oldService, newService edgefsv1alpha1.NFSSpec) bool { +func serviceChanged(oldService, newService edgefsv1beta1.NFSSpec) bool { return false } -func getNFSObject(obj interface{}) (nfs *edgefsv1alpha1.NFS, err error) { +func getNFSObject(obj interface{}) (nfs *edgefsv1beta1.NFS, err error) { var ok bool - nfs, ok = obj.(*edgefsv1alpha1.NFS) + nfs, ok = obj.(*edgefsv1beta1.NFS) if ok { // the nfs object is of the latest type, simply return it return nfs.DeepCopy(), nil diff --git a/pkg/operator/edgefs/nfs/nfs.go b/pkg/operator/edgefs/nfs/nfs.go index 1f48fcfdd..dd482978d 100644 --- a/pkg/operator/edgefs/nfs/nfs.go +++ b/pkg/operator/edgefs/nfs/nfs.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -20,7 +20,7 @@ package nfs import ( "fmt" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" @@ -40,16 +40,16 @@ const ( ) // Start the rgw manager -func (c *NFSController) CreateService(s edgefsv1alpha1.NFS, ownerRefs []metav1.OwnerReference) error { +func (c *NFSController) CreateService(s edgefsv1beta1.NFS, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, false, ownerRefs) } -func (c *NFSController) UpdateService(s edgefsv1alpha1.NFS, ownerRefs []metav1.OwnerReference) error { +func (c *NFSController) UpdateService(s edgefsv1beta1.NFS, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, true, ownerRefs) } // Start the nfs instance -func (c *NFSController) CreateOrUpdate(s edgefsv1alpha1.NFS, update bool, ownerRefs []metav1.OwnerReference) error { +func (c *NFSController) CreateOrUpdate(s edgefsv1beta1.NFS, update bool, ownerRefs []metav1.OwnerReference) error { logger.Infof("starting update=%v service=%s", update, s.Name) logger.Infof("NFS Base image is %s", c.rookImage) @@ -126,7 +126,7 @@ func (c *NFSController) makeNFSService(name, svcname, namespace string) *v1.Serv return svc } -func (c *NFSController) makeDeployment(svcname, namespace, rookImage string, nfsSpec edgefsv1alpha1.NFSSpec) *apps.Deployment { +func (c *NFSController) makeDeployment(svcname, namespace, rookImage string, nfsSpec edgefsv1beta1.NFSSpec) *apps.Deployment { name := instanceName(svcname) volumes := []v1.Volume{} @@ -194,7 +194,7 @@ func (c *NFSController) makeDeployment(svcname, namespace, rookImage string, nfs return d } -func (c *NFSController) nfsContainer(svcname, name, containerImage string, nfsSpec edgefsv1alpha1.NFSSpec) v1.Container { +func (c *NFSController) nfsContainer(svcname, name, containerImage string, nfsSpec edgefsv1beta1.NFSSpec) v1.Container { runAsUser := int64(0) readOnlyRootFilesystem := false @@ -267,7 +267,7 @@ func (c *NFSController) nfsContainer(svcname, name, containerImage string, nfsSp }) } - cont.Env = append(cont.Env, edgefsv1alpha1.GetInitiatorEnvArr("nfs", + cont.Env = append(cont.Env, edgefsv1beta1.GetInitiatorEnvArr("nfs", c.resourceProfile == "embedded" || nfsSpec.ResourceProfile == "embedded", nfsSpec.ChunkCacheSize, nfsSpec.Resources)...) @@ -275,7 +275,7 @@ func (c *NFSController) nfsContainer(svcname, name, containerImage string, nfsSp } // Delete NFS service and possibly some artifacts. -func (c *NFSController) DeleteService(s edgefsv1alpha1.NFS) error { +func (c *NFSController) DeleteService(s edgefsv1beta1.NFS) error { // check if service exists exists, err := serviceExists(c.context, s) if err != nil { @@ -318,7 +318,7 @@ func getLabels(name, svcname, namespace string) map[string]string { } // Validate the NFS arguments -func validateService(context *clusterd.Context, s edgefsv1alpha1.NFS) error { +func validateService(context *clusterd.Context, s edgefsv1beta1.NFS) error { if s.Name == "" { return fmt.Errorf("missing name") } @@ -334,7 +334,7 @@ func instanceName(svcname string) string { } // Check if the NFS service exists -func serviceExists(context *clusterd.Context, s edgefsv1alpha1.NFS) (bool, error) { +func serviceExists(context *clusterd.Context, s edgefsv1beta1.NFS) (bool, error) { _, err := context.Clientset.AppsV1().Deployments(s.Namespace).Get(instanceName(s.Name), metav1.GetOptions{}) if err == nil { // the deployment was found diff --git a/pkg/operator/edgefs/s3/controller.go b/pkg/operator/edgefs/s3/controller.go index 878edfff5..48fffe4fe 100644 --- a/pkg/operator/edgefs/s3/controller.go +++ b/pkg/operator/edgefs/s3/controller.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "k8s.io/api/core/v1" @@ -44,10 +44,10 @@ var logger = capnslog.NewPackageLogger("github.com/rook/rook", "edgefs-op-s3") var S3Resource = opkit.CustomResource{ Name: customResourceName, Plural: customResourceNamePlural, - Group: edgefsv1alpha1.CustomResourceGroup, - Version: edgefsv1alpha1.Version, + Group: edgefsv1beta1.CustomResourceGroup, + Version: edgefsv1beta1.Version, Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(edgefsv1alpha1.S3{}).Name(), + Kind: reflect.TypeOf(edgefsv1beta1.S3{}).Name(), } // S3Controller represents a controller object for s3 custom resources @@ -98,8 +98,8 @@ func (c *S3Controller) StartWatch(namespace string, stopCh chan struct{}) error } logger.Infof("start watching s3 resources in namespace %s", namespace) - watcher := opkit.NewWatcher(S3Resource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient()) - go watcher.Watch(&edgefsv1alpha1.S3{}, stopCh) + watcher := opkit.NewWatcher(S3Resource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1beta1().RESTClient()) + go watcher.Watch(&edgefsv1beta1.S3{}, stopCh) return nil } @@ -151,7 +151,7 @@ func (c *S3Controller) onDelete(obj interface{}) { } } -func (c *S3Controller) serviceOwners(service *edgefsv1alpha1.S3) []metav1.OwnerReference { +func (c *S3Controller) serviceOwners(service *edgefsv1beta1.S3) []metav1.OwnerReference { // Only set the cluster crd as the owner of the S3 resources. // If the S3 crd is deleted, the operator will explicitly remove the S3 resources. // If the S3 crd still exists when the cluster crd is deleted, this will make sure the S3 @@ -159,13 +159,13 @@ func (c *S3Controller) serviceOwners(service *edgefsv1alpha1.S3) []metav1.OwnerR return []metav1.OwnerReference{c.ownerRef} } -func serviceChanged(oldService, newService edgefsv1alpha1.S3Spec) bool { +func serviceChanged(oldService, newService edgefsv1beta1.S3Spec) bool { return false } -func getS3Object(obj interface{}) (s3 *edgefsv1alpha1.S3, err error) { +func getS3Object(obj interface{}) (s3 *edgefsv1beta1.S3, err error) { var ok bool - s3, ok = obj.(*edgefsv1alpha1.S3) + s3, ok = obj.(*edgefsv1beta1.S3) if ok { // the s3 object is of the latest type, simply return it return s3.DeepCopy(), nil diff --git a/pkg/operator/edgefs/s3/s3.go b/pkg/operator/edgefs/s3/s3.go index bfdec8b5a..a31f01e13 100644 --- a/pkg/operator/edgefs/s3/s3.go +++ b/pkg/operator/edgefs/s3/s3.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "fmt" "strings" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" @@ -46,16 +46,16 @@ const ( ) // Start the S3 manager -func (c *S3Controller) CreateService(s edgefsv1alpha1.S3, ownerRefs []metav1.OwnerReference) error { +func (c *S3Controller) CreateService(s edgefsv1beta1.S3, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, false, ownerRefs) } -func (c *S3Controller) UpdateService(s edgefsv1alpha1.S3, ownerRefs []metav1.OwnerReference) error { +func (c *S3Controller) UpdateService(s edgefsv1beta1.S3, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, true, ownerRefs) } // Start the s3 instance -func (c *S3Controller) CreateOrUpdate(s edgefsv1alpha1.S3, update bool, ownerRefs []metav1.OwnerReference) error { +func (c *S3Controller) CreateOrUpdate(s edgefsv1beta1.S3, update bool, ownerRefs []metav1.OwnerReference) error { logger.Debugf("starting update=%v service=%s", update, s.Name) // validate S3 service settings @@ -132,7 +132,7 @@ func (c *S3Controller) CreateOrUpdate(s edgefsv1alpha1.S3, update bool, ownerRef return nil } -func (c *S3Controller) makeS3Service(name, svcname, namespace string, s3Spec edgefsv1alpha1.S3Spec) *v1.Service { +func (c *S3Controller) makeS3Service(name, svcname, namespace string, s3Spec edgefsv1beta1.S3Spec) *v1.Service { labels := getLabels(name, svcname, namespace) svc := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -155,7 +155,7 @@ func (c *S3Controller) makeS3Service(name, svcname, namespace string, s3Spec edg return svc } -func (c *S3Controller) makeDeployment(svcname, namespace, rookImage, imageArgs string, s3Spec edgefsv1alpha1.S3Spec) *apps.Deployment { +func (c *S3Controller) makeDeployment(svcname, namespace, rookImage, imageArgs string, s3Spec edgefsv1beta1.S3Spec) *apps.Deployment { name := instanceName(svcname) volumes := []v1.Volume{} @@ -245,7 +245,7 @@ func (c *S3Controller) makeDeployment(svcname, namespace, rookImage, imageArgs s return d } -func (c *S3Controller) s3Container(svcname, name, containerImage, args string, s3Spec edgefsv1alpha1.S3Spec) v1.Container { +func (c *S3Controller) s3Container(svcname, name, containerImage, args string, s3Spec edgefsv1beta1.S3Spec) v1.Container { runAsUser := int64(0) readOnlyRootFilesystem := false @@ -319,7 +319,7 @@ func (c *S3Controller) s3Container(svcname, name, containerImage, args string, s VolumeMounts: volumeMounts, } - cont.Env = append(cont.Env, edgefsv1alpha1.GetInitiatorEnvArr("s3", + cont.Env = append(cont.Env, edgefsv1beta1.GetInitiatorEnvArr("s3", c.resourceProfile == "embedded" || s3Spec.ResourceProfile == "embedded", s3Spec.ChunkCacheSize, s3Spec.Resources)...) @@ -327,7 +327,7 @@ func (c *S3Controller) s3Container(svcname, name, containerImage, args string, s } // Delete S3 service and possibly some artifacts. -func (c *S3Controller) DeleteService(s edgefsv1alpha1.S3) error { +func (c *S3Controller) DeleteService(s edgefsv1beta1.S3) error { // check if service exists exists, err := serviceExists(c.context, s) if err != nil { @@ -370,7 +370,7 @@ func getLabels(name, svcname, namespace string) map[string]string { } // Validate the S3 arguments -func validateService(context *clusterd.Context, s edgefsv1alpha1.S3) error { +func validateService(context *clusterd.Context, s edgefsv1beta1.S3) error { if s.Name == "" { return fmt.Errorf("missing name") } @@ -386,7 +386,7 @@ func instanceName(svcname string) string { } // Check if the S3 service exists -func serviceExists(context *clusterd.Context, s edgefsv1alpha1.S3) (bool, error) { +func serviceExists(context *clusterd.Context, s edgefsv1beta1.S3) (bool, error) { _, err := context.Clientset.AppsV1().Deployments(s.Namespace).Get(instanceName(s.Name), metav1.GetOptions{}) if err == nil { // the deployment was found diff --git a/pkg/operator/edgefs/s3x/controller.go b/pkg/operator/edgefs/s3x/controller.go index dcfdcdb42..b798790b7 100644 --- a/pkg/operator/edgefs/s3x/controller.go +++ b/pkg/operator/edgefs/s3x/controller.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "k8s.io/api/core/v1" @@ -44,10 +44,10 @@ var logger = capnslog.NewPackageLogger("github.com/rook/rook", "edgefs-op-s3x") var S3XResource = opkit.CustomResource{ Name: customResourceName, Plural: customResourceNamePlural, - Group: edgefsv1alpha1.CustomResourceGroup, - Version: edgefsv1alpha1.Version, + Group: edgefsv1beta1.CustomResourceGroup, + Version: edgefsv1beta1.Version, Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(edgefsv1alpha1.S3X{}).Name(), + Kind: reflect.TypeOf(edgefsv1beta1.S3X{}).Name(), } // S3XController represents a controller object for s3x custom resources @@ -98,8 +98,8 @@ func (c *S3XController) StartWatch(namespace string, stopCh chan struct{}) error } logger.Infof("start watching s3x resources in namespace %s", namespace) - watcher := opkit.NewWatcher(S3XResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient()) - go watcher.Watch(&edgefsv1alpha1.S3X{}, stopCh) + watcher := opkit.NewWatcher(S3XResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1beta1().RESTClient()) + go watcher.Watch(&edgefsv1beta1.S3X{}, stopCh) return nil } @@ -151,7 +151,7 @@ func (c *S3XController) onDelete(obj interface{}) { } } -func (c *S3XController) serviceOwners(service *edgefsv1alpha1.S3X) []metav1.OwnerReference { +func (c *S3XController) serviceOwners(service *edgefsv1beta1.S3X) []metav1.OwnerReference { // Only set the cluster crd as the owner of the S3X resources. // If the S3X crd is deleted, the operator will explicitly remove the S3X resources. // If the S3X crd still exists when the cluster crd is deleted, this will make sure the S3X @@ -159,13 +159,13 @@ func (c *S3XController) serviceOwners(service *edgefsv1alpha1.S3X) []metav1.Owne return []metav1.OwnerReference{c.ownerRef} } -func serviceChanged(oldService, newService edgefsv1alpha1.S3XSpec) bool { +func serviceChanged(oldService, newService edgefsv1beta1.S3XSpec) bool { return false } -func getS3XObject(obj interface{}) (s3x *edgefsv1alpha1.S3X, err error) { +func getS3XObject(obj interface{}) (s3x *edgefsv1beta1.S3X, err error) { var ok bool - s3x, ok = obj.(*edgefsv1alpha1.S3X) + s3x, ok = obj.(*edgefsv1beta1.S3X) if ok { // the s3x object is of the latest type, simply return it return s3x.DeepCopy(), nil diff --git a/pkg/operator/edgefs/s3x/s3x.go b/pkg/operator/edgefs/s3x/s3x.go index 1e14c0c12..f7b7c92c4 100644 --- a/pkg/operator/edgefs/s3x/s3x.go +++ b/pkg/operator/edgefs/s3x/s3x.go @@ -1,11 +1,11 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -20,7 +20,7 @@ package s3x import ( "fmt" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" @@ -44,16 +44,16 @@ const ( ) // Start the rgw manager -func (c *S3XController) CreateService(s edgefsv1alpha1.S3X, ownerRefs []metav1.OwnerReference) error { +func (c *S3XController) CreateService(s edgefsv1beta1.S3X, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, false, ownerRefs) } -func (c *S3XController) UpdateService(s edgefsv1alpha1.S3X, ownerRefs []metav1.OwnerReference) error { +func (c *S3XController) UpdateService(s edgefsv1beta1.S3X, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, true, ownerRefs) } // Start the s3x instance -func (c *S3XController) CreateOrUpdate(s edgefsv1alpha1.S3X, update bool, ownerRefs []metav1.OwnerReference) error { +func (c *S3XController) CreateOrUpdate(s edgefsv1beta1.S3X, update bool, ownerRefs []metav1.OwnerReference) error { logger.Infof("starting update=%v service=%s", update, s.Name) logger.Infof("S3X Base image is %s", c.rookImage) @@ -106,7 +106,7 @@ func (c *S3XController) CreateOrUpdate(s edgefsv1alpha1.S3X, update bool, ownerR return nil } -func (c *S3XController) makeS3XService(name, svcname, namespace string, s3xSpec edgefsv1alpha1.S3XSpec) *v1.Service { +func (c *S3XController) makeS3XService(name, svcname, namespace string, s3xSpec edgefsv1beta1.S3XSpec) *v1.Service { labels := getLabels(name, svcname, namespace) svc := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -129,7 +129,7 @@ func (c *S3XController) makeS3XService(name, svcname, namespace string, s3xSpec return svc } -func (c *S3XController) makeDeployment(svcname, namespace, rookImage string, s3xSpec edgefsv1alpha1.S3XSpec) *apps.Deployment { +func (c *S3XController) makeDeployment(svcname, namespace, rookImage string, s3xSpec edgefsv1beta1.S3XSpec) *apps.Deployment { name := instanceName(svcname) volumes := []v1.Volume{} @@ -219,7 +219,7 @@ func (c *S3XController) makeDeployment(svcname, namespace, rookImage string, s3x return d } -func (c *S3XController) s3xContainer(svcname, name, containerImage string, s3xSpec edgefsv1alpha1.S3XSpec) v1.Container { +func (c *S3XController) s3xContainer(svcname, name, containerImage string, s3xSpec edgefsv1beta1.S3XSpec) v1.Container { runAsUser := int64(0) readOnlyRootFilesystem := false @@ -289,7 +289,7 @@ func (c *S3XController) s3xContainer(svcname, name, containerImage string, s3xSp VolumeMounts: volumeMounts, } - cont.Env = append(cont.Env, edgefsv1alpha1.GetInitiatorEnvArr("s3x", + cont.Env = append(cont.Env, edgefsv1beta1.GetInitiatorEnvArr("s3x", c.resourceProfile == "embedded" || s3xSpec.ResourceProfile == "embedded", s3xSpec.ChunkCacheSize, s3xSpec.Resources)...) @@ -297,7 +297,7 @@ func (c *S3XController) s3xContainer(svcname, name, containerImage string, s3xSp } // Delete S3X service and possibly some artifacts. -func (c *S3XController) DeleteService(s edgefsv1alpha1.S3X) error { +func (c *S3XController) DeleteService(s edgefsv1beta1.S3X) error { // check if service exists exists, err := serviceExists(c.context, s) if err != nil { @@ -340,7 +340,7 @@ func getLabels(name, svcname, namespace string) map[string]string { } // Validate the S3X arguments -func validateService(context *clusterd.Context, s edgefsv1alpha1.S3X) error { +func validateService(context *clusterd.Context, s edgefsv1beta1.S3X) error { if s.Name == "" { return fmt.Errorf("missing name") } @@ -356,7 +356,7 @@ func instanceName(svcname string) string { } // Check if the S3X service exists -func serviceExists(context *clusterd.Context, s edgefsv1alpha1.S3X) (bool, error) { +func serviceExists(context *clusterd.Context, s edgefsv1beta1.S3X) (bool, error) { _, err := context.Clientset.AppsV1().Deployments(s.Namespace).Get(instanceName(s.Name), metav1.GetOptions{}) if err == nil { // the deployment was found diff --git a/pkg/operator/edgefs/swift/controller.go b/pkg/operator/edgefs/swift/controller.go index 60d9d7f56..6f9c76629 100644 --- a/pkg/operator/edgefs/swift/controller.go +++ b/pkg/operator/edgefs/swift/controller.go @@ -1,5 +1,5 @@ /* -Copyright 2016 The Rook Authors. All rights reserved. +Copyright 2019 The Rook Authors. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import ( "github.com/coreos/pkg/capnslog" opkit "github.com/rook/operator-kit" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" "k8s.io/api/core/v1" @@ -44,10 +44,10 @@ var logger = capnslog.NewPackageLogger("github.com/rook/rook", "edgefs-op-swift" var SWIFTResource = opkit.CustomResource{ Name: customResourceName, Plural: customResourceNamePlural, - Group: edgefsv1alpha1.CustomResourceGroup, - Version: edgefsv1alpha1.Version, + Group: edgefsv1beta1.CustomResourceGroup, + Version: edgefsv1beta1.Version, Scope: apiextensionsv1beta1.NamespaceScoped, - Kind: reflect.TypeOf(edgefsv1alpha1.SWIFT{}).Name(), + Kind: reflect.TypeOf(edgefsv1beta1.SWIFT{}).Name(), } // SWIFTController represents a controller object for swift custom resources @@ -97,8 +97,8 @@ func (c *SWIFTController) StartWatch(namespace string, stopCh chan struct{}) err } logger.Infof("start watching swift resources in namespace %s", namespace) - watcher := opkit.NewWatcher(SWIFTResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient()) - go watcher.Watch(&edgefsv1alpha1.SWIFT{}, stopCh) + watcher := opkit.NewWatcher(SWIFTResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1beta1().RESTClient()) + go watcher.Watch(&edgefsv1beta1.SWIFT{}, stopCh) return nil } @@ -150,7 +150,7 @@ func (c *SWIFTController) onDelete(obj interface{}) { } } -func (c *SWIFTController) serviceOwners(service *edgefsv1alpha1.SWIFT) []metav1.OwnerReference { +func (c *SWIFTController) serviceOwners(service *edgefsv1beta1.SWIFT) []metav1.OwnerReference { // Only set the cluster crd as the owner of the SWIFT resources. // If the SWIFT crd is deleted, the operator will explicitly remove the SWIFT resources. // If the SWIFT crd still exists when the cluster crd is deleted, this will make sure the SWIFT @@ -158,13 +158,13 @@ func (c *SWIFTController) serviceOwners(service *edgefsv1alpha1.SWIFT) []metav1. return []metav1.OwnerReference{c.ownerRef} } -func serviceChanged(oldService, newService edgefsv1alpha1.SWIFTSpec) bool { +func serviceChanged(oldService, newService edgefsv1beta1.SWIFTSpec) bool { return false } -func getSWIFTObject(obj interface{}) (swift *edgefsv1alpha1.SWIFT, err error) { +func getSWIFTObject(obj interface{}) (swift *edgefsv1beta1.SWIFT, err error) { var ok bool - swift, ok = obj.(*edgefsv1alpha1.SWIFT) + swift, ok = obj.(*edgefsv1beta1.SWIFT) if ok { // the swift object is of the latest type, simply return it return swift.DeepCopy(), nil diff --git a/pkg/operator/edgefs/swift/swift.go b/pkg/operator/edgefs/swift/swift.go index c10acbac0..ef2f45b7f 100644 --- a/pkg/operator/edgefs/swift/swift.go +++ b/pkg/operator/edgefs/swift/swift.go @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, @@ -21,7 +21,7 @@ import ( "fmt" "strings" - edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1" + edgefsv1beta1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1beta1" "github.com/rook/rook/pkg/clusterd" "github.com/rook/rook/pkg/operator/k8sutil" apps "k8s.io/api/apps/v1" @@ -46,16 +46,16 @@ const ( ) // Start the SWIFT manager -func (c *SWIFTController) CreateService(s edgefsv1alpha1.SWIFT, ownerRefs []metav1.OwnerReference) error { +func (c *SWIFTController) CreateService(s edgefsv1beta1.SWIFT, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, false, ownerRefs) } -func (c *SWIFTController) UpdateService(s edgefsv1alpha1.SWIFT, ownerRefs []metav1.OwnerReference) error { +func (c *SWIFTController) UpdateService(s edgefsv1beta1.SWIFT, ownerRefs []metav1.OwnerReference) error { return c.CreateOrUpdate(s, true, ownerRefs) } // Start the swift instance -func (c *SWIFTController) CreateOrUpdate(s edgefsv1alpha1.SWIFT, update bool, ownerRefs []metav1.OwnerReference) error { +func (c *SWIFTController) CreateOrUpdate(s edgefsv1beta1.SWIFT, update bool, ownerRefs []metav1.OwnerReference) error { logger.Debugf("starting update=%v service=%s", update, s.Name) // validate SWIFT service settings @@ -120,7 +120,7 @@ func (c *SWIFTController) CreateOrUpdate(s edgefsv1alpha1.SWIFT, update bool, ow return nil } -func (c *SWIFTController) makeSWIFTService(name, svcname, namespace string, swiftSpec edgefsv1alpha1.SWIFTSpec) *v1.Service { +func (c *SWIFTController) makeSWIFTService(name, svcname, namespace string, swiftSpec edgefsv1beta1.SWIFTSpec) *v1.Service { labels := getLabels(name, svcname, namespace) svc := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -143,7 +143,7 @@ func (c *SWIFTController) makeSWIFTService(name, svcname, namespace string, swif return svc } -func (c *SWIFTController) makeDeployment(svcname, namespace, rookImage, imageArgs string, swiftSpec edgefsv1alpha1.SWIFTSpec) *apps.Deployment { +func (c *SWIFTController) makeDeployment(svcname, namespace, rookImage, imageArgs string, swiftSpec edgefsv1beta1.SWIFTSpec) *apps.Deployment { name := instanceName(svcname) volumes := []v1.Volume{} @@ -231,7 +231,7 @@ func (c *SWIFTController) makeDeployment(svcname, namespace, rookImage, imageArg return d } -func (c *SWIFTController) swiftContainer(svcname, name, containerImage, args string, swiftSpec edgefsv1alpha1.SWIFTSpec) v1.Container { +func (c *SWIFTController) swiftContainer(svcname, name, containerImage, args string, swiftSpec edgefsv1beta1.SWIFTSpec) v1.Container { runAsUser := int64(0) readOnlyRootFilesystem := false @@ -305,7 +305,7 @@ func (c *SWIFTController) swiftContainer(svcname, name, containerImage, args str VolumeMounts: volumeMounts, } - cont.Env = append(cont.Env, edgefsv1alpha1.GetInitiatorEnvArr("swift", + cont.Env = append(cont.Env, edgefsv1beta1.GetInitiatorEnvArr("swift", c.resourceProfile == "embedded" || swiftSpec.ResourceProfile == "embedded", swiftSpec.ChunkCacheSize, swiftSpec.Resources)...) @@ -313,7 +313,7 @@ func (c *SWIFTController) swiftContainer(svcname, name, containerImage, args str } // Delete SWIFT service and possibly some artifacts. -func (c *SWIFTController) DeleteService(s edgefsv1alpha1.SWIFT) error { +func (c *SWIFTController) DeleteService(s edgefsv1beta1.SWIFT) error { // check if service exists exists, err := serviceExists(c.context, s) if err != nil { @@ -356,7 +356,7 @@ func getLabels(name, svcname, namespace string) map[string]string { } // Validate the SWIFT arguments -func validateService(context *clusterd.Context, s edgefsv1alpha1.SWIFT) error { +func validateService(context *clusterd.Context, s edgefsv1beta1.SWIFT) error { if s.Name == "" { return fmt.Errorf("missing name") } @@ -372,7 +372,7 @@ func instanceName(svcname string) string { } // Check if the SWIFT service exists -func serviceExists(context *clusterd.Context, s edgefsv1alpha1.SWIFT) (bool, error) { +func serviceExists(context *clusterd.Context, s edgefsv1beta1.SWIFT) (bool, error) { _, err := context.Clientset.AppsV1().Deployments(s.Namespace).Get(instanceName(s.Name), metav1.GetOptions{}) if err == nil { // the deployment was found