Skip to content

Commit a2f1601

Browse files
committed
fix: improve logic in syncer and snapshothandler to handle e2e tests failures
1 parent c368b21 commit a2f1601

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

pkg/controllers/resources/ingresses/syncer.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,8 @@ func (s *ingressSyncer) Syncer() syncertypes.Sync[client.Object] {
6262

6363
func (s *ingressSyncer) SyncToHost(ctx *synccontext.SyncContext, event *synccontext.SyncToHostEvent[*networkingv1.Ingress]) (ctrl.Result, error) {
6464
if s.applyLimitByClass(ctx, event.Virtual) {
65-
s.EventRecorder().Eventf(
66-
event.Virtual,
67-
nil,
68-
"Warning",
69-
"SyncWarning",
70-
"IngressSyncWarning",
71-
"did not sync ingress %q to host because it does not match the selector under 'sync.fromHost.ingressClasses.selector'",
72-
event.Virtual.GetName(),
73-
)
65+
// applyLimitByClass already logs the appropriate error message with details
66+
// (including ingress class name), so we don't need to log another message here
7467
return ctrl.Result{}, nil
7568
}
7669

pkg/snapshot/volumes/csi/snapshothandler.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,18 @@ func (h *snapshotHandler) cleanupVolumeSnapshotResource(ctx context.Context, vol
197197
if volumeSnapshot == nil && volumeSnapshotContent == nil {
198198
return true, nil
199199
}
200+
201+
// Check if resources are already being deleted (have DeletionTimestamp set)
202+
// If they are, we just need to wait for them to be fully deleted
203+
volumeSnapshotDeleting := volumeSnapshot != nil && !volumeSnapshot.DeletionTimestamp.IsZero()
204+
volumeSnapshotContentDeleting := volumeSnapshotContent != nil && !volumeSnapshotContent.DeletionTimestamp.IsZero()
205+
206+
// If all existing resources are already being deleted, wait for deletion to complete
207+
if (volumeSnapshot == nil || volumeSnapshotDeleting) && (volumeSnapshotContent == nil || volumeSnapshotContentDeleting) {
208+
h.logger.Debugf("VolumeSnapshot %s/%s and/or VolumeSnapshotContent are already being deleted, waiting for deletion to complete", volumeSnapshotNamespace, volumeSnapshotName)
209+
return false, nil
210+
}
211+
200212
err = h.updateAndDeleteVolumeSnapshotResource(ctx, volumeSnapshot, volumeSnapshotContent, snapshotsv1api.VolumeSnapshotContentRetain)
201213
if err != nil {
202214
return false, fmt.Errorf("failed to cleanup volume snapshot resources: %w", err)

0 commit comments

Comments
 (0)