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

Adding mount path as env variable in container #7968

Merged
merged 2 commits into from
Jun 7, 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
8 changes: 7 additions & 1 deletion cmd/jobsink/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
job.Labels[sinks.JobSinkIDLabel] = id
job.Labels[sinks.JobSinkNameLabel] = ref.Name
job.OwnerReferences = append(job.OwnerReferences, or)

var mountPathName string
for i := range job.Spec.Template.Spec.Containers {
found := false
for j := range job.Spec.Template.Spec.Containers[i].VolumeMounts {
if job.Spec.Template.Spec.Containers[i].VolumeMounts[j].Name == "jobsink-event" {
found = true
mountPathName = job.Spec.Template.Spec.Containers[i].VolumeMounts[j].MountPath
break
}
}
Expand All @@ -312,7 +313,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ReadOnly: true,
MountPath: "/etc/jobsink-event",
})
mountPathName = "/etc/jobsink-event"
}
job.Spec.Template.Spec.Containers[i].Env = append(job.Spec.Template.Spec.Containers[i].Env, corev1.EnvVar{
Name: "K_EVENT_PATH",
Value: mountPathName,
})
Comment on lines +318 to +321
Copy link
Member

@pierDipi pierDipi Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an edge case but we need to check if the env variable is already defined or not here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it was not mentioned, when existing code was checked

}

found := false
Expand Down
Loading