1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 21:39:40 +02:00

fix(docker): prevent misconfigured stack from saving EE-3235 (#7585)

* EE-3235 fix(docker): add checker to editor

* support rollback to update stack file

Co-authored-by: chaogeng77977 <chao.geng@portainer.io>
This commit is contained in:
Rex Wang 2022-09-07 16:50:59 +08:00 committed by GitHub
parent d9cc7eda51
commit 9af9395b73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 120 additions and 4 deletions

View file

@ -3,6 +3,7 @@ package stacks
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"strconv"
@ -124,8 +125,12 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
}
stackFolder := strconv.Itoa(int(stack.ID))
projectPath, err := handler.FileService.StoreStackFileFromBytes(stackFolder, stack.EntryPoint, []byte(payload.StackFileContent))
projectPath, err := handler.FileService.UpdateStoreStackFileFromBytes(stackFolder, stack.EntryPoint, []byte(payload.StackFileContent))
if err != nil {
if rollbackErr := handler.FileService.RollbackStackFile(stackFolder, stack.EntryPoint); rollbackErr != nil {
log.Printf("[WARN] [kubernetes,stack,update] [message: rollback stack file error] [err: %s]", rollbackErr)
}
fileType := "Manifest"
if stack.IsComposeFormat {
fileType = "Compose"
@ -135,5 +140,7 @@ func (handler *Handler) updateKubernetesStack(r *http.Request, stack *portainer.
}
stack.ProjectPath = projectPath
handler.FileService.RemoveStackFileBackup(stackFolder, stack.EntryPoint)
return nil
}