From 05aad4d86fbf897fbed90ae4b845228dd496cbde Mon Sep 17 00:00:00 2001 From: Utku Ozdemir Date: Thu, 5 Jun 2025 19:28:13 +0200 Subject: [PATCH] fix: check config patch creation time as well as updated on orphan check In the config patch cleanup controller, we falsely assumed that the resource update time was set to be the same as the creation time. This in very rare cases caused the cleanup controller started by the runtime in the tests to prune the config patch created by the test itself, failing it sporadically. This should fix the rare test flake we have: ```text #66 4.431 grpc_test.go:266: #66 4.431 Error Trace: /src/internal/backend/grpc/grpc_test.go:266 #66 4.431 Error: Received unexpected error: #66 4.431 rpc error: code = NotFound desc = resource ConfigPatches.omni.sidero.dev(default/1@undefined) doesn't exist #66 4.431 Test: TestGrpcSuite/TestCrud ``` Signed-off-by: Utku Ozdemir --- .../runtime/omni/controllers/omni/config_patch_cleanup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/backend/runtime/omni/controllers/omni/config_patch_cleanup.go b/internal/backend/runtime/omni/controllers/omni/config_patch_cleanup.go index 788c7918..b27dd306 100644 --- a/internal/backend/runtime/omni/controllers/omni/config_patch_cleanup.go +++ b/internal/backend/runtime/omni/controllers/omni/config_patch_cleanup.go @@ -179,7 +179,7 @@ func (ctrl *ConfigPatchCleanupController) isOrphan(ctx context.Context, r contro return false, nil } - if time.Since(configPatch.Metadata().Updated()) < ctrl.DeleteOlderThan { + if time.Since(configPatch.Metadata().Updated()) < ctrl.DeleteOlderThan || time.Since(configPatch.Metadata().Created()) < ctrl.DeleteOlderThan { return false, nil }