Merge pull request #3966 from ikaven1024/fix-map-crash

fix addAnnotationWithClusterName crash
This commit is contained in:
karmada-bot 2023-08-22 10:33:01 +08:00 committed by GitHub
commit cb4a8b33e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -119,7 +119,7 @@ func (r *SearchREST) getObjectItemsFromClusters(
objGVR, namespace, name, cluster.Name, err)
continue
}
items = append(items, addAnnotationWithClusterName([]runtime.Object{resourceObject}, cluster.Name)...)
items = append(items, addAnnotationWithClusterName([]runtime.Object{resourceObject.DeepCopyObject()}, cluster.Name)...)
} else {
var resourceObjects []runtime.Object
if len(namespace) > 0 {
@ -132,7 +132,13 @@ func (r *SearchREST) getObjectItemsFromClusters(
objGVR, cluster.Name, err)
continue
}
items = append(items, addAnnotationWithClusterName(resourceObjects, cluster.Name)...)
cloneObjects := make([]runtime.Object, len(resourceObjects))
for i := range resourceObjects {
cloneObjects[i] = resourceObjects[i].DeepCopyObject()
}
items = append(items, addAnnotationWithClusterName(cloneObjects, cluster.Name)...)
}
}