Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijit Mukherjee <abhijit.mukherjee@infracloud.io>
  • Loading branch information
mabhi committed Mar 26, 2024
1 parent cb3cc13 commit 9037165
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion pkg/function/kube_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func kubeTask(ctx context.Context, cli kubernetes.Interface, namespace, image st
Command: command,
PodOverride: podOverride,
}

// Mark labels to pods with prefix `kanister.io`. Add the jobID as reference to the origin for the pod.
kube.AddDebugLabelsToPodOptions(ctx, options, consts.LabelPrefix, "JobID")

Expand Down
6 changes: 3 additions & 3 deletions pkg/kube/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"

"github.com/kanisterio/kanister/pkg/consts"
"github.com/kanisterio/kanister/pkg/field"
)

Expand Down Expand Up @@ -179,14 +178,15 @@ func PVCContainsReadOnlyAccessMode(pvc *corev1.PersistentVolumeClaim) bool {
// AddDebugLabelsToPodOptions adds additional label selector to `PodOptions`,
// provided the context has a key starting with `keyPrefix`.
func AddDebugLabelsToPodOptions(ctx context.Context, options *PodOptions, keyPrefix, keySuffix string) {
if fields := field.FromContext(ctx); fields != nil {
fields := field.FromContext(ctx)
if fields != nil {
for _, f := range fields.Fields() {
if strings.HasPrefix(f.Key(), keyPrefix) {
value := f.Value().(string)
if options.Labels == nil {
options.Labels = make(map[string]string)
}
options.Labels[consts.LabelPrefix+keySuffix] = value
options.Labels[keyPrefix+keySuffix] = value
}
}
}
Expand Down

0 comments on commit 9037165

Please sign in to comment.