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

Migrate to v2.0 to become a library #221

Conversation

alexander-ding
Copy link
Contributor

@alexander-ding alexander-ding commented Oct 5, 2022

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change

/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
In light of HostProcess containers on K8s Windows, we no longer need the client/server model, with a separate binary running on each Windows node. Instead, we can provide CSI Proxy's functionalities as a Go library to be imported by CSI driver implementations running in HostProcess containers. The change involves a complete restructure of the package structure and bumping the Go version to v2. Each API group is now provided under /pkg/, with the OS package written in /pkg//api.

Which issue(s) this PR fixes:

Part of #217

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

TODO

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Oct 5, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: alexander-ding
Once this PR has been reviewed and has the lgtm label, please assign andyzhangx for approval by writing /assign @andyzhangx in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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
Copy link
Contributor

Welcome @alexander-ding!

It looks like this is your first PR to kubernetes-csi/csi-proxy 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-csi/csi-proxy has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 5, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @alexander-ding. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 5, 2022
@mauriciopoppe
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 5, 2022
Copy link
Member

@mauriciopoppe mauriciopoppe left a comment

Choose a reason for hiding this comment

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

First pass review:

  • Add a more descriptive comment to the PR explaining what were the steps that you took in each commit
  • The PR is huge! I'd split it in different PRs, this is so that it's easier to review / traceback changes.

@@ -0,0 +1,238 @@
package disk
Copy link
Member

Choose a reason for hiding this comment

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

was this file copied or moved? I think we should move files first tracking them with git and then make changes

SERVICE_STATUS_CONTINUE_PENDING = 5
SERVICE_STATUS_PAUSE_PENDING = 6
SERVICE_STATUS_PAUSED = 7
SERVICE_STATUS_UNKNOWN ServiceStatus = iota
Copy link
Member

Choose a reason for hiding this comment

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

cool, thanks for this change

