Skip to content

Commit

Permalink
Add extra finalizers to stop metal3data/dataClaim from being deletable
Browse files Browse the repository at this point in the history
while in use.

Signed-off-by: Max Rantil <[email protected]>
  • Loading branch information
Max Rantil committed Feb 28, 2024
1 parent c9a0a3b commit b4c9431
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions baremetal/metal3data_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ func (m *DataManager) SetFinalizer() {
infrav1.DataFinalizer,
)
}
if !Contains(m.Data.Finalizers, infrav1.MachineFinalizer) {
m.Data.Finalizers = append(m.Data.Finalizers,
infrav1.MachineFinalizer,
)
}
}

// UnsetFinalizer unsets finalizer.
Expand All @@ -96,6 +101,9 @@ func (m *DataManager) UnsetFinalizer() {
m.Data.Finalizers = Filter(m.Data.Finalizers,
infrav1.DataFinalizer,
)
m.Data.Finalizers = Filter(m.Data.Finalizers,
infrav1.MachineFinalizer,
)
}

// clearError clears error message from Metal3Data status.
Expand Down
5 changes: 5 additions & 0 deletions baremetal/metal3datatemplate_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@ func (m *DataTemplateManager) createData(ctx context.Context,
infrav1.DataClaimFinalizer,
)
}
if !Contains(dataClaim.Finalizers, infrav1.MachineFinalizer) {
dataClaim.Finalizers = append(dataClaim.Finalizers,
infrav1.MachineFinalizer,
)
}

if dataClaimIndex, ok := m.DataTemplate.Status.Indexes[dataClaim.Name]; ok {
if m.DataTemplate.Spec.TemplateReference != "" {
Expand Down

0 comments on commit b4c9431

Please sign in to comment.