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
|
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 {
|
||||||
|
|
Loading…
Reference in New Issue