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

dynamic host volumes: ACL policies #24356

Merged
merged 1 commit into from
Nov 5, 2024
Merged

Conversation

tgross
Copy link
Member

@tgross tgross commented Nov 1, 2024

This changeset implements the ACLs required for dynamic host volumes RPCs:

  • host-volume-write is a coarse-grained policy that implies all operations.
  • host-volume-register is the highest fine-grained privilege because it potentially bypasses quotas.
  • host-volume-create is implicitly granted by host-volume-register
  • host-volume-delete is implicitly granted only by host-volume-write
  • host-volume-read is implicitly granted by policy = "read",

These are namespaced operations, so the testing here is predominantly around parsing and granting of implicit capabilities rather than the well-tested AllowNamespaceOperation method.

This changeset does not include any changes to the host_volumes policy which we'll need for claiming volumes on job submit (if any). That'll be covered in a later PR.

Ref: https://hashicorp.atlassian.net/browse/NET-11549

Copy link
Contributor

@pkazmierczak pkazmierczak left a comment

Choose a reason for hiding this comment

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

LGTM, but wouldn't we also want an ACL for volume removal?

@tgross
Copy link
Member Author

tgross commented Nov 5, 2024

LGTM, but wouldn't we also want an ACL for volume removal?

That's a good question. Only Variables and Node Pools have an explicit separate of write vs delete today. While I've been working on the RPCs handlers I've been assuming that host-volume-create gives you delete as well, but if we were going to do that it should probably be called host-volume-write. So maybe it's better just to have a separate delete ACL?

@tgross
Copy link
Member Author

tgross commented Nov 5, 2024

I've updated the PR and its description as per the discussion between you, me, and @gulducat.

Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

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

lgtm! just one policy question, a style nit, and a typo.

@@ -241,6 +246,7 @@ func expandNamespacePolicy(policy string) []string {
NamespaceCapabilityReadJobScaling,
NamespaceCapabilityListScalingPolicies,
NamespaceCapabilityReadScalingPolicy,
NamespaceCapabilityHostVolumeRead,
Copy link
Member

Choose a reason for hiding this comment

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

since there's no addition to write below, policy = "write" does not imply host-volume-write (and its descendants) in contrast to CSI?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, that's how I wrote it in the RFC, but I'm realizing that I missed that policy = "write" gives csi-write-volume. Once you're using a coarse-grained policy you can't subtract capabilities from it. So we can do that here, but I think we should probably have it only imply host-volume-create/read so that the broad policy doesn't imply delete and the quota-breaking register

Copy link
Member

Choose a reason for hiding this comment

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

is that what's meant by the ACL policies doc stating

When both the policy short hand and a capabilities list are provided, the capabilities are merged.

I suppose deny would win? but aside from that, a merger would be additive, not subtractive.

aside from losing the simplicity of "write means write", "write means create/read" seems like a reasonable trade-off. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah deny would win but it's coarse-grained so it flattens everything.

aside from losing the simplicity of "write means write", "write means create/read" seems like a reasonable trade-off.

Yeah, I think it's an example of how some early choices in Nomad's design (like how we did coarse-grained ACLs) were perfectly good choices at the time but make for awkward decisions in a more mature product years later 😁

acl/policy.go Outdated Show resolved Hide resolved
acl/policy.go Outdated Show resolved Hide resolved
This changeset implements the ACLs required for dynamic host volumes RPCs:
* `host-volume-write` is a coarse-grained policy that implies all operations.
* `host-volume-register` is the highest fine-grained privilege because it
  potentially bypasses quotas.
* `host-volume-create` is implicitly granted by `host-volume-register`
* `host-volume-delete` is implicitly granted only by `host-volume-write`
* `host-volume-read` is implicitly granted by `policy = "read"`,

These are namespaced operations, so the testing here is predominantly around
parsing and granting of implicit capabilities rather than the well-tested
`AllowNamespaceOperation` method.

This changeset does not include any changes to the `host_volumes` policy which
we'll need for claiming volumes on job submit. That'll be covered in a later PR.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
@tgross tgross merged commit 9cdd81b into dynamic-host-volumes Nov 5, 2024
17 checks passed
@tgross tgross deleted the dhv-acl-policies branch November 5, 2024 20:19
tgross added a commit that referenced this pull request Nov 5, 2024
This changeset implements the ACLs required for dynamic host volumes RPCs:
* `host-volume-write` is a coarse-grained policy that implies all operations.
* `host-volume-register` is the highest fine-grained privilege because it
  potentially bypasses quotas.
* `host-volume-create` is implicitly granted by `host-volume-register`
* `host-volume-delete` is implicitly granted only by `host-volume-write`
* `host-volume-read` is implicitly granted by `policy = "read"`,

These are namespaced operations, so the testing here is predominantly around
parsing and granting of implicit capabilities rather than the well-tested
`AllowNamespaceOperation` method.

This changeset does not include any changes to the `host_volumes` policy which
we'll need for claiming volumes on job submit. That'll be covered in a later PR.

Ref: https://hashicorp.atlassian.net/browse/NET-11549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants