Skip to content

Commit

Permalink
Identify 'kanister-job' prefix pods with jobID
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijit Mukherjee <[email protected]>
  • Loading branch information
mabhi committed Mar 21, 2024
1 parent 80b3a5d commit e72b3eb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/function/kube_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/kanisterio/kanister/pkg/output"
"github.com/kanisterio/kanister/pkg/param"
"github.com/kanisterio/kanister/pkg/progress"
"strings"
)

const (
Expand Down Expand Up @@ -64,6 +65,17 @@ func kubeTask(ctx context.Context, cli kubernetes.Interface, namespace, image st
Command: command,
PodOverride: podOverride,
}
// Mark labels to pods with prefix `jobPrefix`. Add the jobID as reference to the origin for the pod.
fields := field.FromContext(ctx)
for _, f := range fields.Fields() {
if strings.HasPrefix(f.Key(), consts.LabelPrefix) {
jobID := f.Value().(string)
if options.Labels == nil {
options.Labels = make(map[string]string)
}
options.Labels[consts.LabelPrefix+"JobID"] = jobID
}
}

pr := kube.NewPodRunner(cli, options)
podFunc := kubeTaskPodFunc()
Expand Down

0 comments on commit e72b3eb

Please sign in to comment.