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

feat: allow providers to have the driver write files #481

Merged
merged 1 commit into from
Mar 26, 2021

Conversation

tam7t
Copy link
Contributor

@tam7t tam7t commented Mar 17, 2021

What this PR does / why we need it:

Expands the provider<->driver interface to allow the providers to have the driver write all files to the mount.

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 #460

Special notes for your reviewer:

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 17, 2021
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 17, 2021
@tam7t tam7t marked this pull request as ready for review March 17, 2021 21:43
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 17, 2021
@tam7t
Copy link
Contributor Author

tam7t commented Mar 18, 2021

/retest

@tam7t
Copy link
Contributor Author

tam7t commented Mar 18, 2021

/test pull-secrets-store-csi-driver-e2e-vault

@aramase
Copy link
Member

aramase commented Mar 18, 2021

vault e2e tests should be fixed with #483

@aramase
Copy link
Member

aramase commented Mar 19, 2021

/test pull-secrets-store-csi-driver-e2e-vault

pkg/util/tmpdir/tmpdir.go Outdated Show resolved Hide resolved
pkg/secrets-store/nodeserver_test.go Outdated Show resolved Hide resolved
pkg/util/fileutil/writer.go Outdated Show resolved Hide resolved
)

const (
maxFileNameLength = 255
Copy link
Member

Choose a reason for hiding this comment

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

For Azure Key vault, the max object name length is 128 and I assume this is a reasonable limit for the Google Secrets Manager as well. Is there a restriction for Hashicorp vault? Since this limit is being imposed now we should make sure we aren't breaking any exist cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@aramase aramase Mar 23, 2021

Choose a reason for hiding this comment

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

@tomhjp Do you see anything breaking with imposing this limit on the secret name length for the vault provider?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's no explicit limit currently but I'm ok with introducing this limit 👍

if targetPath == "" {
return fmt.Errorf("invalid path: must not be empty: %q", targetPath)
}
if path.IsAbs(targetPath) {
Copy link
Member

Choose a reason for hiding this comment

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

We should use filepath so this is valid for windows 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.

this was from https://github.com/kubernetes/kubernetes/blob/9c4ffa7e11bb2d0beb25ef1cac6e0699acfc350a/pkg/volume/util/atomic_writer.go#L256

Looking at path.IsAbs and filepath.IsAbs I'm fairly certain that their implementations are equivalent, so I'll move to filepath as that seems more semantically correct. Think we should propose a change to automic_writer.go too?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we should propose a change to atomic_writer.go. We can open a PR and get feedback from the community.

pkg/util/fileutil/writer_test.go Show resolved Hide resolved
string path = 1;
// The mode bits used to set permissions on this file.
// Must be a decimal value between 0 and 511.
int32 mode = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Today, the mode is sent to the provider from the driver. Having this will make it extensible in the future if we decide to support user configuration for mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack. My initial thoughts here are that we should deprecate permission in MountRequest and that permissions should be specified in the provider specific portion of the SecretProviderClass yaml at the same spot that secrets->files are mapped.


// File holds secret file contents and location in the mount path to write the
// file.
message File {
Copy link
Member

Choose a reason for hiding this comment

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

Could we also add a comment with the limitations on the size of the payload?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, i completely forgot about that. Do you think I should also add a configurable message size flag to this PR?

Copy link
Member

@aramase aramase Mar 24, 2021

Choose a reason for hiding this comment

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

I'm assuming bigger size than default supported would mean we would need to use grpc stream? I would be open to keeping the default with the limitation documented. If there are users with additional size, then we can add an option to configure. WDYT?

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 updated the repeated File files = 3 comment but we can just add a flag to control the MaxCallRecvMsgSize option when creating the plugin grpc client. This would require config/deploy from the user but would not require switching to grpc streaming. I believe this was what @tomhjp preferred in the design doc

@tam7t
Copy link
Contributor Author

tam7t commented Mar 23, 2021

/test pull-secrets-store-csi-driver-e2e-azure

1 similar comment
@aramase
Copy link
Member

aramase commented Mar 23, 2021

/test pull-secrets-store-csi-driver-e2e-azure

@k8s-ci-robot
Copy link
Contributor

@tam7t: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
release-secrets-store-csi-driver-e2e-gcp 171ef9a link /test release-secrets-store-csi-driver-e2e-gcp
release-secrets-store-csi-driver-e2e-vault 171ef9a link /test release-secrets-store-csi-driver-e2e-vault
release-secrets-store-csi-driver-e2e-azure 171ef9a link /test release-secrets-store-csi-driver-e2e-azure

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

},
},
{
name: "provider response with multiple files",
Copy link
Member

Choose a reason for hiding this comment

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

maybe add a test for 0 file returned

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "provider successful response" case covers this, but I've updated it to be explicit and this gave me the idea to use filepath.walk + go-cmp for better file comparisons

@@ -59,6 +61,27 @@ message MountRequest {
message MountResponse {
repeated ObjectVersion object_version = 1;
Error error = 2;
// files contains the entire mount volume filesystem.
//
// The total size of all files should not exceed 1MiB or syncing to
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 validate the file content size if this is a known limit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add it for the 1 MiB case but over 4MiB the RPC will fail. I've added a klog to MountContent for when the proto is > 1MiB.

@aramase aramase added this to the v0.0.21 milestone Mar 25, 2021
@aramase
Copy link
Member

aramase commented Mar 26, 2021

/test pull-secrets-store-csi-driver-e2e-windows

@ritazh
Copy link
Member

ritazh commented Mar 26, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 26, 2021
Copy link
Member

@aramase aramase left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aramase, tam7t

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2021
@k8s-ci-robot k8s-ci-robot merged commit ab0b325 into kubernetes-sigs:master Mar 26, 2021
@tam7t tam7t deleted the tam7t/obj-write-spike branch March 29, 2021 13:53
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: secret-store-csi-driver file IO consolidation
5 participants