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

names of deleted ClusterRoleBindings are logged #569

Merged
merged 5 commits into from
Dec 17, 2024
Merged
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
Expand Up @@ -33,7 +33,7 @@ func sFnApplyClusterRoleBindings(ctx context.Context, m *fsm, s *systemState) (s
var crbList rbacv1.ClusterRoleBindingList
if err := shootAdminClient.List(ctx, &crbList); err != nil {
updateCRBApplyFailed(&s.instance)
m.log.Info("Cannot list Cluster Role Bindings on shoot, scheduling for retry", "RuntimeCR", s.instance.Name, "shoot", s.shoot.Name)
m.log.Info("Cannot list Cluster Role Bindings on shoot, scheduling for retry")
return requeue()
}

Expand All @@ -46,9 +46,10 @@ func sFnApplyClusterRoleBindings(ctx context.Context, m *fsm, s *systemState) (s
} {
if err := fn(); err != nil {
updateCRBApplyFailed(&s.instance)
m.log.Info("Cannot setup Cluster Role Bindings on shoot, scheduling for retry", "RuntimeCR", s.instance.Name, "shoot", s.shoot.Name)
m.log.Info("Cannot setup Cluster Role Bindings on shoot, scheduling for retry")
return requeue()
}
logDeletedClusterRoleBindings(removed, m, s)
}

s.instance.UpdateStateReady(
Expand All @@ -60,6 +61,16 @@ func sFnApplyClusterRoleBindings(ctx context.Context, m *fsm, s *systemState) (s
return updateStatusAndStop()
}

func logDeletedClusterRoleBindings(removed []rbacv1.ClusterRoleBinding, m *fsm, s *systemState) {
if len(removed) > 0 {
var crbsNames []string
for _, binding := range removed {
crbsNames = append(crbsNames, binding.Name)
}
m.log.Info("Following CRBs were deleted", "deletedCRBs", crbsNames)
}
}

//nolint:gochecknoglobals
var GetShootClient = func(ctx context.Context, cnt client.Client, runtime imv1.Runtime) (client.Client, error) {
runtimeID := runtime.Labels[imv1.LabelKymaRuntimeID]
Expand Down Expand Up @@ -213,6 +224,7 @@ var newDelCRBs = func(ctx context.Context, shootClient client.Client, crbs []rba
return err
}
}

return nil
}
}
Expand Down
Loading