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

fix bug causing multiple appName fields appended to logger #69

Merged
merged 1 commit into from
Dec 18, 2024
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
4 changes: 2 additions & 2 deletions charts/radix-cluster-cleanup/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
description: A Helm chart for Kubernetes
name: radix-cluster-cleanup
version: 1.0.17
appVersion: 1.0.17
version: 1.0.18
appVersion: 1.0.18
5 changes: 2 additions & 3 deletions radix-cluster-cleanup/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,14 @@ func runFunctionPeriodically(ctx context.Context, someFunc func(ctx context.Cont
}

func getTooInactiveRrs(ctx context.Context, kubeClient *kube.Kube, inactivityLimit time.Duration, action string) ([]v1.RadixRegistration, error) {
logger := log.Ctx(ctx)
rrs, err := kubeClient.ListRegistrations(ctx)
if err != nil {
return nil, err
}
var rrsForDeletion []v1.RadixRegistration
for _, rr := range rrs {
logger := logger.With().Str("appName", rr.Name).Logger()
ctx = logger.WithContext(ctx)
logger := log.Ctx(ctx).With().Str("appName", rr.Name).Logger()
ctx := logger.WithContext(ctx)

if isWhitelisted(rr) {
logger.Debug().Msg("RadixRegistration is whitelisted, skipping")
Expand Down
7 changes: 4 additions & 3 deletions radix-cluster-cleanup/cmd/stopRrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ func stopRrs(ctx context.Context) error {
if err != nil {
return err
}

for _, rr := range tooInactiveRrs {
ctx = log.Ctx(ctx).With().Str("appName", rr.Name).Logger().WithContext(ctx)
ctx := log.Ctx(ctx).With().Str("appName", rr.Name).Logger().WithContext(ctx)
err := stopRr(ctx, kubeClient, rr)
if err != nil {
return err
Expand All @@ -84,7 +85,7 @@ func stopRr(ctx context.Context, kubeClient *kube.Kube, rr v1.RadixRegistration)
}

for _, rd := range slice.FindAll(rdsForRr, rdIsActive) {
ctx = log.Ctx(ctx).With().Str("deployment", rd.Name).Logger().WithContext(ctx)
ctx := log.Ctx(ctx).With().Str("deployment", rd.Name).Logger().WithContext(ctx)
if err := scaleRdComponentsToZeroReplicas(ctx, kubeClient, rd); err != nil {
return err
}
Expand All @@ -101,10 +102,10 @@ func scaleRdComponentsToZeroReplicas(ctx context.Context, kubeClient *kube.Kube,
componentNames = append(componentNames, rd.Spec.Components[i].Name)
}
_, err := kubeClient.RadixClient().RadixV1().RadixDeployments(rd.Namespace).Update(ctx, &rd, metav1.UpdateOptions{})
logger.Info().Msgf("scaled components %s to 0 replicas", strings.Join(componentNames, ", "))
if err != nil {
return err
}
logger.Info().Msgf("scaled components %s to 0 replicas", strings.Join(componentNames, ", "))
return nil
}

Expand Down
Loading