diff --git a/adapter/internal/operator/controllers/dp/api_controller.go b/adapter/internal/operator/controllers/dp/api_controller.go index 456f9f964..378d34c18 100644 --- a/adapter/internal/operator/controllers/dp/api_controller.go +++ b/adapter/internal/operator/controllers/dp/api_controller.go @@ -330,6 +330,8 @@ func (apiReconciler *APIReconciler) Reconcile(ctx context.Context, req ctrl.Requ loggers.LoggerAPKOperator.Infof("Ready to deploy CRs for API in namespace : %s with API UUID : %v, %v", req.NamespacedName.String(), string(apiCR.ObjectMeta.UID), err) *apiReconciler.ch <- apiState + } else { + loggers.LoggerAPKOperator.Infof("No changes detected for API in namespace : %s with API UUID : %v",) } return ctrl.Result{}, nil } diff --git a/adapter/internal/operator/synchronizer/data_store.go b/adapter/internal/operator/synchronizer/data_store.go index c44272fcb..86995720e 100644 --- a/adapter/internal/operator/synchronizer/data_store.go +++ b/adapter/internal/operator/synchronizer/data_store.go @@ -462,6 +462,15 @@ func updateHTTPRoute(httpRoute *HTTPRouteState, cachedHTTPRoute *HTTPRouteState, events = append(events, endpointType+" Backend Properties") break } + if !existingBackend.IsSimilar(*backend) { + cachedHTTPRoute.BackendMapping = httpRoute.BackendMapping + updated = true + events = append(events, endpointType+" Backend Properties") + break + } else { + // log the backend and chaed backend + loggers.LoggerAPKOperator.Infof("Backend %+v is similar to the existing backend %+v", backend.Security, existingBackend.Security) + } } else { cachedHTTPRoute.BackendMapping = httpRoute.BackendMapping updated = true diff --git a/common-go-libs/apis/dp/v1alpha2/resolvedbackend.go b/common-go-libs/apis/dp/v1alpha2/resolvedbackend.go index 670fd0dd9..1a39268c6 100644 --- a/common-go-libs/apis/dp/v1alpha2/resolvedbackend.go +++ b/common-go-libs/apis/dp/v1alpha2/resolvedbackend.go @@ -17,6 +17,8 @@ package v1alpha2 +import "reflect" + // ResolvedBackend holds backend properties type ResolvedBackend struct { Backend Backend @@ -56,3 +58,38 @@ type ResolvedAPIKeySecurityConfig struct { Name string Value string } + +func (rb ResolvedBackend) IsSimilar(other ResolvedBackend) bool { + + if !reflect.DeepEqual(rb.Backend, other.Backend) { + return false + } + if len(rb.Services) != len(other.Services) { + return false + } + if !reflect.DeepEqual(rb.Protocol, other.Protocol) { + return false + } + if !reflect.DeepEqual(rb.TLS, other.TLS) { + return false + } + if !reflect.DeepEqual(rb.Security, other.Security) { + return false + } + if !reflect.DeepEqual(rb.CircuitBreaker, other.CircuitBreaker) { + return false + } + if !reflect.DeepEqual(rb.Timeout, other.Timeout) { + return false + } + if !reflect.DeepEqual(rb.Retry, other.Retry) { + return false + } + if rb.BasePath != other.BasePath { + return false + } + if !reflect.DeepEqual(rb.HealthCheck, other.HealthCheck) { + return false + } + return true +} \ No newline at end of file