Skip to content

Commit bfc0f6f

Browse files
cleanup dead code of generating PropagationPolicy permanent id
Signed-off-by: whitewindmills <[email protected]>
1 parent b217a9c commit bfc0f6f

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

pkg/detector/detector.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -720,26 +720,9 @@ func (d *ResourceDetector) GetUnstructuredObject(objectKey keys.ClusterWideKey)
720720
return unstructuredObj, nil
721721
}
722722

723-
func (d *ResourceDetector) getPropagationPolicyID(policy *policyv1alpha1.PropagationPolicy) (string, error) {
724-
id := util.GetLabelValue(policy.GetLabels(), policyv1alpha1.PropagationPolicyPermanentIDLabel)
725-
if id == "" {
726-
id = uuid.New().String()
727-
policy.Labels = util.DedupeAndMergeLabels(policy.Labels, map[string]string{policyv1alpha1.PropagationPolicyPermanentIDLabel: id})
728-
if err := d.Client.Update(context.TODO(), policy); err != nil {
729-
return id, err
730-
}
731-
}
732-
733-
return id, nil
734-
}
735-
736723
// ClaimPolicyForObject set policy identifier which the object associated with.
737724
func (d *ResourceDetector) ClaimPolicyForObject(object *unstructured.Unstructured, policy *policyv1alpha1.PropagationPolicy) (string, error) {
738-
policyID, err := d.getPropagationPolicyID(policy)
739-
if err != nil {
740-
klog.Errorf("Get PropagationPolicy(%s/%s) ID error:%v", policy.Namespace, policy.Name, err)
741-
return "", err
742-
}
725+
policyID := policy.Labels[policyv1alpha1.PropagationPolicyPermanentIDLabel]
743726

744727
objLabels := object.GetLabels()
745728
if objLabels == nil {
@@ -770,26 +753,9 @@ func (d *ResourceDetector) ClaimPolicyForObject(object *unstructured.Unstructure
770753
return policyID, d.Client.Update(context.TODO(), objectCopy)
771754
}
772755

773-
func (d *ResourceDetector) getClusterPropagationPolicyID(policy *policyv1alpha1.ClusterPropagationPolicy) (string, error) {
774-
id := util.GetLabelValue(policy.GetLabels(), policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel)
775-
if id == "" {
776-
id = uuid.New().String()
777-
policy.Labels = util.DedupeAndMergeLabels(policy.Labels, map[string]string{policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel: id})
778-
if err := d.Client.Update(context.TODO(), policy); err != nil {
779-
return "", err
780-
}
781-
}
782-
783-
return id, nil
784-
}
785-
786756
// ClaimClusterPolicyForObject set cluster identifier which the object associated with
787757
func (d *ResourceDetector) ClaimClusterPolicyForObject(object *unstructured.Unstructured, policy *policyv1alpha1.ClusterPropagationPolicy) (string, error) {
788-
policyID, err := d.getClusterPropagationPolicyID(policy)
789-
if err != nil {
790-
klog.Errorf("Get ClusterPropagationPolicy(%s) ID error:%v", policy.Name, err)
791-
return "", err
792-
}
758+
policyID := policy.Labels[policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel]
793759

794760
claimedID := util.GetLabelValue(object.GetLabels(), policyv1alpha1.ClusterPropagationPolicyPermanentIDLabel)
795761
// object has been claimed, don't need to claim again

0 commit comments

Comments
 (0)