1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-29 18:29:44 +02:00

fix(db): skip resource control migration if stack doesn't exist (#4879)

This commit is contained in:
Chaim Lev-Ari 2021-02-24 23:27:49 +02:00 committed by GitHub
parent 3746542c69
commit 7e7127831d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,9 @@
package migrator package migrator
import ( import (
"fmt"
portainer "github.com/portainer/portainer/api" portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/bolt/errors"
"github.com/portainer/portainer/api/internal/stackutils"
) )
func (m *Migrator) updateStackResourceControlToDB27() error { func (m *Migrator) updateStackResourceControlToDB27() error {
@ -18,16 +18,17 @@ func (m *Migrator) updateStackResourceControlToDB27() error {
} }
stackName := resource.ResourceID stackName := resource.ResourceID
if err != nil {
return err
}
stack, err := m.stackService.StackByName(stackName) stack, err := m.stackService.StackByName(stackName)
if err != nil { if err != nil {
if err == errors.ErrObjectNotFound {
continue
}
return err return err
} }
resource.ResourceID = fmt.Sprintf("%d_%s", stack.EndpointID, stack.Name) resource.ResourceID = stackutils.ResourceControlID(stack.EndpointID, stack.Name)
err = m.resourceControlService.UpdateResourceControl(resource.ID, &resource) err = m.resourceControlService.UpdateResourceControl(resource.ID, &resource)
if err != nil { if err != nil {