Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.

Commit 027f934

Browse files
committed
Rebasing from latest main
1 parent 9df9964 commit 027f934

File tree

2 files changed

+1
-59
lines changed

2 files changed

+1
-59
lines changed

addons/controllers/clusterbootstrap_controller.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,6 @@ func (r *ClusterBootstrapReconciler) patchClusterBootstrapFromTemplate(
481481
return nil, err
482482
}
483483

484-
if err := clusterBootstrapHelper.AddPackageLabelForCNIProvider(cluster.Name, updatedClusterBootstrap); err != nil {
485-
r.Log.Error(err, fmt.Sprintf("unable to add labels to cni provider"))
486-
return nil, err
487-
}
488-
489484
r.Log.Info("updated clusterBootstrap", "clusterBootstrap", updatedClusterBootstrap)
490485
return updatedClusterBootstrap, nil
491486
}

addons/pkg/util/clusterbootstrapclone/clusterbootstrapclone.go

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -465,13 +465,7 @@ func (h *Helper) HandleExistingClusterBootstrap(clusterBootstrap *runtanzuv1alph
465465
if err := h.AddClusterOwnerRef(cluster, providers, nil, nil); err != nil {
466466
h.Logger.Error(err, fmt.Sprintf("unable to add cluster %s/%s as owner reference to providers", cluster.Namespace, cluster.Name))
467467
}
468-
469-
if err := h.AddPackageLabelForCNIProvider(cluster.Name, clusterBootstrap); err != nil {
470-
h.Logger.Error(err, fmt.Sprintf("unable to add labels to cni provider"))
471-
return nil, err
472-
}
473-
h.Logger.Info("patched labels for cni provider.")
474-
468+
475469
clusterBootstrap.OwnerReferences = []metav1.OwnerReference{
476470
{
477471
APIVersion: clusterapiv1beta1.GroupVersion.String(),
@@ -1090,31 +1084,6 @@ func (h *Helper) AddClusterOwnerRefToExistingProviders(cluster *clusterapiv1beta
10901084
return nil
10911085
}
10921086

1093-
// AddPackageLabelForCNIProvider patch the missing labels for AntreaConfig(cni config) when it's related to
1094-
// an existing clusterboostrap. To make antreaconfig works with old versions, it relies on the package label now.
1095-
func (h *Helper) AddPackageLabelForCNIProvider(clusterName string, clusterBootstrap *runtanzuv1alpha3.ClusterBootstrap) error {
1096-
cni := clusterBootstrap.Spec.CNI
1097-
if cni != nil {
1098-
providers, err := h.getListOfExistingProviders(clusterBootstrap)
1099-
if err != nil {
1100-
return err
1101-
}
1102-
for _, p := range providers {
1103-
if cni.ValuesFrom != nil && cni.ValuesFrom.ProviderRef != nil && p.GetKind() == cni.ValuesFrom.ProviderRef.Kind {
1104-
labels := p.GetLabels()
1105-
if labels == nil {
1106-
labels = map[string]string{}
1107-
}
1108-
labels[addontypes.PackageNameLabel] = util.ParseStringForLabel(cni.RefName)
1109-
labels[addontypes.ClusterNameLabel] = clusterName
1110-
return h.setLabels(labels, p)
1111-
}
1112-
}
1113-
1114-
}
1115-
return nil
1116-
}
1117-
11181087
// AddClusterOwnerRef adds cluster as an owner reference to the children with given controller and blockownerdeletion settings
11191088
func (h *Helper) AddClusterOwnerRef(cluster *clusterapiv1beta1.Cluster, children []*unstructured.Unstructured, controller, blockownerdeletion *bool) error {
11201089
ownerRef := metav1.OwnerReference{
@@ -1146,28 +1115,6 @@ func ownedByDifferentCluster(k8SObject *unstructured.Unstructured, cluster *clus
11461115
return ""
11471116
}
11481117

1149-
func (h *Helper) setLabels(labels map[string]string, child *unstructured.Unstructured) error {
1150-
gvr, err := h.GVRHelper.GetGVR(child.GroupVersionKind().GroupKind())
1151-
if err != nil {
1152-
h.Logger.Error(err, fmt.Sprintf("unable to get GVR of %s/%s", child.GetNamespace(), child.GetName()))
1153-
return err
1154-
}
1155-
1156-
patchObj := unstructured.Unstructured{}
1157-
patchObj.SetLabels(labels)
1158-
patchData, err := patchObj.MarshalJSON()
1159-
if err != nil {
1160-
h.Logger.Error(err, fmt.Sprintf("unable to patch provider %s/%s", child.GetNamespace(), child.GetName()), "gvr", gvr)
1161-
return err
1162-
}
1163-
_, err = h.DynamicClient.Resource(*gvr).Namespace(child.GetNamespace()).Patch(h.Ctx, child.GetName(), types.MergePatchType, patchData, metav1.PatchOptions{})
1164-
if err != nil {
1165-
h.Logger.Error(err, fmt.Sprintf("unable to patch provider %s/%s", child.GetNamespace(), child.GetName()), "gvr", gvr)
1166-
}
1167-
return err
1168-
1169-
}
1170-
11711118
func (h *Helper) setOwnerRef(ownerRef *metav1.OwnerReference, children []*unstructured.Unstructured) error {
11721119
for _, child := range children {
11731120
gvr, err := h.GVRHelper.GetGVR(child.GroupVersionKind().GroupKind())

0 commit comments

Comments
 (0)