fix: honor storage attachment process types at deploy time
An attachment's process type was recorded, reported and used to scope `storage:mount --replace` and `storage:unmount --all`, but nothing read it when the volume was actually mounted, so `storage:mount <app> <entry> --container-dir <path> --process-type web` bound the volume into every process rather than only `web`. Both schedulers now scope a mount to the process type it was declared for, and containers that belong to no process type - a `dokku run` one-off, an `app.json` deploy task, a k3s cron job - receive default-scoped mounts only. A container path can now be claimed by a single mount per process type, and `storage:migrate` drains process-scoped `-v` lines out of `docker-options` rather than only the default-scoped ones.
This commit is contained in:
20 files changed
+1075
-114
No files matched your search
@@ -320,17 +320,6 @@ func resolveMountSpecEntry(appName string, appScheduler string, spec string, par
|
||||
return entry, false, nil
|
||||
}
|
||||
|
||||
// attachmentProcessType returns the process type an attachment is scoped to,
|
||||
// treating an unset value as the default scope so attachments written before
|
||||
// the field existed still sort into a scope.
|
||||
func attachmentProcessType(attachment *Attachment) string {
|
||||
if attachment.ProcessType == "" {
|
||||
return DefaultProcessType
|
||||
}
|
||||
|
||||
return attachment.ProcessType
|
||||
}
|
||||
|
||||
// replaceMounts swaps one process type's entire mount set for the declared one
|
||||
// in a single write, so a caller converging an app onto a declared set no
|
||||
// longer issues one storage:mount or storage:unmount per difference and can no
|
||||
@@ -417,13 +406,24 @@ func replaceMounts(input CommandMountInput) error {
|
||||
return err
|
||||
}
|
||||
|
||||
attachments := []*Attachment{}
|
||||
retained := []*Attachment{}
|
||||
for _, attachment := range existing {
|
||||
if attachmentProcessType(attachment) != processType {
|
||||
attachments = append(attachments, attachment)
|
||||
if attachment.EffectiveProcessType() != processType {
|
||||
retained = append(retained, attachment)
|
||||
}
|
||||
}
|
||||
attachments = append(attachments, declared...)
|
||||
|
||||
// The declared set is already unique on container path within its own
|
||||
// scope; what is left to check is the scopes this call does not replace,
|
||||
// so a declared path cannot collide with one held by another process type.
|
||||
// Checking before the write keeps the all-or-nothing contract.
|
||||
for _, attachment := range declared {
|
||||
if err := ensureContainerPathFree(input.AppName, retained, attachment); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
attachments := append(retained, declared...)
|
||||
|
||||
if err := SaveAttachments(input.AppName, attachments); err != nil {
|
||||
return err
|
||||
@@ -578,7 +578,7 @@ func unmountAll(input CommandUnmountInput) error {
|
||||
|
||||
keep := []*Attachment{}
|
||||
for _, attachment := range attachments {
|
||||
if attachmentProcessType(attachment) != input.ProcessType {
|
||||
if attachment.EffectiveProcessType() != input.ProcessType {
|
||||
keep = append(keep, attachment)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user