Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

432 Replication APIs to be moved from alpha phase to v1 #75

Merged
merged 6 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2023 Dell Inc. or its subsidiaries. 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.
Expand All @@ -12,7 +12,7 @@
limitations under the License.
*/

package v1alpha1
package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2023 Dell Inc. or its subsidiaries. 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.
Expand All @@ -12,10 +12,10 @@
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the storage v1alpha1 API group
// Package v1 contains API Schema definitions for the storage v1 API group
// +kubebuilder:object:generate=true
// +groupName=replication.storage.dell.com
package v1alpha1
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -24,7 +24,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "replication.storage.dell.com", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "replication.storage.dell.com", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cmd/csi-replicator/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2023 Dell Inc. or its subsidiaries. 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.
Expand Down Expand Up @@ -39,7 +39,7 @@ import (

controller "github.com/dell/csm-replication/controllers/csi-replicator"

storagev1alpha1 "github.com/dell/csm-replication/api/v1alpha1"
repv1 "github.com/dell/csm-replication/api/v1"
"github.com/dell/csm-replication/core"
"github.com/dell/csm-replication/pkg/connection"
csiidentity "github.com/dell/csm-replication/pkg/csi-clients/identity"
Expand All @@ -64,7 +64,7 @@ var (

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(storagev1alpha1.AddToScheme(scheme))
utilruntime.Must(repv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/replication-controller/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2023 Dell Inc. or its subsidiaries. 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.
Expand All @@ -23,7 +23,7 @@ import (
"time"

"github.com/bombsimon/logrusr/v3"
repV1Alpha1 "github.com/dell/csm-replication/api/v1alpha1"
repv1 "github.com/dell/csm-replication/api/v1"
"github.com/dell/csm-replication/controllers"
repController "github.com/dell/csm-replication/controllers/replication-controller"
"github.com/dell/csm-replication/pkg/common"
Expand Down Expand Up @@ -58,7 +58,7 @@ var (

func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(repV1Alpha1.AddToScheme(scheme))
utilruntime.Must(repv1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme
}

Expand Down
4 changes: 2 additions & 2 deletions config/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# More document can be found at https://docs.cert-manager.io
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
# breaking changes
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: selfsigned-issuer
namespace: system
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1alpha2
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
jsonPath: .status.replicationLinkState.lastSuccessfulUpdate
name: Last LinkState Update
type: string
name: v1alpha1
name: v1
schema:
openAPIV3Schema:
description: DellCSIReplicationGroup is the Schema for the dellcsireplicationgroups
Expand Down
4 changes: 2 additions & 2 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ vars:
# objref:
# kind: Certificate
# group: cert-manager.io
# version: v1alpha2
# version: v1
# name: serving-cert # this name should match the one in certificate.yaml
# fieldref:
# fieldpath: metadata.namespace
#- name: CERTIFICATE_NAME
# objref:
# kind: Certificate
# group: cert-manager.io
# version: v1alpha2
# version: v1
# name: serving-cert # this name should match the one in certificate.yaml
#- name: SERVICE_NAMESPACE # namespace of the service
# objref:
Expand Down
11 changes: 6 additions & 5 deletions controllers/common.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2023 Dell Inc. or its subsidiaries. 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.
Expand All @@ -17,14 +17,15 @@ package controllers
import (
"context"

storagev1alpha1 "github.com/dell/csm-replication/api/v1alpha1"
"os"

repv1 "github.com/dell/csm-replication/api/v1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"os"
ctrlClient "sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -117,8 +118,8 @@ func IgnoreIfFinalError(err error) error {
}

// UpdateConditions updates conditions status field by adding last action condition
func UpdateConditions(rg *storagev1alpha1.DellCSIReplicationGroup, condition storagev1alpha1.LastAction, maxConditions int) {
rg.Status.Conditions = append([]storagev1alpha1.LastAction{condition}, rg.Status.Conditions...)
func UpdateConditions(rg *repv1.DellCSIReplicationGroup, condition repv1.LastAction, maxConditions int) {
rg.Status.Conditions = append([]repv1.LastAction{condition}, rg.Status.Conditions...)
if len(rg.Status.Conditions) > maxConditions {
rg.Status.Conditions = rg.Status.Conditions[:maxConditions]
}
Expand Down
40 changes: 20 additions & 20 deletions controllers/csi-replicator/dellcsireplicationgroup_controller.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright © 2021-2022 Dell Inc. or its subsidiaries. All Rights Reserved.
Copyright © 2021-2023 Dell Inc. or its subsidiaries. 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.
Expand Down Expand Up @@ -29,7 +29,7 @@ import (
reconciler "sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/ratelimiter"

storagev1alpha1 "github.com/dell/csm-replication/api/v1alpha1"
repv1 "github.com/dell/csm-replication/api/v1"
csireplication "github.com/dell/csm-replication/pkg/csi-clients/replication"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -110,7 +110,7 @@ type ActionAnnotation struct {
ProtectionGroupStatus string `json:"protectionGroupStatus"`
}

func updateRGSpecWithActionResult(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup, result *ActionResult) bool {
func updateRGSpecWithActionResult(ctx context.Context, rg *repv1.DellCSIReplicationGroup, result *ActionResult) bool {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Begin updating RG spec with", "Action Result", result)

Expand Down Expand Up @@ -182,7 +182,7 @@ func getActionResultFromActionAnnotation(ctx context.Context, actionAnnotation A
return &actionResult, nil
}

func updateRGStatusWithActionResult(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup, actionResult *ActionResult) error {
func updateRGStatusWithActionResult(ctx context.Context, rg *repv1.DellCSIReplicationGroup, actionResult *ActionResult) error {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Begin updating RG status with action result")

Expand Down Expand Up @@ -224,11 +224,11 @@ func updateRGStatusWithActionResult(ctx context.Context, rg *storagev1alpha1.Del
return nil
}

func updateConditionsWithActionResult(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup, result *ActionResult) {
func updateConditionsWithActionResult(ctx context.Context, rg *repv1.DellCSIReplicationGroup, result *ActionResult) {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Begin updating condition with action result")

condition := storagev1alpha1.LastAction{
condition := repv1.LastAction{
Condition: result.ActionType.getSuccessfulString(),
Time: &metav1.Time{Time: result.Time},
}
Expand All @@ -242,7 +242,7 @@ func updateConditionsWithActionResult(ctx context.Context, rg *storagev1alpha1.D
log.V(common.InfoLevel).Info("Condition was updated")
}

func updateLastAction(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup, result *ActionResult) {
func updateLastAction(ctx context.Context, rg *repv1.DellCSIReplicationGroup, result *ActionResult) {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Updating last action..")

Expand Down Expand Up @@ -282,7 +282,7 @@ func (r *ReplicationGroupReconciler) Reconcile(ctx context.Context, req ctrl.Req
log := r.Log.WithValues("persistentvolumeclaim", req.NamespacedName)
ctx = context.WithValue(ctx, common.LoggerContextKey, log)

rg := new(storagev1alpha1.DellCSIReplicationGroup)
rg := new(repv1.DellCSIReplicationGroup)
err := r.Get(ctx, req.NamespacedName, rg)
if err != nil {
log.Error(err, "RG not found", "rg", rg)
Expand Down Expand Up @@ -345,7 +345,7 @@ func (r *ReplicationGroupReconciler) getAction(actionType ActionType) (*csiext.E
return nil, fmt.Errorf("unsupported action")
}

func (r *ReplicationGroupReconciler) deleteProtectionGroup(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup) error {
func (r *ReplicationGroupReconciler) deleteProtectionGroup(ctx context.Context, rg *repv1.DellCSIReplicationGroup) error {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Deleting protection-group")

Expand All @@ -360,7 +360,7 @@ func (r *ReplicationGroupReconciler) deleteProtectionGroup(ctx context.Context,
return nil
}

func (r *ReplicationGroupReconciler) removeFinalizer(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup) error {
func (r *ReplicationGroupReconciler) removeFinalizer(ctx context.Context, rg *repv1.DellCSIReplicationGroup) error {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Removing finalizer")

Expand All @@ -377,7 +377,7 @@ func (r *ReplicationGroupReconciler) removeFinalizer(ctx context.Context, rg *st
return nil
}

func (r *ReplicationGroupReconciler) addFinalizer(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup) (bool, error) {
func (r *ReplicationGroupReconciler) addFinalizer(ctx context.Context, rg *repv1.DellCSIReplicationGroup) (bool, error) {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Adding finalizer")

Expand All @@ -392,7 +392,7 @@ func (r *ReplicationGroupReconciler) addFinalizer(ctx context.Context, rg *stora
return ok, nil
}

func (r *ReplicationGroupReconciler) updateState(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup, state string) error {
func (r *ReplicationGroupReconciler) updateState(ctx context.Context, rg *repv1.DellCSIReplicationGroup, state string) error {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Updating to", "state", state)

Expand All @@ -411,7 +411,7 @@ func (r *ReplicationGroupReconciler) SetupWithManager(mgr ctrl.Manager, limiter
r.MaxRetryDurationForActions = MaxRetryDurationForActions
}
return ctrl.NewControllerManagedBy(mgr).
For(&storagev1alpha1.DellCSIReplicationGroup{}).
For(&repv1.DellCSIReplicationGroup{}).
WithOptions(reconciler.Options{
RateLimiter: limiter,
MaxConcurrentReconciles: maxReconcilers,
Expand All @@ -438,13 +438,13 @@ func getActionInProgress(ctx context.Context, annotations map[string]string) (*A
return &actionAnnotation, nil
}

func resetRGSpecForInvalidAction(rg *storagev1alpha1.DellCSIReplicationGroup) {
func resetRGSpecForInvalidAction(rg *repv1.DellCSIReplicationGroup) {
rg.Spec.Action = ""
delete(rg.Annotations, Action)
}

func (r *ReplicationGroupReconciler) processRGInActionInProgressState(ctx context.Context,
rg *storagev1alpha1.DellCSIReplicationGroup) (ctrl.Result, error) {
rg *repv1.DellCSIReplicationGroup) (ctrl.Result, error) {
log := common.GetLoggerFromContext(ctx)
// Get action in progress from annotation
inProgress, err := getActionInProgress(ctx, rg.Annotations)
Expand Down Expand Up @@ -567,7 +567,7 @@ func (r *ReplicationGroupReconciler) processRGInActionInProgressState(ctx contex
return ctrl.Result{}, controllers.IgnoreIfFinalError(actionResult.Error)
}

func (r *ReplicationGroupReconciler) executeAction(ctx context.Context, rg *storagev1alpha1.DellCSIReplicationGroup,
func (r *ReplicationGroupReconciler) executeAction(ctx context.Context, rg *repv1.DellCSIReplicationGroup,
actionType ActionType, action *csiext.ExecuteActionRequest_Action) *ActionResult {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Executing action", "actionType", actionType)
Expand Down Expand Up @@ -609,7 +609,7 @@ func (r *ReplicationGroupReconciler) executeAction(ctx context.Context, rg *stor
// - Add an ActionInProgress annotation
// - Update the spec
// - Update status.State to <ACTION>_IN_PROGRESS
func (r *ReplicationGroupReconciler) processRG(ctx context.Context, dellCSIReplicationGroup *storagev1alpha1.DellCSIReplicationGroup) (ctrl.Result, error) {
func (r *ReplicationGroupReconciler) processRG(ctx context.Context, dellCSIReplicationGroup *repv1.DellCSIReplicationGroup) (ctrl.Result, error) {
log := common.GetLoggerFromContext(ctx)
log.V(common.InfoLevel).Info("Start process RG")

Expand Down Expand Up @@ -662,7 +662,7 @@ func (r *ReplicationGroupReconciler) processRG(ctx context.Context, dellCSIRepli
// We just update the state to match

// We need to reset the LastAction results if any
lastAction := storagev1alpha1.LastAction{
lastAction := repv1.LastAction{
Condition: "",
FirstFailure: nil,
Time: nil,
Expand All @@ -678,7 +678,7 @@ func (r *ReplicationGroupReconciler) processRG(ctx context.Context, dellCSIRepli
return ctrl.Result{}, nil
}

func (r *ReplicationGroupReconciler) processRGInNoState(ctx context.Context, dellCSIReplicationGroup *storagev1alpha1.DellCSIReplicationGroup) (ctrl.Result, error) {
func (r *ReplicationGroupReconciler) processRGInNoState(ctx context.Context, dellCSIReplicationGroup *repv1.DellCSIReplicationGroup) (ctrl.Result, error) {
ok, err := r.addFinalizer(ctx, dellCSIReplicationGroup.DeepCopy())
if err != nil {
return ctrl.Result{}, err
Expand All @@ -692,7 +692,7 @@ func (r *ReplicationGroupReconciler) processRGInNoState(ctx context.Context, del
return ctrl.Result{}, nil
}

func (r *ReplicationGroupReconciler) processRGForDeletion(ctx context.Context, dellCSIReplicationGroup *storagev1alpha1.DellCSIReplicationGroup) (ctrl.Result, error) {
func (r *ReplicationGroupReconciler) processRGForDeletion(ctx context.Context, dellCSIReplicationGroup *repv1.DellCSIReplicationGroup) (ctrl.Result, error) {
log := common.GetLoggerFromContext(ctx)

if dellCSIReplicationGroup.Spec.ProtectionGroupID != "" {
Expand Down
Loading