Skip to content

Commit

Permalink
[PWX-34991] Fetching rules from migration namespace instead of namesp…
Browse files Browse the repository at this point in the history
…ace to migrate (#1569)
  • Loading branch information
olavangad-px authored Nov 23, 2023
1 parent f108248 commit 4794e40
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions pkg/migration/controllers/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -907,16 +907,12 @@ func (m *MigrationController) runPreExecRule(migration *stork_api.Migration, mig
return nil, nil
}
}
r, err := storkops.Instance().GetRule(migration.Spec.PreExecRule, migration.Namespace)
if err != nil {
return nil, err
}
terminationChannels := make([]chan bool, 0)
for _, ns := range migrationNamespaces {
r, err := storkops.Instance().GetRule(migration.Spec.PreExecRule, ns)
if err != nil {
for _, channel := range terminationChannels {
channel <- true
}
return nil, err
}

ch, err := rule.ExecuteRule(r, rule.PreExecRule, migration, ns)
if err != nil {
for _, channel := range terminationChannels {
Expand All @@ -932,15 +928,14 @@ func (m *MigrationController) runPreExecRule(migration *stork_api.Migration, mig
}

func (m *MigrationController) runPostExecRule(migration *stork_api.Migration, migrationNamespaces []string) error {
r, err := storkops.Instance().GetRule(migration.Spec.PostExecRule, migration.Namespace)
if err != nil {
return err
}
for _, ns := range migrationNamespaces {
r, err := storkops.Instance().GetRule(migration.Spec.PostExecRule, ns)
if err != nil {
return err
}

_, err = rule.ExecuteRule(r, rule.PostExecRule, migration, ns)
if err != nil {
return fmt.Errorf("error executing PreExecRule for namespace %v: %v", ns, err)
return fmt.Errorf("error executing PostExecRule for namespace %v: %v", ns, err)
}
}
return nil
Expand Down

0 comments on commit 4794e40

Please sign in to comment.