From b0efd02836cb08fb99d4817624a1a35e039125a9 Mon Sep 17 00:00:00 2001 From: Zhiying Lin Date: Thu, 20 Mar 2025 15:31:03 +0800 Subject: [PATCH 1/2] Revert "address comments to fix bug (#1080)" This reverts commit 9a376db6ee569a7f37b21a29b5ffeb6495c4fbed. --- .../workapplier/availability_tracker.go | 6 ++--- .../workapplier/availability_tracker_test.go | 24 ++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/pkg/controllers/workapplier/availability_tracker.go b/pkg/controllers/workapplier/availability_tracker.go index c61fbe3da..b44d252b0 100644 --- a/pkg/controllers/workapplier/availability_tracker.go +++ b/pkg/controllers/workapplier/availability_tracker.go @@ -271,11 +271,11 @@ func trackServiceExportAvailability(curObj *unstructured.Unstructured) (Manifest return ManifestProcessingAvailabilityResultTypeNotYetAvailable, nil } // Validate annotation weight. Updating the annotation won't change the object generation, - // so the current status is not reliable and need to validate the annotation again here. + // so the current status is not reliable and need to validate the annotation again here weight, err := objectmeta.ExtractWeightFromServiceExport(&svcExport) if err != nil { - klog.Error(err, "ServiceExport has invalid weight", "serviceExport", svcExportObj) - return ManifestProcessingAvailabilityResultTypeNotYetAvailable, nil + klog.Errorf(err.Error(), "ServiceExport has invalid weight", "serviceExport", svcExportObj) + return ManifestProcessingAvailabilityResultTypeNotYetAvailable, err } if weight != 0 { // Check conflict condition for non-zero weight diff --git a/pkg/controllers/workapplier/availability_tracker_test.go b/pkg/controllers/workapplier/availability_tracker_test.go index 4fc941616..864b3666f 100644 --- a/pkg/controllers/workapplier/availability_tracker_test.go +++ b/pkg/controllers/workapplier/availability_tracker_test.go @@ -7,6 +7,7 @@ package workapplier import ( "context" + "fmt" "testing" "github.com/google/go-cmp/cmp" @@ -1001,6 +1002,7 @@ func TestServiceExportAvailability(t *testing.T) { weight string status fleetnetworkingv1alpha1.ServiceExportStatus wantManifestProcessingAvailabilityResultType ManifestProcessingAvailabilityResultType + err error }{ { name: "available svcExport (annotation weight is 0)", @@ -1016,6 +1018,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeAvailable, + err: nil, }, { name: "unavailable svcExport (ServiceExportValid is false)", @@ -1031,6 +1034,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "unavailable svcExport (different generation, annotation weight is 0)", @@ -1046,6 +1050,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "available svcExport with no conflict (annotation weight is 1)", @@ -1067,6 +1072,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeAvailable, + err: nil, }, { name: "unavailable svcExport with conflict (annotation weight is 1)", @@ -1088,6 +1094,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "unavailable invalid svcExport (annotation weight is 1)", @@ -1103,6 +1110,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "unavailable svcExport (different generation, annotation weight is 1)", @@ -1124,6 +1132,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "unavailable svcExport (no annotation weight, no conflict condition)", @@ -1139,6 +1148,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "available svcExport (no annotation weight)", @@ -1160,6 +1170,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeAvailable, + err: nil, }, { name: "unavailable svcExport (no annotation weight with conflict)", @@ -1181,6 +1192,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "unavailable svcExport (no annotation weight, different generation)", @@ -1202,6 +1214,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "unavailable svcExport (no annotation weight, invalid service export)", @@ -1217,6 +1230,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: nil, }, { name: "unavailable svcExport (invalid weight)", @@ -1232,6 +1246,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: fmt.Errorf("the weight annotation is not a valid integer: a"), }, { name: "unavailable svcExport (out of range weight)", @@ -1247,6 +1262,7 @@ func TestServiceExportAvailability(t *testing.T) { }, }, wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, + err: fmt.Errorf("the weight annotation is not in the range [0, 1000]: 1002"), }, } @@ -1258,8 +1274,14 @@ func TestServiceExportAvailability(t *testing.T) { } svcExport.Status = tc.status gotResTyp, err := trackServiceExportAvailability(toUnstructured(t, svcExport)) + + // Check for errors if err != nil { - t.Fatalf("trackServiceExportAvailability() = %v, want no error", err) + if tc.err == nil || err.Error() != tc.err.Error() { + t.Fatalf("trackServiceExportAvailability() = %v, want %v", err, tc.err) + } + } else if tc.err != nil { + t.Fatalf("trackServiceExportAvailability() = nil, want error: %v", tc.err) } // Check the result type From 5e52ded31e14ed2118402efa4ff1c5d56a7390cd Mon Sep 17 00:00:00 2001 From: Zhiying Lin Date: Thu, 20 Mar 2025 15:31:51 +0800 Subject: [PATCH 2/2] Revert "feat: add svc export trackability (#1061)" This reverts commit 22dc1a0fc681c2db930604b7040c4cc6dfdefbe2. --- go.mod | 2 +- go.sum | 4 +- .../workapplier/availability_tracker.go | 45 --- .../workapplier/availability_tracker_test.go | 309 ------------------ pkg/utils/common.go | 6 - 5 files changed, 3 insertions(+), 363 deletions(-) diff --git a/go.mod b/go.mod index d68f2e0ac..c466f19b4 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.10.0 github.com/wI2L/jsondiff v0.6.0 - go.goms.io/fleet-networking v0.3.5 + go.goms.io/fleet-networking v0.3.3 go.uber.org/atomic v1.11.0 go.uber.org/zap v1.27.0 golang.org/x/exp v0.0.0-20241004190924-225e2abe05e6 diff --git a/go.sum b/go.sum index 132d8621d..d50d43fdc 100644 --- a/go.sum +++ b/go.sum @@ -253,8 +253,8 @@ github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcY github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.goms.io/fleet-networking v0.3.5 h1:nR0LFEbpu9cfBwYFVV8cGB8OARemIwtzaaFpRpp1GtQ= -go.goms.io/fleet-networking v0.3.5/go.mod h1:zegH1iEZScjUWiGnXL67D/ZfWTM9DBUaSo1gPWaxLek= +go.goms.io/fleet-networking v0.3.3 h1:5rwBntaUoLF+E1CzaWAEL4GdvLJPQorKhjgkbLlllPE= +go.goms.io/fleet-networking v0.3.3/go.mod h1:Qgbi8M1fGaz/p5rtb6HJPmTDATWRnMt9HD1gz57WKUc= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg= go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= diff --git a/pkg/controllers/workapplier/availability_tracker.go b/pkg/controllers/workapplier/availability_tracker.go index b44d252b0..afe7d88f1 100644 --- a/pkg/controllers/workapplier/availability_tracker.go +++ b/pkg/controllers/workapplier/availability_tracker.go @@ -14,18 +14,13 @@ import ( policyv1 "k8s.io/api/policy/v1" apiextensionshelpers "k8s.io/apiextensions-apiserver/pkg/apihelpers" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" - "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/component-helpers/apps/poddisruptionbudget" "k8s.io/klog/v2" - fleetnetworkingv1alpha1 "go.goms.io/fleet-networking/api/v1alpha1" - "go.goms.io/fleet-networking/pkg/common/objectmeta" - "go.goms.io/fleet/pkg/utils" - "go.goms.io/fleet/pkg/utils/condition" "go.goms.io/fleet/pkg/utils/controller" ) @@ -88,8 +83,6 @@ func trackInMemberClusterObjAvailabilityByGVR( return trackCRDAvailability(inMemberClusterObj) case utils.PodDisruptionBudgetGVR: return trackPDBAvailability(inMemberClusterObj) - case utils.ServiceExportGVR: - return trackServiceExportAvailability(inMemberClusterObj) default: if isDataResource(*gvr) { klog.V(2).InfoS("The object from the member cluster is a data object, consider it to be immediately available", @@ -254,44 +247,6 @@ func trackPDBAvailability(curObj *unstructured.Unstructured) (ManifestProcessing return ManifestProcessingAvailabilityResultTypeNotYetAvailable, nil } -// trackServiceExportAvailability tracks the availability of a service export in the member cluster. -// It is available if the ServiceExportValid condition is true (will be false if annotation value is invalid). -// If the weight is not 0, ServiceExportValid condition must be true and the ServiceExportConflict condition must be false. -func trackServiceExportAvailability(curObj *unstructured.Unstructured) (ManifestProcessingAvailabilityResultType, error) { - var svcExport fleetnetworkingv1alpha1.ServiceExport - if err := runtime.DefaultUnstructuredConverter.FromUnstructured(curObj.Object, &svcExport); err != nil { - return ManifestProcessingAvailabilityResultTypeFailed, controller.NewUnexpectedBehaviorError(err) - } - - // Check if ServiceExport is valid and up to date - svcExportObj := klog.KObj(curObj) - validCond := meta.FindStatusCondition(svcExport.Status.Conditions, string(fleetnetworkingv1alpha1.ServiceExportValid)) - if !condition.IsConditionStatusTrue(validCond, svcExport.Generation) { - klog.V(2).InfoS("Still need to wait for ServiceExport to be valid", "serviceExport", svcExportObj, "validCondition", validCond) - return ManifestProcessingAvailabilityResultTypeNotYetAvailable, nil - } - // Validate annotation weight. Updating the annotation won't change the object generation, - // so the current status is not reliable and need to validate the annotation again here - weight, err := objectmeta.ExtractWeightFromServiceExport(&svcExport) - if err != nil { - klog.Errorf(err.Error(), "ServiceExport has invalid weight", "serviceExport", svcExportObj) - return ManifestProcessingAvailabilityResultTypeNotYetAvailable, err - } - if weight != 0 { - // Check conflict condition for non-zero weight - conflictCond := meta.FindStatusCondition(svcExport.Status.Conditions, string(fleetnetworkingv1alpha1.ServiceExportConflict)) - if !condition.IsConditionStatusFalse(conflictCond, svcExport.Generation) { - klog.V(2).InfoS("Still need to wait for ServiceExport to not have conflicts", "serviceExport", svcExportObj, "conflictCondition", conflictCond) - return ManifestProcessingAvailabilityResultTypeNotYetAvailable, nil - } - } else { - klog.V(2).InfoS("Skipping checking the conflict condition for the weight 0", "serviceExport", svcExportObj) - } - - klog.V(2).InfoS("ServiceExport is available", "serviceExport", svcExportObj) - return ManifestProcessingAvailabilityResultTypeAvailable, nil -} - // isDataResource checks if the resource is a data resource; such resources are // available immediately after creation. func isDataResource(gvr schema.GroupVersionResource) bool { diff --git a/pkg/controllers/workapplier/availability_tracker_test.go b/pkg/controllers/workapplier/availability_tracker_test.go index 864b3666f..c41c2fcc9 100644 --- a/pkg/controllers/workapplier/availability_tracker_test.go +++ b/pkg/controllers/workapplier/availability_tracker_test.go @@ -7,7 +7,6 @@ package workapplier import ( "context" - "fmt" "testing" "github.com/google/go-cmp/cmp" @@ -27,9 +26,6 @@ import ( "k8s.io/klog/v2" "k8s.io/utils/ptr" - fleetnetworkingv1alpha1 "go.goms.io/fleet-networking/api/v1alpha1" - "go.goms.io/fleet-networking/pkg/common/objectmeta" - fleetv1beta1 "go.goms.io/fleet/apis/placement/v1beta1" "go.goms.io/fleet/pkg/utils" "go.goms.io/fleet/pkg/utils/parallelizer" @@ -987,311 +983,6 @@ func TestTrackInMemberClusterObjAvailabilityByGVR(t *testing.T) { } } -func TestServiceExportAvailability(t *testing.T) { - svcExportTemplate := &fleetnetworkingv1alpha1.ServiceExport{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-svcExport", - Namespace: nsName, - Annotations: map[string]string{}, - Generation: 3, - }, - } - - testCases := []struct { - name string - weight string - status fleetnetworkingv1alpha1.ServiceExportStatus - wantManifestProcessingAvailabilityResultType ManifestProcessingAvailabilityResultType - err error - }{ - { - name: "available svcExport (annotation weight is 0)", - weight: "0", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeAvailable, - err: nil, - }, - { - name: "unavailable svcExport (ServiceExportValid is false)", - weight: "0", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionFalse, - Reason: "ServiceNotFound", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "unavailable svcExport (different generation, annotation weight is 0)", - weight: "0", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 2, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "available svcExport with no conflict (annotation weight is 1)", - weight: "1", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - { - Type: string(fleetnetworkingv1alpha1.ServiceExportConflict), - Status: metav1.ConditionFalse, - Reason: "NoConflictFound", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeAvailable, - err: nil, - }, - { - name: "unavailable svcExport with conflict (annotation weight is 1)", - weight: "1", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - { - Type: string(fleetnetworkingv1alpha1.ServiceExportConflict), - Status: metav1.ConditionTrue, - Reason: "ConflictFound", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "unavailable invalid svcExport (annotation weight is 1)", - weight: "1", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionFalse, - Reason: "ServiceIneligible", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "unavailable svcExport (different generation, annotation weight is 1)", - weight: "1", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - { - Type: string(fleetnetworkingv1alpha1.ServiceExportConflict), - Status: metav1.ConditionTrue, - Reason: "ConflictFound", - ObservedGeneration: 2, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "unavailable svcExport (no annotation weight, no conflict condition)", - weight: "", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "available svcExport (no annotation weight)", - weight: "", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - { - Type: string(fleetnetworkingv1alpha1.ServiceExportConflict), - Status: metav1.ConditionFalse, - Reason: "NoConflictFound", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeAvailable, - err: nil, - }, - { - name: "unavailable svcExport (no annotation weight with conflict)", - weight: "", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - { - Type: string(fleetnetworkingv1alpha1.ServiceExportConflict), - Status: metav1.ConditionTrue, - Reason: "ConflictFound", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "unavailable svcExport (no annotation weight, different generation)", - weight: "", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - { - Type: string(fleetnetworkingv1alpha1.ServiceExportConflict), - Status: metav1.ConditionFalse, - Reason: "NoConflictFound", - ObservedGeneration: 2, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "unavailable svcExport (no annotation weight, invalid service export)", - weight: "", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionFalse, - Reason: "ServiceIsNotValid", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: nil, - }, - { - name: "unavailable svcExport (invalid weight)", - weight: "a", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: fmt.Errorf("the weight annotation is not a valid integer: a"), - }, - { - name: "unavailable svcExport (out of range weight)", - weight: "1002", - status: fleetnetworkingv1alpha1.ServiceExportStatus{ - Conditions: []metav1.Condition{ - { - Type: string(fleetnetworkingv1alpha1.ServiceExportValid), - Status: metav1.ConditionTrue, - Reason: "ServiceIsValid", - ObservedGeneration: 3, - }, - }, - }, - wantManifestProcessingAvailabilityResultType: ManifestProcessingAvailabilityResultTypeNotYetAvailable, - err: fmt.Errorf("the weight annotation is not in the range [0, 1000]: 1002"), - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - svcExport := svcExportTemplate.DeepCopy() - if tc.weight != "" { - svcExport.Annotations[objectmeta.ServiceExportAnnotationWeight] = tc.weight - } - svcExport.Status = tc.status - gotResTyp, err := trackServiceExportAvailability(toUnstructured(t, svcExport)) - - // Check for errors - if err != nil { - if tc.err == nil || err.Error() != tc.err.Error() { - t.Fatalf("trackServiceExportAvailability() = %v, want %v", err, tc.err) - } - } else if tc.err != nil { - t.Fatalf("trackServiceExportAvailability() = nil, want error: %v", tc.err) - } - - // Check the result type - if gotResTyp != tc.wantManifestProcessingAvailabilityResultType { - t.Errorf("manifestProcessingAvailabilityResultType = %v, want %v", gotResTyp, tc.wantManifestProcessingAvailabilityResultType) - } - }) - } -} - // TestTrackInMemberClusterObjAvailability tests the trackInMemberClusterObjAvailability method. func TestTrackInMemberClusterObjAvailability(t *testing.T) { ctx := context.Background() diff --git a/pkg/utils/common.go b/pkg/utils/common.go index 0daf26317..959aeeab4 100644 --- a/pkg/utils/common.go +++ b/pkg/utils/common.go @@ -358,12 +358,6 @@ var ( Resource: "serviceaccounts", } - ServiceExportGVR = schema.GroupVersionResource{ - Group: fleetnetworkingv1alpha1.GroupVersion.Group, - Version: fleetnetworkingv1alpha1.GroupVersion.Version, - Resource: "serviceexports", - } - StorageClassGVR = schema.GroupVersionResource{ Group: storagev1.SchemeGroupVersion.Group, Version: storagev1.SchemeGroupVersion.Version,