fix: fail deploy tasks when a docker-args trigger fails

The ephemeral containers that run `app.json` deploy tasks ignored a failure from the `docker-args-deploy` and `docker-args-process-deploy` triggers, so a plugin refusing to describe the container produced a task that ran without the arguments it had asked for, while the very same failure aborted the deploy moments later on the scheduler's own path. Both are now fatal, which the trigger documentation states. Storage no longer reports a scheduler mismatch for an app deploying with another scheduler, since those triggers are fired for every app whatever its scheduler and a k3s app's volumes are mounted by k3s rather than bound into a container here.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-09-21 23:35:28 -04:00
1 parent 14bdc1b2bd
commit 17cf249f2e
5 files changed
+70 -15

No files matched your search

+4
View File
@@ -20,6 +20,10 @@ func withTempLibRoot(t *testing.T) string {
t.Helper()
dir := t.TempDir()
t.Setenv("DOKKU_LIB_ROOT", dir)
// Point plugn at an empty tree so anything resolving a plugin trigger in
// these tests falls back to its default instead of reading the host's
// real dokku install.
t.Setenv("PLUGIN_PATH", filepath.Join(dir, "plugins"))
current, err := user.Current()
if err != nil {
+14
View File
@@ -264,7 +264,17 @@ func TriggerDockerArgs(appName string, phase string, processType string) error {
// Every attachment in the phase is resolved and scheduler-checked, not just
// the ones in scope, so an entry created for the wrong scheduler still fails
// the deploy no matter which process type happens to be starting.
//
// Apps on another scheduler emit nothing rather than failing: the docker-args
// triggers are invoked for every app, whatever its scheduler, because the
// app.json deploy-task path builds its ephemeral container with docker
// directly. A k3s app's volumes are PersistentVolumeClaims mounted by its own
// scheduler and there is nothing to bind-mount here.
func dockerVFlagsForProcess(appName string, phase string, processType string) ([]string, error) {
if appSchedulerFor(appName) != SchedulerDockerLocal {
return nil, nil
}
attachments, err := AttachmentsForPhase(appName, phase)
if err != nil {
return nil, err
@@ -291,6 +301,10 @@ func dockerVFlagsForProcess(appName string, phase string, processType string) ([
return flags, nil
}
// appSchedulerFor resolves the scheduler an app deploys with. It is a variable
// so tests can exercise the non-docker-local path without a plugn install.
var appSchedulerFor = common.GetAppScheduler
// buildDockerVFlag formats the Docker -v argument for a docker-local
// attachment.
func buildDockerVFlag(entry *Entry, attachment *Attachment) string {
+32
View File
@@ -109,6 +109,38 @@ func TestTriggerDockerArgsRejectsSchedulerMismatchOutOfScope(t *testing.T) {
Expect(err).To(HaveOccurred())
}
// TestDockerVFlagsForProcessSkipsOtherSchedulers covers apps that do not
// deploy with docker-local. The docker-args triggers are fired for every app -
// the app.json deploy-task path builds its ephemeral container with docker
// whatever the app's scheduler is - so a k3s app reaches this code with k3s
// entries attached. Those are PersistentVolumeClaims its own scheduler mounts,
// so the right answer is no flags, not an error.
func TestDockerVFlagsForProcessSkipsOtherSchedulers(t *testing.T) {
RegisterTestingT(t)
root := withTempLibRoot(t)
previous := appSchedulerFor
appSchedulerFor = func(string) string { return SchedulerK3s }
t.Cleanup(func() { appSchedulerFor = previous })
Expect(SaveEntry(&Entry{
Name: "demo-pvc",
Scheduler: SchedulerK3s,
})).To(Succeed())
writeAttachmentsFile(t, root, "demo", []*Attachment{
{
EntryName: "demo-pvc",
ContainerPath: "/data",
Phases: []string{PhaseDeploy},
},
})
flags, err := dockerVFlagsForProcess("demo", PhaseDeploy, "web")
Expect(err).NotTo(HaveOccurred())
Expect(flags).To(BeEmpty())
}
// TestDockerVFlagsForProcessScopes is the docker-local half of #9059. An
// attachment scoped to a named process type reaches that process only; the
// default scope reaches every process, including containers that belong to no