Skip to content

[WIP, POC] Add PolicyEnforcementMode to RBAC policy definition#3548

Closed
quanjielin wants to merge 2 commits intoenvoyproxy:masterfrom
quanjielin:quanlinplay1
Closed

[WIP, POC] Add PolicyEnforcementMode to RBAC policy definition#3548
quanjielin wants to merge 2 commits intoenvoyproxy:masterfrom
quanjielin:quanlinplay1

Conversation

@quanjielin
Copy link
Copy Markdown
Contributor

@quanjielin quanjielin commented Jun 5, 2018

#3552

Updated POC PR: #3554

Use case:
rbac policy dark launch - test new rbac policies work as expected before it's rolled out to production, policy in dark_launch mode won't effect real users, rbac filter just log the results by applying policies and sending metrics to some metrics store/then build dashboard.

@quanjielin quanjielin force-pushed the quanlinplay1 branch 2 times, most recently from 4f34517 to 7995570 Compare June 5, 2018 18:10
@mattklein123
Copy link
Copy Markdown
Member

Nice, I like this idea. @rodaine can you take a first pass?

@quanjielin quanjielin force-pushed the quanlinplay1 branch 4 times, most recently from d5e7ab4 to 3404a67 Compare June 5, 2018 19:16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

coding wise, it is more readable to return a struct with two boolean.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or return an enum.
Alternatively, keep this function the same, but handle the result in filter only.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, talked to @diemtvu offline, will use another POC PR #3554, which evaluate two rules(enforcement/darklaunch) independently.

@quanjielin
Copy link
Copy Markdown
Contributor Author

/cc @qiwzhang @liminw @diemtvu

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or return an enum.
Alternatively, keep this function the same, but handle the result in filter only.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not follow this logic. Can we keep this function as is, and in the filter, simply check if poicy.isDarklaunch() (or engine.isDarklaunch()) to decide if it should reject request or simply log result?

Copy link
Copy Markdown
Member

@rodaine rodaine left a comment

Choose a reason for hiding this comment

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

Oh this is great! Some comments around intent in the PolicyMatcher, particularly around changing the current behavior which short-circuits on the first match.

Based off this, I'd recommend we treat policies different than just matchers and elevate them. FWICT, we want to execute all dark policies for evaluation, and emit tagged stats for any matched policy (be it dark or ... erm light?)

Also, darklaunch seems a bit strange to me naming wise. Is there an existing convention in Envoy's nomenclature (like shadow?) we can use instead?

enum PolicyEnforcementMode {
POLICY_ENFORCEMENT_ENFORCED = 0;
POLICY_ENFORCEMENT_DARKLAUNCH = 1;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we namespace this under the Policy message? Then we don't need to prefix these.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removed this from proto in 2nd POC

for (const auto& policy : policies_) {
if (policy.matches(connection, headers)) {
matched = true;
break;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This (erm) breaks the existing short circuiting behavior of the engine. I don't think we want to always evaluate every policy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

separated rules(enforce/darklaunch) approach in 2nd POC solves this issue

matched = true;
}

darklaunch_matched_ = true;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the intent here? We want to tell the filter that we matched a particular dark policy (or policies) correct? If so, this currently will always be true if we match any filter, and we end up hiding which policy (or policies) actually matched.

if (darklaunch_allowed) {
config_->stats().darklaunch_allowed_.inc();
} else {
config_->stats().darklaunch_denied_.inc();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For both the existing stats as well as these dark ones, I feel like we should apply tags with the matching policy name so we can identify the source of the allow/deny.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agree, will put this in separated PR about what attributes need to be collected and how to pass data to metrics storage(pass data cross-filters, etc)

@quanjielin
Copy link
Copy Markdown
Contributor Author

Close this PR since it's replaced by #3554

@quanjielin quanjielin closed this Jun 6, 2018
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.

5 participants