@@ -14,18 +14,13 @@ import (
1414 policyv1 "k8s.io/api/policy/v1"
1515 apiextensionshelpers "k8s.io/apiextensions-apiserver/pkg/apihelpers"
1616 apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
17- "k8s.io/apimachinery/pkg/api/meta"
1817 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1918 "k8s.io/apimachinery/pkg/runtime"
2019 "k8s.io/apimachinery/pkg/runtime/schema"
2120 "k8s.io/component-helpers/apps/poddisruptionbudget"
2221 "k8s.io/klog/v2"
2322
24- fleetnetworkingv1alpha1 "go.goms.io/fleet-networking/api/v1alpha1"
25- "go.goms.io/fleet-networking/pkg/common/objectmeta"
26-
2723 "go.goms.io/fleet/pkg/utils"
28- "go.goms.io/fleet/pkg/utils/condition"
2924 "go.goms.io/fleet/pkg/utils/controller"
3025)
3126
@@ -88,8 +83,6 @@ func trackInMemberClusterObjAvailabilityByGVR(
8883 return trackCRDAvailability (inMemberClusterObj )
8984 case utils .PodDisruptionBudgetGVR :
9085 return trackPDBAvailability (inMemberClusterObj )
91- case utils .ServiceExportGVR :
92- return trackServiceExportAvailability (inMemberClusterObj )
9386 default :
9487 if isDataResource (* gvr ) {
9588 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
254247 return ManifestProcessingAvailabilityResultTypeNotYetAvailable , nil
255248}
256249
257- // trackServiceExportAvailability tracks the availability of a service export in the member cluster.
258- // It is available if the ServiceExportValid condition is true (will be false if annotation value is invalid).
259- // If the weight is not 0, ServiceExportValid condition must be true and the ServiceExportConflict condition must be false.
260- func trackServiceExportAvailability (curObj * unstructured.Unstructured ) (ManifestProcessingAvailabilityResultType , error ) {
261- var svcExport fleetnetworkingv1alpha1.ServiceExport
262- if err := runtime .DefaultUnstructuredConverter .FromUnstructured (curObj .Object , & svcExport ); err != nil {
263- return ManifestProcessingAvailabilityResultTypeFailed , controller .NewUnexpectedBehaviorError (err )
264- }
265-
266- // Check if ServiceExport is valid and up to date
267- svcExportObj := klog .KObj (curObj )
268- validCond := meta .FindStatusCondition (svcExport .Status .Conditions , string (fleetnetworkingv1alpha1 .ServiceExportValid ))
269- if ! condition .IsConditionStatusTrue (validCond , svcExport .Generation ) {
270- klog .V (2 ).InfoS ("Still need to wait for ServiceExport to be valid" , "serviceExport" , svcExportObj , "validCondition" , validCond )
271- return ManifestProcessingAvailabilityResultTypeNotYetAvailable , nil
272- }
273- // Validate annotation weight. Updating the annotation won't change the object generation,
274- // so the current status is not reliable and need to validate the annotation again here
275- weight , err := objectmeta .ExtractWeightFromServiceExport (& svcExport )
276- if err != nil {
277- klog .Errorf (err .Error (), "ServiceExport has invalid weight" , "serviceExport" , svcExportObj )
278- return ManifestProcessingAvailabilityResultTypeNotYetAvailable , err
279- }
280- if weight != 0 {
281- // Check conflict condition for non-zero weight
282- conflictCond := meta .FindStatusCondition (svcExport .Status .Conditions , string (fleetnetworkingv1alpha1 .ServiceExportConflict ))
283- if ! condition .IsConditionStatusFalse (conflictCond , svcExport .Generation ) {
284- klog .V (2 ).InfoS ("Still need to wait for ServiceExport to not have conflicts" , "serviceExport" , svcExportObj , "conflictCondition" , conflictCond )
285- return ManifestProcessingAvailabilityResultTypeNotYetAvailable , nil
286- }
287- } else {
288- klog .V (2 ).InfoS ("Skipping checking the conflict condition for the weight 0" , "serviceExport" , svcExportObj )
289- }
290-
291- klog .V (2 ).InfoS ("ServiceExport is available" , "serviceExport" , svcExportObj )
292- return ManifestProcessingAvailabilityResultTypeAvailable , nil
293- }
294-
295250// isDataResource checks if the resource is a data resource; such resources are
296251// available immediately after creation.
297252func isDataResource (gvr schema.GroupVersionResource ) bool {
0 commit comments