Skip to content

Commit

Permalink
chore: label cron jobs so they can be matched across different enviro… (
Browse files Browse the repository at this point in the history
#142)

* chore: label cron jobs so they can be matched across different environments

* fix: slog for destroy handler
  • Loading branch information
tonsV2 authored Sep 29, 2024
1 parent f60528b commit 6b2c9e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions helm/chart/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
{{- include "im-inspector.selectorLabels" . | nindent 8 }}
spec:
template:
metadata:
labels:
{{- include "im-inspector.selectorLabels" . | nindent 12 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down
8 changes: 4 additions & 4 deletions pkg/pod/ttlDestroyHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func (t ttlDestroyHandler) Supports() string {

func (t ttlDestroyHandler) Handle(pod v1.Pod) error {
correlationID := uuid.NewString()
t.logger = t.logger.With("correlationId", correlationID)
logger := t.logger.With("correlationId", correlationID)

t.logger.Info("TTL handler invoked", "pod", pod.Name)
logger.Info("TTL handler invoked", "pod", pod.Name)

creationTimestampLabel := pod.Labels["im-creation-timestamp"]
if creationTimestampLabel == "" {
Expand All @@ -47,7 +47,7 @@ func (t ttlDestroyHandler) Handle(pod v1.Pod) error {

ttlLabel := pod.Labels["im-ttl"]
if ttlLabel == "" {
t.logger.Info(`No TTL label "im-ttl" found`)
logger.Info(`No TTL label "im-ttl" found`)
return nil
}

Expand All @@ -72,7 +72,7 @@ func (t ttlDestroyHandler) Handle(pod v1.Pod) error {
if err != nil {
return err
}
t.logger.Info("TTL destroyed", "pod", pod.Name, "namespace", pod.Namespace, "correlationId", correlationID)
logger.Info("TTL destroyed", "pod", pod.Name, "namespace", pod.Namespace, "correlationId", correlationID)
}

return nil
Expand Down

0 comments on commit 6b2c9e9

Please sign in to comment.