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

chore: updating pubsub system #3646

Merged
merged 12 commits into from
Feb 12, 2025

Conversation

JaydipGabani
Copy link
Contributor

@JaydipGabani JaydipGabani commented Oct 15, 2024

What this PR does / why we need it:

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 #1037 #3497

Special notes for your reviewer:

@codecov-commenter
Copy link

codecov-commenter commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 52.83019% with 75 lines in your changes missing coverage. Please review.

Project coverage is 47.72%. Comparing base (3350319) to head (55d941e).
Report is 259 commits behind head on master.

Files with missing lines Patch % Lines
pkg/export/dapr/fake_dapr_client.go 24.13% 22 Missing ⚠️
pkg/export/dapr/dapr.go 65.95% 14 Missing and 2 partials ⚠️
pkg/export/testdriver/testdriver.go 36.84% 11 Missing and 1 partial ⚠️
pkg/controller/export/export_config_controller.go 8.33% 11 Missing ⚠️
pkg/export/system.go 79.54% 6 Missing and 3 partials ⚠️
pkg/audit/manager.go 0.00% 5 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (3350319) and HEAD (55d941e). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (55d941e)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3646      +/-   ##
==========================================
- Coverage   54.49%   47.72%   -6.78%     
==========================================
  Files         134      234     +100     
  Lines       12329    19864    +7535     
==========================================
+ Hits         6719     9480    +2761     
- Misses       5116     9493    +4377     
- Partials      494      891     +397     
Flag Coverage Δ
unittests 47.72% <52.83%> (-6.78%) ⬇️

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.

@JaydipGabani JaydipGabani changed the title [WIP] chore: updating violation system [WIP] chore: updating pubsub system Oct 21, 2024
@JaydipGabani JaydipGabani changed the title [WIP] chore: updating pubsub system chore: updating pubsub system Oct 23, 2024
@JaydipGabani JaydipGabani marked this pull request as ready for review October 23, 2024 01:31
@JaydipGabani JaydipGabani requested a review from a team as a code owner October 23, 2024 01:31
@JaydipGabani
Copy link
Contributor Author

Still working on doc changes.

@@ -26,37 +26,37 @@ import (
)

var (
PubsubEnabled = flag.Bool("enable-pub-sub", false, "(alpha) Enabled pubsub to publish messages")
ExportEnabled = flag.Bool("enable-pub-sub", false, "(alpha) Enabled pubsub to publish messages")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to rename the flag to remove pub-sub word?

Copy link
Contributor

Choose a reason for hiding this comment

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

May as well while it's still alpha

Copy link
Member

@sozercan sozercan Jan 23, 2025

Choose a reason for hiding this comment

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

should we provide a warning for the user if we change the name? we can remove it after a release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean? How would we provide warning for changing a name before release?

@ritazh ritazh added this to the v3.19.0 milestone Dec 11, 2024
@JaydipGabani
Copy link
Contributor Author

Fixes #3497

@@ -114,22 +114,22 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
}

if len(cfg.Data) == 0 {
return reconcile.Result{}, fmt.Errorf(fmt.Sprintf("data missing in configmap %s, unable to configure respective pubsub", request.NamespacedName))
return reconcile.Result{}, fmt.Errorf(fmt.Sprintf("data missing in configmap %s, unable to establish connection", request.NamespacedName))
Copy link
Contributor

Choose a reason for hiding this comment

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

is it a "connection" necessarily?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"link" may be? I just couldn't come up with better alternative at the time.

Copy link
Member

Choose a reason for hiding this comment

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

"unable to configure exporter"?

}
if _, ok := cfg.Data["provider"]; !ok {
return reconcile.Result{}, fmt.Errorf(fmt.Sprintf("missing provider field in configmap %s, unable to configure respective pubsub", request.NamespacedName))
if _, ok := cfg.Data["driver"]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is changing from config map to CRD coming later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can raise a follow up PR, we have the design finalized as per last discussion.

Copy link
Member

@sozercan sozercan left a comment

Choose a reason for hiding this comment

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

minor comments, otherwise LGTM

}

