Skip to content
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

update (*AppManagement).GetAppGrid(...) to ignore any replacement container created to apply settings or update #97

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ require (
)

require (
github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha6
github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha8
github.com/compose-spec/compose-go v1.9.0
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf
github.com/docker/cli v23.0.0+incompatible
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha6 h1:5N8y2ubnTfeyaxrKSV6wl7j8ob5LW9lW8xCudljGgp0=
github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha6/go.mod h1:2IuYyy5qW1BE6jqC6M+tOU+WtUec1K565rLATBJ9p/0=
github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha8 h1:UhCg3d9Cxhx7KVmqh8oUrUl1qFmFdcHee3Zkk4+P2JA=
github.com/IceWhaleTech/CasaOS-Common v0.4.4-alpha8/go.mod h1:2IuYyy5qW1BE6jqC6M+tOU+WtUec1K565rLATBJ9p/0=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
github.com/Microsoft/hcsshim v0.9.6 h1:VwnDOgLeoi2du6dAznfmspNqTiwczvjv4K7NxuY9jsY=
Expand Down
25 changes: 25 additions & 0 deletions route/v2/internal_web.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/IceWhaleTech/CasaOS-Common/utils"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger"
"github.com/compose-spec/compose-go/types"
"github.com/docker/compose/v2/pkg/api"
"github.com/labstack/echo/v4"
"github.com/samber/lo"
"go.uber.org/zap"
Expand Down Expand Up @@ -64,6 +65,30 @@ func (a *AppManagement) GetAppGrid(ctx echo.Context) error {
return codegen.WebAppGridItem{}, false
}

// check if this is a replacement container for a compose app when applying new settings or updating.
//
// we need this logic so that user does not see the temporary replacement container in the UI.
{
container, err := service.MyService.Docker().GetContainerByName(app.Name)
if err != nil {
logger.Error("failed to get container by name", zap.Error(err), zap.String("container", app.Name))
return codegen.WebAppGridItem{}, false
}

// see recreateContainer() func from https://github.com/docker/compose/blob/v2/pkg/compose/convergence.go
if replaceLabel, ok := container.Labels[api.ContainerReplaceLabel]; ok {
if lo.ContainsBy(
composeAppContainers,
func(container codegen.ContainerSummary) bool {
return container.ID == replaceLabel
},
) {
// this is a replacement container for a compose app, skipping...
return codegen.WebAppGridItem{}, false
}
}
}

item, err := WebAppGridItemAdapterContainer(&app)
if err != nil {
logger.Error("failed to adapt web app grid item", zap.Error(err), zap.String("app", app.Name))
Expand Down