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

pull/4414/merge
Chaim Lev-Ari 4 years ago committed by GitHub
parent 3746542c69
commit 7e7127831d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,9 +1,9 @@
package migrator
import (
"fmt"
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 {
@ -18,16 +18,17 @@ func (m *Migrator) updateStackResourceControlToDB27() error {
}
stackName := resource.ResourceID
if err != nil {
return err
}
stack, err := m.stackService.StackByName(stackName)
if err != nil {
if err == errors.ErrObjectNotFound {
continue
}
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)
if err != nil {

Loading…
Cancel
Save