mirror of https://github.com/portainer/portainer
fix(db): skip resource control migration if stack doesn't exist (#4879)
parent
3746542c69
commit
7e7127831d
|
@ -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…
Reference in New Issue