Fix: gc resources without resourceversion (#4583)

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive
2022-08-09 19:20:31 +08:00
committed by GitHub
parent aa1f090fb6
commit f23e2a8442
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -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()
+3 -2
View File
@@ -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": "-",
},
}}
}