func (a *Adder) Add(mgr manager.Manager) error {
if !*PubsubEnabled {
if !*ExportEnabled {
return nil
}
log.Info("Warning: Alpha flag enable-pub-sub is set to true. This flag may change in the future.")
Copy link
Member

Choose a reason for hiding this comment

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

update this too if we change the flag name

@@ -114,22 +114,22 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
}

if len(cfg.Data) == 0 {
return reconcile.Result{}, fmt.Errorf(fmt.Sprintf("data missing in configmap %s, unable to configure respective pubsub", request.NamespacedName))
return reconcile.Result{}, fmt.Errorf(fmt.Sprintf("data missing in configmap %s, unable to establish connection", request.NamespacedName))
Copy link
Member

Choose a reason for hiding this comment

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

"unable to configure exporter"?

title: Export Interface/Driver walkthrough
---

This guide provides an overview of the driver interface, including details of its structure and functionality. Additionally, it offers instructions on adding a new driver and utilizing different backends to export violations.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This guide provides an overview of the driver interface, including details of its structure and functionality. Additionally, it offers instructions on adding a new driver and utilizing different backends to export violations.
This guide provides an overview of the driver interface, including details of its structure and functionality. Additionally, it offers instructions on adding a new driver and utilizing different backends to export audit violations.

Signed-off-by: Jaydip Gabani <[email protected]>
@@ -1,18 +1,18 @@
name: dapr-pubsub
Copy link
Member

Choose a reason for hiding this comment

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

since you are renaming everything, does this yaml need to be renamed too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, ty!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the file name.


This feature uses publish and subscribe (pubsub) model that allows Gatekeeper to export audit violations over a broker that can be consumed by a subscriber independently. Therefore, pubsub violations are not subject to reporting limits. Please refer to [this](pubsub.md) guide to configure audit to push violations over a channel.
This feature allows plugging in different backends that allows Gatekeeper to export audit violations. Therefore, violations are not subject to reporting limits. Please refer to [this](export.md) guide to configure audit to push violations via this feature.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This feature allows plugging in different backends that allows Gatekeeper to export audit violations. Therefore, violations are not subject to reporting limits. Please refer to [this](export.md) guide to configure audit to push violations via this feature.
This feature allows different systems to be provided for Gatekeeper to export audit violations. Thereby, ensuing violations are not subject to reporting limits. Please refer to [this](export.md) guide to configure audit to push violations via this feature.

- There is an inherent risk of messages getting dropped. You might not receive all the published violations.
- Additional dependency on pubsub broker.
- There is a risk of messages getting dropped. You might not receive all the exported violations. This depends on the type of backend you are using for delivery. For example, using a network as backend to export violation has the risk of messages getting dropped.
- Additional dependency depending on what is plugged in. For example, using pubsub tools to export violations.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Additional dependency depending on what is plugged in. For example, using pubsub tools to export violations.
- Additional dependency on the backend system provided. For example, using pubsub tools to export violations.


## Running Audit
For more details on how to deploy audit and
number of instances to run, please refer to [operations audit](operations.md#audit).

## Configuring Audit

- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you are gathering audit results using the pubsub model, please refer to the [pubsub](pubsub.md) guide. Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.
- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you want to gather audit results via other means, please refer to the [exporting audit results](export.md) guide. Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you want to gather audit results via other means, please refer to the [exporting audit results](export.md) guide. Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.
- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you want to export audit results via other means, please refer to the [exporting audit results](export.md) guide. Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.

id: pubsub
title: Consuming violations using Pubsub
id: export
title: Exporting violations
Copy link
Member

Choose a reason for hiding this comment

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

do we want to add something like "Previously known as pubsub feature"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this idea if we will be removing it when we go beta or in couple of releases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added This feature was previously known as "Consuming violations using Pubsub" below feature state.

@@ -34,7 +34,7 @@ module.exports = {
'expansion',
'gator',
'workload-resources',
'pubsub',
'export',
Copy link
Member

Choose a reason for hiding this comment

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

How does this impact older versions of docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't, with older version of website it will route to pubsub.md. And once this PR gets merged, I doubt there would be any maintenance work for old docs since we are changing lots of things in the feature including name.

Signed-off-by: Jaydip Gabani <[email protected]>
Signed-off-by: Jaydip Gabani <[email protected]>
@JaydipGabani JaydipGabani requested a review from ritazh February 11, 2025 18:13

This feature uses publish and subscribe (pubsub) model that allows Gatekeeper to export audit violations over a broker that can be consumed by a subscriber independently. Therefore, pubsub violations are not subject to reporting limits. Please refer to [this](pubsub.md) guide to configure audit to push violations over a channel.
This feature allows different systems to be provided for Gatekeeper to export audit violations. Thereby, ensuing violations are not subject to reporting limits. Please refer to [this](export.md) guide to configure audit to push violations via this feature.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This feature allows different systems to be provided for Gatekeeper to export audit violations. Thereby, ensuing violations are not subject to reporting limits. Please refer to [this](export.md) guide to configure audit to push violations via this feature.
This feature allows different systems to be provided for Gatekeeper to export audit violations. Thereby, ensuring violations are not subject to reporting limits. Please refer to [the export guide](export.md) to configure audit to push violations via this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the docs.


## Running Audit
For more details on how to deploy audit and
number of instances to run, please refer to [operations audit](operations.md#audit).

## Configuring Audit

- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you are gathering audit results using the pubsub model, please refer to the [pubsub](pubsub.md) guide. Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.
- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you want to export audit results via other means, please refer to the [exporting audit results](export.md) guide. Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you want to export audit results via other means, please refer to the [exporting audit results](export.md) guide. Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.
- Audit violations per constraint: set `--constraint-violations-limit=123` (defaults to `20`). NOTE: This flag only impacts when gathering audit results using the constraint status model. If you want to export audit results via other means, please refer to [the export guide](export.md). Both approaches for getting audit violations can be configured independently and work simultaneously without any interference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@ritazh ritazh left a comment

Choose a reason for hiding this comment

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

Nit, otherwise LGTM

Copy link
Contributor

@maxsmythe maxsmythe left a comment

Choose a reason for hiding this comment

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

LGTM

@JaydipGabani JaydipGabani merged commit 18c2fbf into open-policy-agent:master Feb 12, 2025
22 checks passed
@JaydipGabani JaydipGabani deleted the exporter-interface branch February 12, 2025 23:32
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.

Decision log exporter side car
5 participants