Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
messaging: trigger proxy update when feature flag is toggled (#4345)
Browse files Browse the repository at this point in the history
Triggers a proxy update event when feature flags are modified.
The event is scoped to any feature flag because all the feature
flags are associated with proxy config updates.

Signed-off-by: Shashank Ram <[email protected]>
  • Loading branch information
shashankram authored Nov 8, 2021
1 parent 903f36c commit 52e13ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/messaging/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ func getProxyUpdateEvent(msg events.PubSubMessage) *proxyUpdateEvent {
prevSpec.Observability.Tracing != newSpec.Observability.Tracing ||
prevSpec.Traffic.InboundExternalAuthorization.Enable != newSpec.Traffic.InboundExternalAuthorization.Enable ||
// Only trigger an update on InboundExternalAuthorization field changes if the new spec has the 'Enable' flag set to true.
(newSpec.Traffic.InboundExternalAuthorization.Enable && (prevSpec.Traffic.InboundExternalAuthorization != newSpec.Traffic.InboundExternalAuthorization)) {
(newSpec.Traffic.InboundExternalAuthorization.Enable && (prevSpec.Traffic.InboundExternalAuthorization != newSpec.Traffic.InboundExternalAuthorization)) ||
prevSpec.FeatureFlags != newSpec.FeatureFlags {
return &proxyUpdateEvent{
msg: msg,
topic: announcements.ProxyUpdate.String(),
Expand Down
22 changes: 22 additions & 0 deletions pkg/messaging/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,28 @@ func TestGetProxyUpdateEvent(t *testing.T) {
},
expectEvent: false,
},
{
name: "MeshConfig update with feature flags results in proxy update",
msg: events.PubSubMessage{
Kind: announcements.MeshConfigUpdated,
OldObj: &configv1alpha1.MeshConfig{
Spec: configv1alpha1.MeshConfigSpec{
FeatureFlags: configv1alpha1.FeatureFlags{
EnableEgressPolicy: true,
},
},
},
NewObj: &configv1alpha1.MeshConfig{
Spec: configv1alpha1.MeshConfigSpec{
FeatureFlags: configv1alpha1.FeatureFlags{
EnableEgressPolicy: false,
},
},
},
},
expectEvent: true,
expectedTopic: announcements.ProxyUpdate.String(),
},
{
name: "Namespace event",
msg: events.PubSubMessage{
Expand Down

0 comments on commit 52e13ad

Please sign in to comment.