Skip to content

Commit

Permalink
fix: ignore not found ClusterMachine in the migrations
Browse files Browse the repository at this point in the history
`migrateInstallImageConfigIntoGenOptions` was missing that check.
Add the check and add the test.

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
  • Loading branch information
Unix4ever committed Jun 11, 2024
1 parent a2c3802 commit 2e64c31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/backend/runtime/omni/migration/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,9 @@ func (suite *MigrationSuite) TestMigrateInstallImageConfigIntoGenOptions() {

for _, res := range []resource.Resource{
clusterMachine, clusterMachineConfig, configPatches, genOptions, clusterSecrets, lbConfig, cluster,
omni.NewMachineStatus(resources.DefaultNamespace, "test2"),
omni.NewMachineConfigGenOptions(resources.DefaultNamespace, "test2"),
omni.NewClusterMachineTalosVersion(resources.DefaultNamespace, "test2"),
} {
suite.Require().NoError(suite.state.Create(ctx, res, state.WithCreateOwner(res.Metadata().Owner())))
}
Expand Down
4 changes: 4 additions & 0 deletions internal/backend/runtime/omni/migration/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,10 @@ func migrateInstallImageConfigIntoGenOptions(ctx context.Context, st state.State
var clusterMachine *omni.ClusterMachine

if clusterMachine, err = safe.StateGetByID[*omni.ClusterMachine](ctx, st, genOptions.Metadata().ID()); err != nil {
if state.IsNotFoundError(err) {
continue
}

return err
}

Expand Down

0 comments on commit 2e64c31

Please sign in to comment.