diff --git a/deploy/cstor-operator.yaml b/deploy/cstor-operator.yaml index 767aa97f..1590454a 100644 --- a/deploy/cstor-operator.yaml +++ b/deploy/cstor-operator.yaml @@ -129,7 +129,7 @@ spec: protocol: TCP targetPort: 5757 selector: - name: maya-apiserver + name: cvc-operator sessionAffinity: None --- apiVersion: apps/v1 diff --git a/pkg/controllers/cstorvolumeconfig/start.go b/pkg/controllers/cstorvolumeconfig/start.go index c7d4551d..eac2687b 100644 --- a/pkg/controllers/cstorvolumeconfig/start.go +++ b/pkg/controllers/cstorvolumeconfig/start.go @@ -187,7 +187,7 @@ func setupCVCServer(k8sclientset kubernetes.Interface, openebsClientset clientse cvcServer := cvcserver.NewCVCServer(config, os.Stdout). WithOpenebsClientSet(openebsClientset). WithKubernetesClientSet(k8sclientset). - WithSnapshoter(&snapshot.SnapClient{}) + WithSnapshotter(&snapshot.SnapClient{}) // Setup the HTTP server http, err := cvcserver.NewHTTPServer(cvcServer) diff --git a/pkg/server/cstorvolumeconfig/backup_endpoint.go b/pkg/server/cstorvolumeconfig/backup_endpoint.go index 87243a33..502fd32a 100644 --- a/pkg/server/cstorvolumeconfig/backup_endpoint.go +++ b/pkg/server/cstorvolumeconfig/backup_endpoint.go @@ -44,7 +44,7 @@ type backupAPIOps struct { resp http.ResponseWriter k8sclientset kubernetes.Interface clientset clientset.Interface - snapshoter snapshot.Snapshoter + snapshotter snapshot.Snapshotter } var ( @@ -59,7 +59,7 @@ func (s *HTTPServer) backupV1alpha1SpecificRequest(resp http.ResponseWriter, req resp: resp, k8sclientset: s.cvcServer.kubeclientset, clientset: s.cvcServer.clientset, - snapshoter: s.cvcServer.snapshoter, + snapshotter: s.cvcServer.snapshotter, } switch req.Method { @@ -87,6 +87,7 @@ func (bOps *backupAPIOps) create() (interface{}, error) { if err := backupCreateRequestValidations(backUp); err != nil { return nil, err } + klog.Infof("Requested to create backup for volume %s/%s remoteBackup: %t", backUp.Namespace, backUp.Spec.VolumeName, !backUp.Spec.LocalSnap) // TODO: Move this to interface so that we can mock // snapshot calls @@ -94,7 +95,7 @@ func (bOps *backupAPIOps) create() (interface{}, error) { VolumeName: backUp.Spec.VolumeName, SnapshotName: backUp.Spec.SnapName, Namespace: getOpenEBSNamespace(), - SnapClient: bOps.snapshoter, + SnapClient: bOps.snapshotter, } snapResp, err := snapshot.CreateSnapshot(bOps.clientset) if err != nil { @@ -270,7 +271,7 @@ func (bOps *backupAPIOps) deleteBackup(backup, volname, ns, schedule string) err VolumeName: volname, SnapshotName: backup, Namespace: ns, - SnapClient: bOps.snapshoter, + SnapClient: bOps.snapshotter, } // Snapshot Name and backup name are same _, err = snapshot.DeleteSnapshot(bOps.clientset) diff --git a/pkg/server/cstorvolumeconfig/https_test.go b/pkg/server/cstorvolumeconfig/https_test.go index 539fe00e..8cad1148 100644 --- a/pkg/server/cstorvolumeconfig/https_test.go +++ b/pkg/server/cstorvolumeconfig/https_test.go @@ -243,8 +243,8 @@ func TestBackupPostEndPoint(t *testing.T) { cspcName string // cstorBackup used to query on backup endpoint cstorBackup *openebsapis.CStorBackup - // snapshoter is used to mock snapshot operations on volumes - snapshoter *snapshot.FakeSnapshoter + // snapshotter is used to mock snapshot operations on volumes + snapshotter *snapshot.FakeSnapshotter // cvrStatus creates CVR with provided phase cvrStatus cstor.CStorVolumeReplicaPhase isScheduledBackup bool @@ -265,7 +265,7 @@ func TestBackupPostEndPoint(t *testing.T) { SnapName: "snapshot1", }, }, - snapshoter: &snapshot.FakeSnapshoter{}, + snapshotter: &snapshot.FakeSnapshotter{}, cvrStatus: cstor.CVRStatusOnline, expectedResponseCode: http.StatusOK, verifyBackUpStatus: verifyExistenceOfPendingBackup, @@ -284,7 +284,7 @@ func TestBackupPostEndPoint(t *testing.T) { SnapName: "snapshot", }, }, - snapshoter: &snapshot.FakeSnapshoter{ + snapshotter: &snapshot.FakeSnapshotter{ ShouldReturnFakeError: true, }, expectedResponseCode: http.StatusBadRequest, @@ -302,7 +302,7 @@ func TestBackupPostEndPoint(t *testing.T) { BackupDest: "172.102.29.12:3234", }, }, - snapshoter: &snapshot.FakeSnapshoter{ + snapshotter: &snapshot.FakeSnapshotter{ ShouldReturnFakeError: true, }, expectedResponseCode: http.StatusBadRequest, @@ -322,7 +322,7 @@ func TestBackupPostEndPoint(t *testing.T) { SnapName: "snapshot", }, }, - snapshoter: &snapshot.FakeSnapshoter{}, + snapshotter: &snapshot.FakeSnapshotter{}, expectedResponseCode: http.StatusBadRequest, verifyBackUpStatus: backupShouldNotExist, cvrStatus: cstor.CVRStatusOffline, @@ -340,7 +340,7 @@ func TestBackupPostEndPoint(t *testing.T) { SnapName: "snapshot4", }, }, - snapshoter: &snapshot.FakeSnapshoter{}, + snapshotter: &snapshot.FakeSnapshotter{}, expectedResponseCode: http.StatusOK, verifyBackUpStatus: backupShouldNotExist, cvrStatus: cstor.CVRStatusOnline, @@ -359,7 +359,7 @@ func TestBackupPostEndPoint(t *testing.T) { LocalSnap: true, }, }, - snapshoter: &snapshot.FakeSnapshoter{}, + snapshotter: &snapshot.FakeSnapshotter{}, expectedResponseCode: http.StatusOK, verifyBackUpStatus: backupShouldNotExist, cvrStatus: cstor.CVRStatusOffline, @@ -377,7 +377,7 @@ func TestBackupPostEndPoint(t *testing.T) { LocalSnap: true, }, }, - snapshoter: &snapshot.FakeSnapshoter{ + snapshotter: &snapshot.FakeSnapshotter{ ShouldReturnFakeError: true, }, expectedResponseCode: http.StatusBadRequest, @@ -405,7 +405,7 @@ func TestBackupPostEndPoint(t *testing.T) { cvcServer: NewCVCServer(server.DefaultServerConfig(), os.Stdout). WithOpenebsClientSet(f.openebsClient). WithKubernetesClientSet(f.k8sClient). - WithSnapshoter(test.snapshoter), + WithSnapshotter(test.snapshotter), logger: log.New(os.Stdout, "", log.LstdFlags|log.Lmicroseconds), } //Marshal serializes the value provided into a json document @@ -532,7 +532,7 @@ func TestBackupGetEndPoint(t *testing.T) { cvcServer: NewCVCServer(server.DefaultServerConfig(), os.Stdout). WithOpenebsClientSet(f.openebsClient). WithKubernetesClientSet(f.k8sClient). - WithSnapshoter(&snapshot.FakeSnapshoter{}), + WithSnapshotter(&snapshot.FakeSnapshotter{}), logger: log.New(os.Stdout, "", log.LstdFlags|log.Lmicroseconds), } //Marshal serializes the value provided into a json document diff --git a/pkg/server/cstorvolumeconfig/restore_endpoint.go b/pkg/server/cstorvolumeconfig/restore_endpoint.go index 38fba5d8..24a92ce1 100644 --- a/pkg/server/cstorvolumeconfig/restore_endpoint.go +++ b/pkg/server/cstorvolumeconfig/restore_endpoint.go @@ -66,7 +66,7 @@ func (s *HTTPServer) restoreV1alpha1SpecificRequest( klog.Infof("Got restore GET request") return restoreOps.get() } - klog.Infof("please add a support for %s method in restore", req.Method) + klog.Infof("restore endpoint doesn't support %s", req.Method) return nil, CodedError(405, ErrInvalidMethod) } diff --git a/pkg/server/cstorvolumeconfig/server.go b/pkg/server/cstorvolumeconfig/server.go index b44f2d5b..860f94bd 100644 --- a/pkg/server/cstorvolumeconfig/server.go +++ b/pkg/server/cstorvolumeconfig/server.go @@ -42,8 +42,8 @@ type CVCServer struct { // clientset is a openebs custom resource package generated for custom API group. clientset clientset.Interface - // snapshoter is used to perform snapshot operations on Volumes - snapshoter snapshot.Snapshoter + // snapshotter is used to perform snapshot operations on Volumes + snapshotter snapshot.Snapshotter } // NewCVCServer is used to create a new CVC server @@ -70,9 +70,9 @@ func (cs *CVCServer) WithOpenebsClientSet(openebsClientSet clientset.Interface) return cs } -// WithSnapshoter sets the snapshoter with provided argument -func (cs *CVCServer) WithSnapshoter(snapshoter snapshot.Snapshoter) *CVCServer { - cs.snapshoter = snapshoter +// WithSnapshotter sets the snapshotter with provided argument +func (cs *CVCServer) WithSnapshotter(snapshotter snapshot.Snapshotter) *CVCServer { + cs.snapshotter = snapshotter return cs } diff --git a/pkg/snapshot/client.go b/pkg/snapshot/client.go index 5be6fa8d..208a4649 100644 --- a/pkg/snapshot/client.go +++ b/pkg/snapshot/client.go @@ -36,8 +36,8 @@ type CommandStatus struct { Response string `json:"response"` } -// Snapshoter is used to perform snapshot operations on given volume -type Snapshoter interface { +// Snapshotter is used to perform snapshot operations on given volume +type Snapshotter interface { CreateSnapshot(ip, volumeName, namesapce string) (*v1proto.VolumeSnapCreateResponse, error) DestroySnapshot(ip, volumeName, namesapce string) (*v1proto.VolumeSnapDeleteResponse, error) } diff --git a/pkg/snapshot/snapshot.go b/pkg/snapshot/snapshot.go index 296fa0c9..5b80e99f 100644 --- a/pkg/snapshot/snapshot.go +++ b/pkg/snapshot/snapshot.go @@ -27,7 +27,7 @@ type Snapshot struct { VolumeName string SnapshotName string Namespace string - SnapClient Snapshoter + SnapClient Snapshotter } // CreateSnapshot creates snapshot for provided CStor Volume diff --git a/pkg/snapshot/snapshottest/snapshot.go b/pkg/snapshot/snapshottest/snapshot.go index 9a1e5f72..e689c036 100644 --- a/pkg/snapshot/snapshottest/snapshot.go +++ b/pkg/snapshot/snapshottest/snapshot.go @@ -5,13 +5,13 @@ import ( "github.com/pkg/errors" ) -// FakeSnapshoter is used to mock the snapshot operations -type FakeSnapshoter struct { +// FakeSnapshotter is used to mock the snapshot operations +type FakeSnapshotter struct { ShouldReturnFakeError bool } // CreateSnapshot mocks snapshot create operation -func (fs *FakeSnapshoter) CreateSnapshot(ip, volName, snapName string) (*v1proto.VolumeSnapCreateResponse, error) { +func (fs *FakeSnapshotter) CreateSnapshot(ip, volName, snapName string) (*v1proto.VolumeSnapCreateResponse, error) { if fs.ShouldReturnFakeError { return nil, errors.Errorf("injected fake errors during snapshot create operation") } @@ -19,7 +19,7 @@ func (fs *FakeSnapshoter) CreateSnapshot(ip, volName, snapName string) (*v1proto } //DestroySnapshot mocks snapshot delete operation -func (fs *FakeSnapshoter) DestroySnapshot(ip, volName, snapName string) (*v1proto.VolumeSnapDeleteResponse, error) { +func (fs *FakeSnapshotter) DestroySnapshot(ip, volName, snapName string) (*v1proto.VolumeSnapDeleteResponse, error) { if fs.ShouldReturnFakeError { return nil, errors.Errorf("injected fake errors during snapshot delete operation") }