Skip to content

Commit

Permalink
Fix intermittent api key security problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharsanan1 committed Oct 18, 2024
1 parent dc3c99c commit d8961cf
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions adapter/internal/operator/controllers/dp/api_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 9 additions & 0 deletions adapter/internal/operator/synchronizer/data_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions common-go-libs/apis/dp/v1alpha2/resolvedbackend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package v1alpha2

import "reflect"

// ResolvedBackend holds backend properties
type ResolvedBackend struct {
Backend Backend
Expand Down Expand Up @@ -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
}

0 comments on commit d8961cf

Please sign in to comment.