-
Notifications
You must be signed in to change notification settings - Fork 27
Support multiple volume items in the same directory using subPath #301
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -92,10 +92,38 @@ func AuthorinoDeployment(authorino *api.Authorino) *k8sapps.Deployment { | |
| }, | ||
| }) | ||
|
|
||
| volumeMounts = append(volumeMounts, k8score.VolumeMount{ | ||
| Name: volume.Name, | ||
| MountPath: volume.MountPath, | ||
| }) | ||
| if len(volume.Items) == 0 { | ||
| volumeMounts = append(volumeMounts, k8score.VolumeMount{ | ||
| Name: volume.Name, | ||
| MountPath: volume.MountPath, | ||
| }) | ||
| continue | ||
| } | ||
|
|
||
| for _, item := range volume.Items { | ||
| path := item.Path | ||
| if path == "" { | ||
| path = item.Key | ||
| } | ||
|
|
||
| mountPath := volume.MountPath | ||
| // For multiple items, always treat mountPath as a directory. | ||
| // For a single item, check if mountPath already includes the full path. | ||
| if len(volume.Items) > 1 || !strings.HasSuffix(mountPath, "/"+path) { | ||
| // mountPath is a directory, append the path | ||
| if !strings.HasSuffix(mountPath, "/") { | ||
| mountPath = mountPath + "/" | ||
| } | ||
| mountPath = mountPath + path | ||
| } | ||
|
|
||
| volumeMount := k8score.VolumeMount{ | ||
| Name: volume.Name, | ||
| MountPath: mountPath, | ||
| SubPath: path, | ||
| } | ||
|
Comment on lines
+120
to
+124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In Kubernetes, subPath volume mounts backed by Secret, ConfigMap, or projected volumes do not receive live updates when the source object changes. A pod restart is required to pick up the changes. Citations:
SubPath mounts prevent automatic Secret/ConfigMap updates. Using Code locationLines 119–123 in pkg/reconcilers/deployment.go 🤖 Prompt for AI Agents |
||
| volumeMounts = append(volumeMounts, volumeMount) | ||
| } | ||
| } | ||
|
|
||
| // mount tls cert volume for the ext_authz listener if enable | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against empty
pathwhen bothitem.Pathanditem.Keyare unset.If both fields are empty strings,
pathremains empty, resulting in an emptySubPath(which mounts the entire volume instead of a specific file) and a malformedmountPathending with just/. Consider skipping items with no resolvable path or logging a warning.🛡️ Proposed defensive guard
for _, item := range volume.Items { path := item.Path if path == "" { path = item.Key } + if path == "" { + // Skip items with no resolvable path to avoid malformed mounts + continue + } mountPath := volume.MountPath📝 Committable suggestion
🤖 Prompt for AI Agents