@@ -67,36 +64,34 @@ func TestServiceCommands(t *testing.T) {
require.NoError(t, err, "failed unmarshalling json out=%v", out)

assert.Equal(t, serviceInfo.Status, uint32(response.Status))
assert.Equal(t, v1alpha1.ServiceStatus_STOPPED, response.Status)
assert.Equal(t, system.SERVICE_STATUS_STOPPED, response.Status)
Copy link
Member

Choose a reason for hiding this comment

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

Nice, I see that this was generated from protoc but replaced with a const that was already defined in pkg/system/types.go


// Empty volume test
runNegativeIsVolumeFormattedRequest(t, client, "")
// runNegativeIsVolumeFormattedRequest(t, client, "")
Copy link
Member

Choose a reason for hiding this comment

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

what happened with these tests?

@k8s-ci-robot
Copy link
Contributor

@alexander-ding: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-csi-csi-proxy 080019c link true /test pull-kubernetes-csi-csi-proxy
pull-kubernetes-csi-csi-proxy-integration 080019c link true /test pull-kubernetes-csi-csi-proxy-integration

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.

@mauriciopoppe
Copy link
Member

Let's change the description a little bit more, #217 will become an umbrella item for the overall work i.e. remove fixes #217

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2022
@ameade
Copy link

ameade commented Oct 19, 2022

Looks like this not only enables using the CSI proxy as a library but removes the ability to run it as a gRPC server application? Please let me know if that's not true. Running the CSI Proxy separately from the CSI driver that uses it provides really valuable security isolation. Our current implementation for Windows SMB support (at NetApp) lets us have our Windows pods be unprivileged with no host access, leaving those privileges to the CSI Proxy. This greatly reduces the attack surface.

@alexander-ding
Copy link
Contributor Author

alexander-ding commented Oct 19, 2022

Looks like this not only enables using the CSI proxy as a library but removes the ability to run it as a gRPC server application? Please let me know if that's not true. Running the CSI Proxy separately from the CSI driver that uses it provides really valuable security isolation. Our current implementation for Windows SMB support (at NetApp) lets us have our Windows pods be unprivileged with no host access, leaving those privileges to the CSI Proxy. This greatly reduces the attack surface.

You're right. Note that the existing client-server model will still be available on the v1.x branch.

I'll defer to @mauriciopoppe to chime in on the security considerations.

@mauriciopoppe
Copy link
Member

@ameade Thanks for the feedback, CSI Proxy does provide format/mount isolation to some directories in the filesystem https://github.com/kubernetes-csi/csi-proxy/blob/v1.x/cmd/csi-proxy/main.go#L49 but with a few drawbacks.

Running the CSI Proxy separately from the CSI driver that uses it provides really valuable security isolation

  • The named pipes are not protected, this means that not only CSI Drivers but any Windows workload can mount them and execute privileged storage operations (imagine a workload reformatting the volume of another workload 😨). This is a current problem as of now.

In addition the current client/server model has some drawbacks, this is one of them:

  • It's hard to introduce new changes, to upgrade the CSI Driver with a new version of CSI Proxy we need to install a new binary and restart the Windows service, at the same time if there's a new API the CSI Driver needs to be updated with the new CSI Proxy client, on the CSI Proxy codebase that means supporting lots of autogenerated code like 1, 2 which slows down the development which has gotten to a stable point luckily, there have been attempts to ease the deployment in https://github.com/kubernetes-sigs/sig-windows-tools/blob/master/hostprocess/csi-proxy/README.md but the main problem is still the current client/server model that needs to support different API versions.

By becoming similar to the Linux node component which runs as a privileged container I think we'll have a similar deployment for both OSs. At the same time, enabling HostProcess Pods is also a security concern as it provides no filesystem isolation, this is a point I'll cover in the KEP and strategies on how to use it in a cluster.

Let's continue the discussion in the KEP.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 22, 2022
@mauriciopoppe
Copy link
Member

@ameade KEP is up in kubernetes/enhancements#3641, if you have further questions about the motivation, security or any other question please add it to the PR.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 2, 2022
@k8s-ci-robot
Copy link
Contributor

@alexander-ding: PR needs rebase.

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.

mauriciopoppe added a commit to mauriciopoppe/csi-proxy that referenced this pull request Jul 20, 2023
4133d1d Merge pull request kubernetes-csi#226 from msau42/cloudbuild
8d519d2 Pin buildkit to v0.10.6 to workaround v0.11 bug with docker manifest
6e04a03 Merge pull request kubernetes-csi#224 from msau42/cloudbuild
26fdfff Update cloudbuild image
6613c39 Merge pull request kubernetes-csi#223 from sunnylovestiramisu/update
0e7ae99 Update k8s image repo url
77e47cc Merge pull request kubernetes-csi#222 from xinydev/fix-dep-version
155854b Fix dep version mismatch
8f83905 Merge pull request kubernetes-csi#221 from sunnylovestiramisu/go-update
1d3f94d Update go version to 1.20 to match k/k v1.27
e322ce5 Merge pull request kubernetes-csi#220 from andyzhangx/fix-golint-error
b74a512 test: fix golint error
aa61bfd Merge pull request kubernetes-csi#218 from xing-yang/update_csi_driver
7563d19 Update CSI_PROW_DRIVER_VERSION to v1.11.0
a2171be Merge pull request kubernetes-csi#216 from msau42/process
cb98782 Merge pull request kubernetes-csi#217 from msau42/owners
a11216e add new reviewers and remove inactive reviewers
dd98675 Add step for checking builds
b66c082 Merge pull request kubernetes-csi#214 from pohly/junit-fixes
b9b6763 filter-junit.go: fix loss of testcases when parsing Ginkgo v2 JUnit
d427783 filter-junit.go: preserve system error log
38e1146 prow.sh: publish individual JUnit files as separate artifacts

git-subtree-dir: release-tools
git-subtree-split: 4133d1df083eaa65bdeddd0530d54278529c7a60
marosset added a commit to marosset/csi-proxy that referenced this pull request Jul 25, 2023
c10b678 Merge pull request kubernetes-csi#227 from coulof/check-sidecar-supported-versions
b055535 Header
bd0a10b typo
c39d73c Add comments
f6491af Script to verify EOL sidecar version
4133d1d Merge pull request kubernetes-csi#226 from msau42/cloudbuild
8d519d2 Pin buildkit to v0.10.6 to workaround v0.11 bug with docker manifest
6e04a03 Merge pull request kubernetes-csi#224 from msau42/cloudbuild
26fdfff Update cloudbuild image
6613c39 Merge pull request kubernetes-csi#223 from sunnylovestiramisu/update
0e7ae99 Update k8s image repo url
77e47cc Merge pull request kubernetes-csi#222 from xinydev/fix-dep-version
155854b Fix dep version mismatch
8f83905 Merge pull request kubernetes-csi#221 from sunnylovestiramisu/go-update
1d3f94d Update go version to 1.20 to match k/k v1.27
e322ce5 Merge pull request kubernetes-csi#220 from andyzhangx/fix-golint-error
b74a512 test: fix golint error
aa61bfd Merge pull request kubernetes-csi#218 from xing-yang/update_csi_driver
7563d19 Update CSI_PROW_DRIVER_VERSION to v1.11.0
a2171be Merge pull request kubernetes-csi#216 from msau42/process
cb98782 Merge pull request kubernetes-csi#217 from msau42/owners
a11216e add new reviewers and remove inactive reviewers
dd98675 Add step for checking builds
b66c082 Merge pull request kubernetes-csi#214 from pohly/junit-fixes
b9b6763 filter-junit.go: fix loss of testcases when parsing Ginkgo v2 JUnit
d427783 filter-junit.go: preserve system error log
38e1146 prow.sh: publish individual JUnit files as separate artifacts

git-subtree-dir: release-tools
git-subtree-split: c10b67804e07a324fe33595040afd13f020ee000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants