Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix intermittent api key security problem #2592

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 6 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,12 @@ 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 {
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
}
Loading