Skip to content

Commit 9e80e8d

Browse files
authored
chore: remove ClearManagementConflictsWithKind (#1447)
The watch.Runnable interface doesn't need to know how to clear management conflicts, because the watch.Manager already has access to the conflict.Handler. So just clear the conflicts in AddWatches, where it also deals with other conflicts. AddWatches also knows that the watch is no longer needed, whereas stopWatch only knows that it needs to be stopped.
1 parent 15f0b2e commit 9e80e8d

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

pkg/remediator/watch/filteredwatcher.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ const maxWatchRetryFactor = 18
7373
type Runnable interface {
7474
Stop()
7575
Run(ctx context.Context) status.Error
76-
ClearManagementConflictsWithKind(gk schema.GroupKind)
7776
SetLatestCommit(string)
7877
}
7978

@@ -157,10 +156,6 @@ func (w *filteredWatcher) addError(errorID string) bool {
157156
return false
158157
}
159158

160-
func (w *filteredWatcher) ClearManagementConflictsWithKind(gk schema.GroupKind) {
161-
w.conflictHandler.ClearConflictErrorsWithKind(gk)
162-
}
163-
164159
// SetLatestCommit sets the latest observed commit which references the GVK
165160
// watched by this filteredWatcher.
166161
func (w *filteredWatcher) SetLatestCommit(commit string) {

pkg/remediator/watch/manager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ func (m *Manager) UpdateWatches(ctx context.Context, gvkMap map[schema.GroupVers
218218
// It is safe to stop the watcher.
219219
m.stopWatcher(gvk)
220220
stoppedWatches++
221+
// Remove all conflict errors for objects with the same GK because
222+
// the objects are no longer managed by the reconciler.
223+
m.conflictHandler.ClearConflictErrorsWithKind(gvk.GroupKind())
221224
}
222225
}
223226

@@ -322,8 +325,5 @@ func (m *Manager) stopWatcher(gvk schema.GroupVersionKind) {
322325

323326
// Stop the watcher.
324327
w.Stop()
325-
// Remove all conflict errors for objects with the same GK because the
326-
// objects are no longer managed by the reconciler.
327-
w.ClearManagementConflictsWithKind(gvk.GroupKind())
328328
delete(m.watcherMap, gvk)
329329
}

0 commit comments

Comments
 (0)