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: refactoring to remove pubsub flags to improve experience #3339

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

JaydipGabani
Copy link
Contributor

What this PR does / why we need it:

  • Removing --audit-connection and --audit-channel flags to reduce configuration complexity
  • Adding support to define channel/topic to publish messages within dapr driver
  • Publishing to all established connections

Which issue(s) this PR fixes (optional, using fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when the PR gets merged):
Fixes #

Special notes for your reviewer:

@JaydipGabani JaydipGabani requested a review from a team as a code owner March 27, 2024 23:24
Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
Signed-off-by: Jaydip Gabani <gabanijaydip@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Apr 1, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 46.72%. Comparing base (3350319) to head (acc6280).
Report is 57 commits behind head on master.

Files Patch % Lines
pkg/pubsub/dapr/dapr.go 40.00% 5 Missing and 1 partial ⚠️
pkg/pubsub/dapr/fake_dapr_client.go 16.66% 5 Missing ⚠️
pkg/audit/manager.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3339      +/-   ##
==========================================
- Coverage   54.49%   46.72%   -7.77%     
==========================================
  Files         134      218      +84     
  Lines       12329    14798    +2469     
==========================================
+ Hits         6719     6915     +196     
- Misses       5116     7079    +1963     
- Partials      494      804     +310     
Flag Coverage Δ
unittests 46.72% <50.00%> (-7.77%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maxsmythe
Copy link
Contributor

I'm confused as to how this improves UX. If a customer doesn't specify the flags, won't they get the default values, which is an equivalent effort on the users part?

If a user is using a custom queue value/name how would they be able to continue to do so with this change?

Are there any backwards compatibility concerns removing flags from the command line and Helm chart?

@maxsmythe
Copy link
Contributor

Also, we probably want to ensure pubsub can still be disabled for those who do not want to use it.

@maxsmythe
Copy link
Contributor

Sorry, that last comment was off-topic... you mistakenly removed enablePubsub from the Helm config's values file instead of the channel name flag.

@@ -212,8 +212,6 @@ controllerManager:
# - ipBlock:
# cidr: 0.0.0.0/0
audit:
enablePubsub: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you removed the wrong value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yip! I will update that.

@JaydipGabani
Copy link
Contributor Author

I'm confused as to how this improves UX. If a customer doesn't specify the flags, won't they get the default values, which is an equivalent effort on the users part?

If a user is using a custom queue value/name how would they be able to continue to do so with this change?

Are there any backwards compatibility concerns removing flags from the command line and Helm chart?

Instead of using flags to define global connection and channel - ensure that --audit-connection must match name of the configMap to send messages, the channel/queue should now be defined as a part of spec in connectionConfig. So each connection will say on which queue these messages should be sent out to. And instead of using only one connection for all messages, now pubsub would be able to use all the configured connections to send messages as it will not be required to sepcify a connection using audit-connection flag.

@@ -125,6 +126,9 @@ Dapr: https://dapr.io/
- name: go-sub
image: fake-subscriber:latest
imagePullPolicy: Never
env:
- name: AUDIT_CHANNEL
Copy link
Member

@ritazh ritazh Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is consuming this env var? it looks like it is no longer being used and got removed here: https://github.com/open-policy-agent/gatekeeper/pull/3339/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52L228

@ritazh
Copy link
Member

ritazh commented Apr 30, 2024

I'm confused as to how this improves UX. If a customer doesn't specify the flags, won't they get the default values, which is an equivalent effort on the users part?
If a user is using a custom queue value/name how would they be able to continue to do so with this change?
Are there any backwards compatibility concerns removing flags from the command line and Helm chart?

Instead of using flags to define global connection and channel - ensure that --audit-connection must match name of the configMap to send messages, the channel/queue should now be defined as a part of spec in connectionConfig. So each connection will say on which queue these messages should be sent out to. And instead of using only one connection for all messages, now pubsub would be able to use all the configured connections to send messages as it will not be required to sepcify a connection using audit-connection flag.

The concern here is by removing flags, it will definitely break in-place upgrade if users are using this alpha feature. are we ok with doing that for an alpha feature? @maxsmythe
If not, then we need to follow the same deprecation process as other flags to add deprecation message for 2-3 releases before we can remove it. e.g. the validate-template-rego flag lived for 3 releases before we can remove it in 3.16.

Separately, you should add some details in the docs for how users can use topic in the configmap to describe connections and queues they want to use for different purposes. Add few examples on top of the audit one maybe.

@@ -19,16 +20,19 @@ func NewSystem() *System {
return &System{}
}

func (s *System) Publish(_ context.Context, connection string, topic string, msg interface{}) error {
func (s *System) Publish(ctx context.Context, msg interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we still looking at supporting multiple queues simultaneously? Possibly specifying which connection/topic gets pushed to as part of a constraint's enforcement action?

Example: send violation X to security queue, violation Y to ops queue?

If so, Publish() will need to support something more fine-grained than "broadcast everywhere"

@@ -21,19 +24,22 @@ type Dapr struct {

// Name of the pubsub component
pubSubComponent string

// Topic where the messages would be published for the connection
topic string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What part of the connection/channel config should be specify-able by downstream users (e.g. constraint authors) and what should be owned by the author of the constraint objects?

We should think about the personas who would be interacting with these knobs. Are the people setting up the infra always the same people writing the policy?

@JaydipGabani JaydipGabani requested review from ritazh and maxsmythe and removed request for ritazh and maxsmythe May 13, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants