diff --git a/baremetal/metal3data_manager.go b/baremetal/metal3data_manager.go index 3853ab6e80..8bbca8e1d5 100644 --- a/baremetal/metal3data_manager.go +++ b/baremetal/metal3data_manager.go @@ -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. @@ -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. diff --git a/baremetal/metal3datatemplate_manager.go b/baremetal/metal3datatemplate_manager.go index 3e98ca35b9..8d8169c8a1 100644 --- a/baremetal/metal3datatemplate_manager.go +++ b/baremetal/metal3datatemplate_manager.go @@ -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 != "" { @@ -414,6 +419,9 @@ func (m *DataTemplateManager) deleteData(ctx context.Context, dataClaim.Finalizers = Filter(dataClaim.Finalizers, infrav1.DataClaimFinalizer, ) + dataClaim.Finalizers = Filter(dataClaim.Finalizers, + infrav1.MachineFinalizer, + ) m.Log.Info("Deleted Claim", "Metal3DataClaim", dataClaim.Name)