diff --git a/pkg/resourcekeeper/cache.go b/pkg/resourcekeeper/cache.go index 84ad5b209..121af1bb1 100644 --- a/pkg/resourcekeeper/cache.go +++ b/pkg/resourcekeeper/cache.go @@ -113,7 +113,7 @@ func (cache *resourceCache) exists(manifest *unstructured.Unstructured) bool { return true } appKey, controlledBy := apply.GetAppKey(cache.app), apply.GetControlledBy(manifest) - if appKey == controlledBy { + if appKey == controlledBy || manifest.GetResourceVersion() == "" { return true } annotations := manifest.GetAnnotations() diff --git a/pkg/resourcekeeper/cache_test.go b/pkg/resourcekeeper/cache_test.go index be798eebe..1a736ddfd 100644 --- a/pkg/resourcekeeper/cache_test.go +++ b/pkg/resourcekeeper/cache_test.go @@ -139,8 +139,9 @@ func TestResourceCacheExistenceCheck(t *testing.T) { createResource := func(appName, appNs, sharedBy string) *unstructured.Unstructured { return &unstructured.Unstructured{Object: map[string]interface{}{ "metadata": map[string]interface{}{ - "labels": map[string]interface{}{oam.LabelAppName: appName, oam.LabelAppNamespace: appNs}, - "annotations": map[string]interface{}{oam.AnnotationAppSharedBy: sharedBy}, + "labels": map[string]interface{}{oam.LabelAppName: appName, oam.LabelAppNamespace: appNs}, + "annotations": map[string]interface{}{oam.AnnotationAppSharedBy: sharedBy}, + "resourceVersion": "-", }, }} }