From d4da468dc301147977b4c44651482761795cf05d Mon Sep 17 00:00:00 2001 From: calvin0327 Date: Sun, 5 Jun 2022 20:58:12 +0800 Subject: [PATCH] move this annotation key `cluster.karmada.io/name` to the Cluster API. Signed-off-by: calvin0327 --- .../{well_known_taints.go => well_known_constants.go} | 5 ++++- pkg/registry/search/storage/cache.go | 4 ++-- pkg/search/backendstore/opensearch.go | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) rename pkg/apis/cluster/v1alpha1/{well_known_taints.go => well_known_constants.go} (78%) diff --git a/pkg/apis/cluster/v1alpha1/well_known_taints.go b/pkg/apis/cluster/v1alpha1/well_known_constants.go similarity index 78% rename from pkg/apis/cluster/v1alpha1/well_known_taints.go rename to pkg/apis/cluster/v1alpha1/well_known_constants.go index 5f6eb6627..02107352d 100644 --- a/pkg/apis/cluster/v1alpha1/well_known_taints.go +++ b/pkg/apis/cluster/v1alpha1/well_known_constants.go @@ -4,7 +4,6 @@ const ( // TaintClusterUnscheduler will be added when cluster becomes unschedulable // and removed when cluster becomes scheduable. TaintClusterUnscheduler = "cluster.karmada.io/unschedulable" - // TaintClusterNotReady will be added when cluster is not ready // and removed when cluster becomes ready. TaintClusterNotReady = "cluster.karmada.io/not-ready" @@ -12,4 +11,8 @@ const ( // (corresponding to ClusterConditionReady status ConditionUnknown) // and removed when cluster becomes reachable (ClusterConditionReady status ConditionTrue). TaintClusterUnreachable = "cluster.karmada.io/unreachable" + + // CacheSourceAnnotationKey is the annotation that added to a resource to + // represent which cluster it cached from. + CacheSourceAnnotationKey = "resource.karmada.io/cached-from-cluster" ) diff --git a/pkg/registry/search/storage/cache.go b/pkg/registry/search/storage/cache.go index 3f480415d..d6fbb4cdc 100644 --- a/pkg/registry/search/storage/cache.go +++ b/pkg/registry/search/storage/cache.go @@ -140,8 +140,8 @@ func addAnnotationWithClusterName(resourceObjects []runtime.Object, clusterName if annotations == nil { annotations = make(map[string]string) } - // TODO: move this annotation key `cluster.karmada.io/name` to the Cluster API. - annotations["cluster.karmada.io/name"] = clusterName + + annotations[clusterv1alpha1.CacheSourceAnnotationKey] = clusterName resource.SetAnnotations(annotations) resources = append(resources, resource) diff --git a/pkg/search/backendstore/opensearch.go b/pkg/search/backendstore/opensearch.go index bd1f39abd..7585fe9f5 100644 --- a/pkg/search/backendstore/opensearch.go +++ b/pkg/search/backendstore/opensearch.go @@ -175,7 +175,8 @@ func (os *OpenSearch) upsert(obj interface{}) { if annotations == nil { annotations = make(map[string]string) } - annotations["cluster.karmada.io/name"] = os.cluster + + annotations[clusterv1alpha1.CacheSourceAnnotationKey] = os.cluster us.SetAnnotations(annotations) doc := map[string]interface{}{