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(util): Allows building for darwin targets #133

Merged
merged 2 commits into from
May 27, 2022

Conversation

thomastaylor312
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

This is a simple change that allows the registrar to be built for MacOS. All of the unix package being used works for Mac as well. The reason for enabling this is completely selfish I'll admit. We are adding CSI Support to the Krustlet project, which supports Mac as well. As most CSI implementations don't support registering themselves with the Kubelet directly, we wanted to unblock any users to need to register their plugins with a Krustlet Kubelet. This change shouldn't affect normal container-based usage of the registrar

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 28, 2021
@k8s-ci-robot k8s-ci-robot requested review from lpabon and msau42 January 28, 2021 18:57
@k8s-ci-robot
Copy link
Contributor

Welcome @thomastaylor312!

It looks like this is your first PR to kubernetes-csi/node-driver-registrar 🎉. 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/node-driver-registrar 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
Copy link
Contributor

Hi @thomastaylor312. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 28, 2021
pohly added a commit to pohly/node-driver-registrar that referenced this pull request Feb 3, 2021
7bc70e52 Merge pull request kubernetes-csi#129 from pohly/squash-documentation
e0b02e72 README.md: document usage of --squash
316cb957 Merge pull request kubernetes-csi#132 from yiyang5055/bugfix/boilerplate
26e2ab10 fix: default boilerplate path
1add8c18 Merge pull request kubernetes-csi#133 from pohly/kubernetes-1.20-tag
3e811d6c prow.sh: fix "on-master" prow jobs

git-subtree-dir: release-tools
git-subtree-split: 7bc70e5264a5ce5f47780bdbc6c7b7f4e79243fa
@msau42
Copy link
Collaborator

msau42 commented Mar 31, 2021

/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 Mar 31, 2021
@msau42
Copy link
Collaborator

msau42 commented Mar 31, 2021

@pohly do you know if we can add this to our build job to make sure this compiles? Better yet, if we can release images with it?

@pohly
Copy link
Contributor

pohly commented Mar 31, 2021

@pohly do you know if we can add this to our build job to make sure this compiles?

We only do build and unit tests for the default Go platform on which we run (linux amd64), so this would be a rather bigger change but ...

Better yet, if we can release images with it?

... this should be as simple as adding "darwin linux" to

configvar CSI_PROW_BUILD_PLATFORMS "linux amd64; windows amd64 .exe; linux ppc64le -ppc64le; linux s390x -s390x; linux arm64 -arm64" "Go target platforms (= GOOS + GOARCH) and file suffix of the resulting binaries"

Well, "should". I just tried it with make push-multiarch-csi-node-driver-registrar BUILD_PLATFORMS="linux amd64;windows amd64 .exe;darwin amd64" PULL_BASE_REF=master REGISTRY_NAME=pohly and "docker buildx" fails for Darwin. The code itself compiled fine.

+ docker buildx build --push --tag pohly/csi-node-driver-registrar:amd64-darwin-canary --platform=darwin/amd64 --file --build-arg binary=./bin/csi-node-driver-registrar --label revision=v2.1.0-1-g083d5ab9 .
"docker buildx build" requires exactly 1 argument.
See 'docker buildx build --help'.

Usage:  docker buildx build [OPTIONS] PATH | URL | -

The same command worked for --platform=linux/amd64 and --platform=windows/amd64.

This might be an issue with my local setup. https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images explicitly mentions darwin/amd64.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 29, 2021
@thomastaylor312
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 29, 2021
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 3, 2021
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 3, 2021
@mauriciopoppe
Copy link
Member

mauriciopoppe commented Aug 4, 2021

Sorry for creating the need for a rebase, I think that the first line should also be changed to //go:build !windows, I think it was added by my editor on save

@thomastaylor312
Copy link
Contributor Author

Sweet, I'll fix that real quick

This is a simple change that allows the registrar to be built for MacOS.
All of the `unix` package being used works for Mac as well. The reason for
enabling this is completely selfish I'll admit. We are adding
[CSI Support](krustlet/krustlet#462) to the Krustlet
project, which supports Mac as well. As most CSI implementations don't support
registering themselves with the Kubelet directly, we wanted to unblock any
users to need to register their plugins with a Krustlet Kubelet. This change
shouldn't affect normal container-based usage of the registrar
@@ -1,5 +1,5 @@
//go:build linux
// +build linux
//go:build !windows
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the first time I've seen the "nix" suffix being used. Is there a general convention that the Kubernetes project is using to support darwin?

Copy link
Contributor

Choose a reason for hiding this comment

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

@thomastaylor312: can you explain where the _nix.go filename comes from? Is that being used elsewhere already?

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 can just call it unix if you prefer. I was just trying to indicate that this file wasn't for just linux, but any *nix system. I don't have any sort of a strong preference. Also no skin off of my teeth if you don't want to support darwin targets. This was just a proposal of something to do and can be shot down. As you can see, there was no change to code, so the restriction to linux build targets only was artificial and not for any specific code reason insofar as I can tell

Copy link
Contributor

Choose a reason for hiding this comment

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

I (like @msau42 I guess) was just wondering. Personally I prefer "unix" over "nix". The latter might not be immediately recognizable as a placeholder for "unix or linux".

Kubernetes releases darwin/amd64 and darwin/arm64 client binaries, but not node binaries. I'm fine with merging this PR, but I would not actually build container images for Darwin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, no need to build a container image here. Let me rename the file real quick

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, file has been renamed!

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 9, 2021
@thomastaylor312
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 9, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 7, 2022
@thomastaylor312
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 7, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 8, 2022
@thomastaylor312
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 23, 2022
Signed-off-by: Taylor Thomas <[email protected]>
Copy link
Contributor

@pohly pohly left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 24, 2022
@pohly
Copy link
Contributor

pohly commented May 24, 2022

/assign @jsafrane

For approval.

@jsafrane
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, pohly, thomastaylor312

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 May 27, 2022
@k8s-ci-robot k8s-ci-robot merged commit 5aa7c89 into kubernetes-csi:master May 27, 2022
@thomastaylor312 thomastaylor312 deleted the feat/support_mac branch May 27, 2022 19:13
@thomastaylor312
Copy link
Contributor Author

Thanks all!

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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants