Skip to content

Commit

Permalink
e2e: updated logs for enable/disable actions
Browse files Browse the repository at this point in the history
Move/update info logs to debug in EnableProtection DisableProtection for managed
and discovered apps

Signed-off-by: Parikshith <[email protected]>
  • Loading branch information
parikshithb authored and nirs committed Feb 17, 2025
1 parent ca44e13 commit ad1b697
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
23 changes: 13 additions & 10 deletions e2e/dractions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ func EnableProtection(ctx types.Context) error {
w := ctx.Workload()
name := ctx.Name()
managementNamespace := ctx.ManagementNamespace()
appNamespace := ctx.AppNamespace()
log := ctx.Logger()

log.Infof("Protecting workload in namespace %q", managementNamespace)
log.Infof("Protecting workload in app namespace %q, management namespace: %q", appNamespace, managementNamespace)

drPolicyName := util.DefaultDRPolicyName
appname := w.GetAppName()
Expand All @@ -48,9 +49,7 @@ func EnableProtection(ctx types.Context) error {
}

clusterName := placementDecision.Status.Decisions[0].ClusterName
log.Infof("Workload running on cluster %q", clusterName)

log.Info("Annotating placement")
log.Debugf("Workload running on cluster %q", clusterName)

err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
placement, err := getPlacement(util.Ctx.Hub.Client, managementNamespace, placementName)
Expand All @@ -64,14 +63,19 @@ func EnableProtection(ctx types.Context) error {

placement.Annotations[OcmSchedulingDisable] = "true"

return updatePlacement(util.Ctx.Hub.Client, placement)
if err := updatePlacement(util.Ctx.Hub.Client, placement); err != nil {
return err
}

log.Debugf("Annotated placement \"%s/%s\" with \"%s: %s\"",
managementNamespace, placementName, OcmSchedulingDisable, placement.Annotations[OcmSchedulingDisable])

return nil
})
if err != nil {
return err
}

log.Info("Creating drpc")

drpc := generateDRPC(name, managementNamespace, clusterName, drPolicyName, placementName, appname)
if err = createDRPC(util.Ctx.Hub.Client, drpc); err != nil {
return err
Expand All @@ -95,15 +99,14 @@ func DisableProtection(ctx types.Context) error {

name := ctx.Name()
managementNamespace := ctx.ManagementNamespace()
appNamespace := ctx.AppNamespace()
log := ctx.Logger()

log.Infof("Unprotecting workload in namespace %q", managementNamespace)
log.Infof("Unprotecting workload in app namespace %q, management namespace: %q", appNamespace, managementNamespace)

drpcName := name
client := util.Ctx.Hub.Client

log.Info("Deleting drpc")

if err := deleteDRPC(client, managementNamespace, drpcName); err != nil {
return err
}
Expand Down
11 changes: 3 additions & 8 deletions e2e/dractions/discovered.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ func EnableProtectionDiscoveredApps(ctx types.Context) error {
managementNamespace := ctx.ManagementNamespace()
appNamespace := ctx.AppNamespace()

// TODO: log cluster namespace for completeness?
log.Infof("Protecting workload in namespace %q", managementNamespace)
log.Infof("Protecting workload in app namespace %q, management namespace: %q", appNamespace, managementNamespace)

drPolicyName := util.DefaultDRPolicyName
appname := w.GetAppName()
Expand All @@ -41,8 +40,6 @@ func EnableProtectionDiscoveredApps(ctx types.Context) error {
return err
}

log.Info("Creating drpc")

clusterName := drpolicy.Spec.DRClusters[0]

drpc := generateDRPCDiscoveredApps(
Expand All @@ -61,17 +58,15 @@ func DisableProtectionDiscoveredApps(ctx types.Context) error {
name := ctx.Name()
log := ctx.Logger()
managementNamespace := ctx.ManagementNamespace()
appNamespace := ctx.AppNamespace()

// TODO: log cluster namespace for completeness?
log.Infof("Unprotecting workload in namespace %q", managementNamespace)
log.Infof("Unprotecting workload in app namespace %q, management namespace: %q", appNamespace, managementNamespace)

placementName := name
drpcName := name

client := util.Ctx.Hub.Client

log.Info("Deleting drpc")

if err := deleteDRPC(client, managementNamespace, drpcName); err != nil {
return err
}
Expand Down

0 comments on commit ad1b697

Please sign in to comment.