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

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

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.67%. Comparing base (3350319) to head (2fba5c2).
Report is 245 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 (2fba5c2). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (3350319) HEAD (2fba5c2)
unittests 2 1
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3646      +/-   ##
==========================================
- Coverage   54.49%   47.67%   -6.83%     
==========================================
  Files         134      234     +100     
  Lines       12329    19855    +7526     
==========================================
+ Hits         6719     9465    +2746     
- Misses       5116     9498    +4382     
- Partials      494      892     +398     
Flag Coverage Δ
unittests 47.67% <52.83%> (-6.83%) ⬇️

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.

@@ -67,8 +67,8 @@ var (
auditEventsInvolvedNamespace = flag.Bool("audit-events-involved-namespace", false, "emit audit events for each violation in the involved objects namespace, the default (false) generates events in the namespace Gatekeeper is installed in. Audit events from cluster-scoped resources will still follow the default behavior")
auditMatchKindOnly = flag.Bool("audit-match-kind-only", false, "only use kinds specified in all constraints for auditing cluster resources. if kind is not specified in any of the constraints, it will audit all resources (same as setting this flag to false)")
apiCacheDir = flag.String("api-cache-dir", defaultAPICacheDir, "The directory where audit from api server cache are stored, defaults to /tmp/audit")
auditConnection = flag.String("audit-connection", defaultConnection, "(alpha) Connection name for publishing audit violation messages. Defaults to audit-connection")
auditChannel = flag.String("audit-channel", defaultChannel, "(alpha) Channel name for publishing audit violation messages. Defaults to audit-channel")
auditConnection = flag.String("audit-connection", defaultConnection, "(alpha) Connection name for exporting audit violation messages. Defaults to audit-connection")
Copy link
Member

Choose a reason for hiding this comment

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

exporter-connection?

Copy link
Contributor Author

@JaydipGabani JaydipGabani Jan 28, 2025

Choose a reason for hiding this comment

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

we may want to change default to something else in this case?

I am wondering if removing audit-connection and audit-channel flags altogether makes sense. We would create connections for configmaps created in gatekeeper-system when gatekeeper.sh/exporter-config: yes annotation is attached to it. This opens up door for supporting multiple connections at the same time as well by creating connections with multiple config_map rather than the one passed down with --audit-connection. And audit-channel should be passed in as part of the config. Additionally, replacing config_map with CRD should also be relatively seamless with this modification.

I am more than happy to just change flag names and helm variables in revisit this later. LMK your thoughts @sozercan @maxsmythe @ritazh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per community discussion, keep the flag names as is and then remove once we have CRD inplace.

auditConnection = flag.String("audit-connection", defaultConnection, "(alpha) Connection name for publishing audit violation messages. Defaults to audit-connection")
auditChannel = flag.String("audit-channel", defaultChannel, "(alpha) Channel name for publishing audit violation messages. Defaults to audit-channel")
auditConnection = flag.String("audit-connection", defaultConnection, "(alpha) Connection name for exporting audit violation messages. Defaults to audit-connection")
auditChannel = flag.String("audit-channel", defaultChannel, "(alpha) Channel name for exporting audit violation messages. Defaults to audit-channel")
Copy link
Member

Choose a reason for hiding this comment

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

export-channel?

Signed-off-by: Jaydip Gabani <[email protected]>
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