Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Raghavendra Talur <[email protected]>
  • Loading branch information
raghavendra-talur committed Nov 21, 2023
1 parent de07977 commit 57d4fab
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion controllers/drclusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func drClusterUndeploy(
mcv util.ManagedClusterViewGetter,
log logr.Logger,
) error {
clusterNames := sets.String{}
clusterNames := sets.Set[string]{}
drpolicies := rmn.DRPolicyList{}

if err := mwu.Client.List(mwu.Ctx, &drpolicies); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions controllers/drplacementcontrol.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func (d *DRPCInstance) checkRegionalFailoverPrerequisites() bool {
if required, activationsRequired := requiresRegionalFailoverPrerequisites(
d.ctx,
d.reconciler.APIReader,
rmnutil.DRPolicyS3Profiles(d.drPolicy, d.drClusters).List(),
rmnutil.DRPolicyS3Profiles(d.drPolicy, d.drClusters).UnsortedList(),
d.instance.GetName(), d.instance.GetNamespace(),
d.vrgs, d.instance.Spec.FailoverCluster,
d.reconciler.ObjStoreGetter, d.log); required {
Expand Down Expand Up @@ -1498,7 +1498,7 @@ func (d *DRPCInstance) generateVRG(repState rmn.ReplicationState) rmn.VolumeRepl
Spec: rmn.VolumeReplicationGroupSpec{
PVCSelector: d.instance.Spec.PVCSelector,
ReplicationState: repState,
S3Profiles: rmnutil.DRPolicyS3Profiles(d.drPolicy, d.drClusters).List(),
S3Profiles: rmnutil.DRPolicyS3Profiles(d.drPolicy, d.drClusters).UnsortedList(),
KubeObjectProtection: d.instance.Spec.KubeObjectProtection,
},
}
Expand Down
8 changes: 3 additions & 5 deletions controllers/drplacementcontrol_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,6 @@ func DRPCsFailingOverToCluster(k8sclient client.Client, log logr.Logger, drclust

// DRPCsFailingOverToClusterForPolicy filters DRPC resources that reference the DRPolicy and are failing over
// to the target cluster passed in
//
//nolint:gocognit
func DRPCsFailingOverToClusterForPolicy(

Check failure on line 433 in controllers/drplacementcontrol_controller.go

View workflow job for this annotation

GitHub Actions / Golangci Lint

cognitive complexity 16 of func `DRPCsFailingOverToClusterForPolicy` is high (> 15) (gocognit)
k8sclient client.Client,
log logr.Logger,
Expand Down Expand Up @@ -587,7 +585,7 @@ func (r *DRPlacementControlReconciler) SetupWithManager(mgr ctrl.Manager) error
// For more details, check Reconcile and its Result here:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile
//
//nolint:cyclop,funlen,gocognit
//nolint:cyclop,funlen
func (r *DRPlacementControlReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {

Check failure on line 589 in controllers/drplacementcontrol_controller.go

View workflow job for this annotation

GitHub Actions / Golangci Lint

cognitive complexity 17 of func `(*DRPlacementControlReconciler).Reconcile` is high (> 15) (gocognit)
logger := r.Log.WithValues("DRPC", req.NamespacedName, "rid", uuid.New())

Expand Down Expand Up @@ -655,7 +653,7 @@ func (r *DRPlacementControlReconciler) Reconcile(ctx context.Context, req ctrl.R
if err != nil && !errorswrapper.Is(err, InitialWaitTimeForDRPCPlacementRule) {
err2 := r.updateDRPCStatus(ctx, drpc, placementObj, logger)

return ctrl.Result{}, fmt.Errorf("failed to create DRPC instance (%w) and (%v)", err, err2)
return ctrl.Result{}, fmt.Errorf("failed to create DRPC instance (%w) and (%w)", err, err2)

Check failure on line 656 in controllers/drplacementcontrol_controller.go

View workflow job for this annotation

GitHub Actions / Golangci Lint

printf: fmt.Errorf call has more than one error-wrapping directive %w (govet)
}

if errorswrapper.Is(err, InitialWaitTimeForDRPCPlacementRule) {
Expand Down Expand Up @@ -927,7 +925,7 @@ func (r *DRPlacementControlReconciler) getDRPolicy(ctx context.Context,
func (r DRPlacementControlReconciler) updateObjectMetadata(ctx context.Context,
drpc *rmn.DRPlacementControl, placementObj client.Object, log logr.Logger,
) error {
update := false
var update bool

update = rmnutil.AddLabel(drpc, rmnutil.OCMBackupLabelKey, rmnutil.OCMBackupLabelValue)
update = rmnutil.AddFinalizer(drpc, DRPCFinalizer) || update
Expand Down
18 changes: 9 additions & 9 deletions controllers/drpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func drClusterSecretsDeploy(
log.Info("Received partial list", "err", err)
}

for _, secretName := range drPolicySecrets.List() {
for _, secretName := range drPolicySecrets.UnsortedList() {
if err := secretsUtil.AddSecretToCluster(
secretName,
clusterName,
Expand Down Expand Up @@ -102,7 +102,7 @@ func drClustersUndeploySecrets(
return nil
}

mustHaveS3Secrets := map[string]sets.String{}
mustHaveS3Secrets := map[string]sets.Set[string]{}

// Determine S3 secrets that must continue to exist per cluster in the policy being deleted
for _, clusterName := range util.DrpolicyClusterNames(drpolicy) {
Expand All @@ -119,7 +119,7 @@ func drClustersUndeploySecrets(
// For each cluster in the must have S3 secrets list, check and delete
// S3Profiles that maybe deleted, iff absent in the must have list
for clusterName, mustHaveS3Secrets := range mustHaveS3Secrets {
for _, s3SecretToDelete := range mayDeleteS3Secrets.List() {
for _, s3SecretToDelete := range mayDeleteS3Secrets.UnsortedList() {
if mustHaveS3Secrets.Has(s3SecretToDelete) {
continue
}
Expand All @@ -144,8 +144,8 @@ func drClusterListMustHaveSecrets(
clusterName string,
ignorePolicy *rmn.DRPolicy,
ramenConfig *rmn.RamenConfig,
) sets.String {
mustHaveS3Secrets := sets.String{}
) sets.Set[string] {
mustHaveS3Secrets := sets.Set[string]{}

mustHaveS3Profiles := drClusterListMustHaveS3Profiles(drpolicies, drclusters, clusterName, ignorePolicy)

Expand All @@ -164,8 +164,8 @@ func drClusterListMustHaveS3Profiles(drpolicies rmn.DRPolicyList,
drclusters *rmn.DRClusterList,
clusterName string,
ignorePolicy *rmn.DRPolicy,
) sets.String {
mustHaveS3Profiles := sets.String{}
) sets.Set[string] {
mustHaveS3Profiles := sets.Set[string]{}

for idx := range drpolicies.Items {
// Skip the policy being ignored (used for delete)
Expand All @@ -192,8 +192,8 @@ func drClusterListMustHaveS3Profiles(drpolicies rmn.DRPolicyList,
func drPolicySecretNames(drpolicy *rmn.DRPolicy,
drclusters *rmn.DRClusterList,
rmnCfg *rmn.RamenConfig,
) (sets.String, error) {
secretNames := sets.String{}
) (sets.Set[string], error) {
secretNames := sets.Set[string]{}

var err error

Expand Down
3 changes: 1 addition & 2 deletions controllers/ramenconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package controllers
import (
"context"
"fmt"
"io/ioutil"
"net/url"
"os"

Expand Down Expand Up @@ -90,7 +89,7 @@ func ReadRamenConfigFile(log logr.Logger) (ramenConfig ramendrv1alpha1.RamenConf

log.Info("loading Ramen config file ", "name", cachedRamenConfigFileName)

fileContents, err := ioutil.ReadFile(cachedRamenConfigFileName)
fileContents, err := os.ReadFile(cachedRamenConfigFileName)
if err != nil {
err = fmt.Errorf("unable to load the config file %s: %w",
cachedRamenConfigFileName, err)
Expand Down
8 changes: 4 additions & 4 deletions controllers/util/drpolicy_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func DrpolicyRegionNames(drpolicy *rmn.DRPolicy, drClusters []rmn.DRCluster) []s
return regionNames
}

func DrpolicyRegionNamesAsASet(drpolicy *rmn.DRPolicy, drClusters []rmn.DRCluster) sets.String {
return sets.NewString(DrpolicyRegionNames(drpolicy, drClusters)...)
func DrpolicyRegionNamesAsASet(drpolicy *rmn.DRPolicy, drClusters []rmn.DRCluster) sets.Set[string] {
return sets.New[string](DrpolicyRegionNames(drpolicy, drClusters)...)
}

func DrpolicyValidated(drpolicy *rmn.DRPolicy) error {
Expand All @@ -68,8 +68,8 @@ func GetAllDRPolicies(ctx context.Context, client client.Reader) (rmn.DRPolicyLi
return drpolicies, nil
}

func DRPolicyS3Profiles(drpolicy *rmn.DRPolicy, drclusters []rmn.DRCluster) sets.String {
mustHaveS3Profiles := sets.String{}
func DRPolicyS3Profiles(drpolicy *rmn.DRPolicy, drclusters []rmn.DRCluster) sets.Set[string] {
mustHaveS3Profiles := sets.Set[string]{}

for _, managedCluster := range DrpolicyClusterNames(drpolicy) {
s3ProfileName := ""
Expand Down
1 change: 0 additions & 1 deletion controllers/volsync/vshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ func (v *VSHandler) DeleteRD(pvcName string) error {
return nil
}

//nolint:gocognit
func (v *VSHandler) deleteLocalRDAndRS(rd *volsyncv1alpha1.ReplicationDestination) error {

Check failure on line 738 in controllers/volsync/vshandler.go

View workflow job for this annotation

GitHub Actions / Golangci Lint

cognitive complexity 16 of func `(*VSHandler).deleteLocalRDAndRS` is high (> 15) (gocognit)
latestRDImage, err := v.getRDLatestImage(rd.GetName())
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion controllers/vrg_kubeobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (v *VRGInstance) kubeObjectsGroupCapture(

result.Requeue = true

return
return requestsCompletedCount
}

captureInProgressStatusUpdate()
Expand Down
4 changes: 2 additions & 2 deletions controllers/vrg_recipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ var _ = Describe("VolumeReplicationGroupRecipe", func() {
recipeHooksDefine(hook(ns0ParameterRef))
})
JustBeforeEach(func() {
recipeExpanded = &*r
Expect(controllers.RecipeParametersExpand(recipeExpanded, vrgRecipeParameters(), testLogger)).To(Succeed())
recipeExpanded := *r
Expect(controllers.RecipeParametersExpand(&recipeExpanded, vrgRecipeParameters(), testLogger)).To(Succeed())
})
It("expands a parameter list enclosed in double quotes to a single string with quotes preserved", func() {
Skip("feature not supported")
Expand Down
8 changes: 4 additions & 4 deletions controllers/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -1995,10 +1995,10 @@ func restoreClusterDataObjects[

for i := range objList {
object := &objList[i]
objectCopy := &*object
obj := ClientObject(objectCopy)
objectCopy := *object
obj := ClientObject(&objectCopy)

cleanupForRestore(objectCopy)
cleanupForRestore(&objectCopy)
addRestoreAnnotation(obj)

if err := v.reconciler.Create(v.ctx, obj); err != nil {
Expand Down Expand Up @@ -2328,7 +2328,7 @@ func (v *VRGInstance) aggregateVolRepDataReadyCondition() *metav1.Condition {
return newVRGDataErrorCondition(v.instance.Generation, msg)
}

//nolint:funlen,gocognit,cyclop
//nolint:funlen,cyclop
func (v *VRGInstance) aggregateVolRepDataProtectedCondition() *metav1.Condition {

Check failure on line 2332 in controllers/vrg_volrep.go

View workflow job for this annotation

GitHub Actions / Golangci Lint

cognitive complexity 18 of func `(*VRGInstance).aggregateVolRepDataProtectedCondition` is high (> 15) (gocognit)
if len(v.volRepPVCs) == 0 {
return nil
Expand Down
4 changes: 2 additions & 2 deletions controllers/vrg_volsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (v *VRGInstance) reconcileVolSyncAsPrimary(finalSyncPrepared *bool) (requeu
if len(v.volSyncPVCs) == 0 {
finalSyncComplete()

return
return requeue
}

v.log.Info(fmt.Sprintf("Reconciling VolSync as Primary. %d VolSyncPVCs", len(v.volSyncPVCs)))
Expand All @@ -89,7 +89,7 @@ func (v *VRGInstance) reconcileVolSyncAsPrimary(finalSyncPrepared *bool) (requeu

requeue = true

return
return requeue
}

for _, pvc := range v.volSyncPVCs {
Expand Down

0 comments on commit 57d4fab

Please sign in to comment.