Skip to content

Commit

Permalink
e2e: logs for mcsb and placement functions
Browse files Browse the repository at this point in the history
Add debug logs for Create and delete ManagedClusterSetBinding,
createPlacementManagedByRamen, CreatePlacement and DeletePlacement for
managed apps

Signed-off-by: Parikshith <[email protected]>
  • Loading branch information
parikshithb committed Feb 7, 2025
1 parent d64e764 commit 70fa6b9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion e2e/deployers/applicationset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (a ApplicationSet) Deploy(ctx types.Context) error {

log.Infof("Deploying applicationset in namespace %q", managementNamespace)

err := CreateManagedClusterSetBinding(McsbName, managementNamespace)
err := CreateManagedClusterSetBinding(ctx, McsbName, managementNamespace)
if err != nil {
return err
}
Expand Down
17 changes: 13 additions & 4 deletions e2e/deployers/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const (
fMode = 0o600
)

func CreateManagedClusterSetBinding(name, namespace string) error {
func CreateManagedClusterSetBinding(ctx types.Context, name, namespace string) error {
log := ctx.Logger()
labels := make(map[string]string)
labels[AppLabelKey] = namespace
mcsb := &ocmv1b2.ManagedClusterSetBinding{
Expand All @@ -49,6 +50,8 @@ func CreateManagedClusterSetBinding(name, namespace string) error {
},
}

log.Debugf("Creating ManagedClusterSetBinding %q in namespace %q", name, namespace)

err := util.Ctx.Hub.Client.Create(context.Background(), mcsb)
if err != nil {
if !errors.IsAlreadyExists(err) {
Expand All @@ -68,13 +71,15 @@ func DeleteManagedClusterSetBinding(ctx types.Context, name, namespace string) e
},
}

log.Debugf("Deleting ManagedClusterSetBinding %q in namespace %q", name, namespace)

err := util.Ctx.Hub.Client.Delete(context.Background(), mcsb)
if err != nil {
if !errors.IsNotFound(err) {
return err
}

log.Infof("ManagedClusterSetBinding %q not found", name)
log.Debugf("ManagedClusterSetBinding %q not found", name)
}

return nil
Expand All @@ -99,13 +104,15 @@ func CreatePlacement(ctx types.Context, name, namespace string) error {
},
}

log.Debugf("Creating placement %q in namespace %q", name, namespace)

err := util.Ctx.Hub.Client.Create(context.Background(), placement)
if err != nil {
if !errors.IsAlreadyExists(err) {
return err
}

log.Info("Placement already Exists")
log.Debugf("Placement %q already Exists", name)
}

return nil
Expand All @@ -120,13 +127,15 @@ func DeletePlacement(ctx types.Context, name, namespace string) error {
},
}

log.Debugf("Deleting placement %q in namespace %q", name, namespace)

err := util.Ctx.Hub.Client.Delete(context.Background(), placement)
if err != nil {
if !errors.IsNotFound(err) {
return err
}

log.Info("Placement not found")
log.Debugf("Placement %q not found", name)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion e2e/deployers/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (s Subscription) Deploy(ctx types.Context) error {
return err
}

err = CreateManagedClusterSetBinding(McsbName, managementNamespace)
err = CreateManagedClusterSetBinding(ctx, McsbName, managementNamespace)
if err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion e2e/dractions/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ func createPlacementManagedByRamen(ctx types.Context, name, namespace string) er
},
}

log.Debugf("Creating placement %q in namespace %q", name, namespace)

err := util.Ctx.Hub.Client.Create(context.Background(), placement)
if err != nil {
if !errors.IsAlreadyExists(err) {
return err
}

log.Info("Placement already Exists")
log.Debugf("Placement %q already Exists", name)
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion e2e/dractions/discovered.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func EnableProtectionDiscoveredApps(ctx types.Context) error {
drpcName := name

// create mcsb default in ramen-ops ns
if err := deployers.CreateManagedClusterSetBinding(deployers.McsbName, managementNamespace); err != nil {
if err := deployers.CreateManagedClusterSetBinding(ctx, deployers.McsbName, managementNamespace); err != nil {
return err
}

Expand Down

0 comments on commit 70fa6b9

Please sign in to comment.