fix(stacks): pass prune option through the deploy pipeline [BE-12738] (#2098)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Chaim Lev-Ari
2026-03-22 12:37:40 +02:00
committed by GitHub
parent 5670216d7e
commit a2fee4fc4c
15 changed files with 180 additions and 37 deletions
+12 -1
View File
@@ -26,6 +26,8 @@ type updateComposeStackPayload struct {
Env []portainer.Pair
// RepullImageAndRedeploy indicates whether to force repulling images and redeploying the stack
RepullImageAndRedeploy bool
// Prune services that are no longer referenced
Prune bool `example:"true"`
// Deprecated(2.36): use RepullImageAndRedeploy instead for cleaner responsibility
// Force a pulling to current image with the original tag though the image is already the latest
@@ -45,7 +47,7 @@ type updateSwarmStackPayload struct {
StackFileContent string `example:"version: 3\n services:\n web:\n image:nginx"`
// A list of environment(endpoint) variables used during stack deployment
Env []portainer.Pair
// Prune services that are no longer referenced (only available for Swarm stacks)
// Prune services that are no longer referenced
Prune bool `example:"true"`
// RepullImageAndRedeploy indicates whether to force repulling images and redeploying the stack
RepullImageAndRedeploy bool
@@ -242,6 +244,7 @@ func (handler *Handler) updateComposeStack(tx dataservices.DataStoreTx, r *http.
endpoint,
handler.FileService,
handler.StackDeployer,
payload.Prune,
payload.RepullImageAndRedeploy,
payload.RepullImageAndRedeploy)
if err != nil {
@@ -252,6 +255,14 @@ func (handler *Handler) updateComposeStack(tx dataservices.DataStoreTx, r *http.
return httperror.InternalServerError(err.Error(), err)
}
if stack.Option != nil {
stack.Option.Prune = payload.Prune
} else {
stack.Option = &portainer.StackOption{
Prune: payload.Prune,
}
}
// Deploy the stack
if err := composeDeploymentConfig.Deploy(); err != nil {
if rollbackErr := handler.FileService.RollbackStackFile(stackFolder, stack.EntryPoint); rollbackErr != nil {