Skip to content

Switch from package syscall to golang.org/x/sys/unix#49300

Merged
k8s-github-robot merged 3 commits intokubernetes:masterfrom
tklauser:syscall-to-x-sys-unix
Aug 3, 2017
Merged

Switch from package syscall to golang.org/x/sys/unix#49300
k8s-github-robot merged 3 commits intokubernetes:masterfrom
tklauser:syscall-to-x-sys-unix

Conversation

@tklauser
Copy link
Copy Markdown
Contributor

@tklauser tklauser commented Jul 20, 2017

What this PR does / why we need it:

The syscall package is locked down and the comment in https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24 advises to switch code to use the corresponding package from golang.org/x/sys. This PR does so and replaces usage of package syscall with package golang.org/x/sys/unix where applicable. This will also allow to get updates and fixes
without having to use a new go version.

In order to get the latest functionality, golang.org/x/sys/ is re-vendored. This also allows to use Eventfd() from this package instead of calling the eventfd() C function.

Special notes for your reviewer:

This follows previous works in other Go projects, see e.g. moby/moby#33399, cilium/cilium#588

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 20, 2017
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @tklauser. Thanks for your PR.

I'm waiting for a kubernetes 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.

I understand the commands that are listed here.

Details

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.

@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-label-needed release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Jul 20, 2017
@resouer
Copy link
Copy Markdown
Contributor

resouer commented Jul 20, 2017

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 20, 2017
Comment thread pkg/kubectl/rollback.go Outdated
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.

May I ask what's the go version required for this?

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.

I have only tested this with go 1.8.3 but I'd guess this should work with every version, as the underlying type of both syscall.Signal and unix.Signal is int.

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.

@resouer We only support go1.8.3 in any case...

@tklauser
Copy link
Copy Markdown
Contributor Author

The federation-e2e-gce test failure seems unrelated to the PR as indicated by the following log messages in https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/49300/pull-kubernetes-federation-e2e-gce/16070/?log#log:

...
I0720 14:57:30.326] Your "OAuth 2.0 Service Account" credentials are invalid. Please run
I0720 14:57:30.326]   $ gcloud auth login
I0720 14:57:30.326] Duplicate type [0:0:4]
I0720 14:57:43.091] CommandException: 1 file/object could not be transferred.
I0720 14:57:43.181] FAILED
I0720 14:57:43.184] 
I0720 14:57:43.187] 
I0720 14:57:43.189] Signal ERR caught!
I0720 14:57:43.192] 
I0720 14:57:43.194] Traceback (line function script):
I0720 14:57:43.195] 192 main /go/src/k8s.io/release/push-build.sh
I0720 14:57:43.197] 
I0720 14:57:43.200] Exiting...
I0720 14:57:43.202] 
I0720 14:57:43.205] 
I0720 14:57:43.206] push-build.sh: DONE main on ed611d83e0bd Thu Jul 20 14:57:43 UTC 2017 in 41s
W0720 14:57:43.306] 2017/07/20 14:57:43 util.go:131: Step '/go/src/k8s.io/release/push-build.sh --nomock --verbose --noupdatelatest --bucket=kubernetes-release-pull --ci --gcs-suffix=/pull-kubernetes-federation-e2e-gce --federation' finished in 40.529395722s
W0720 14:57:43.307] 2017/07/20 14:57:43 main.go:182: Saved XML output to /workspace/_artifacts/junit_runner.xml.
W0720 14:57:43.307] 2017/07/20 14:57:43 main.go:220: Something went wrong: failed to acquire k8s binaries: error during /go/src/k8s.io/release/push-build.sh --nomock --verbose --noupdatelatest --bucket=kubernetes-release-pull --ci --gcs-suffix=/pull-kubernetes-federation-e2e-gce --federation: exit status 2
...

@cmluciano
Copy link
Copy Markdown

Should these files be guarded with build tags?

@tklauser
Copy link
Copy Markdown
Contributor Author

@cmluciano AFAICT all files touched by this PR - except pkg/kubectl/rollback.go - already have either build tags or the filename set accordingly. As for rollback.go I'm not sure now whether this should even be converted or whether this is an arch-independent file? In the latter case, switching to x/sys/unix wouldn't be valid. Any advise there?

@luxas
Copy link
Copy Markdown
Member

luxas commented Jul 21, 2017

/test pull-kubernetes-cross

will tell us whether this works on all platforms

tklauser added 2 commits July 21, 2017 12:14
The syscall package is locked down and the comment in [1] advises to
switch code to use the corresponding package from golang.org/x/sys. Do
so and replace usage of package syscall with package
golang.org/x/sys/unix where applicable.

  [1] https://github.com/golang/go/blob/master/src/syscall/syscall.go#L21-L24

This will also allow to get updates and fixes for syscall wrappers
without having to use a new go version.

Errno, Signal and SysProcAttr aren't changed as they haven't been
implemented in /x/sys/. Stat_t from syscall is used if standard library
packages (e.g. os) require it. syscall.SIGTERM is used for
cross-platform files.
Use unix.Eventfd() instead of C.eventfd and also use the correct
corresponding unix.EFD_CLOEXEC flag. This allows to get rid of cgo.
@tklauser tklauser force-pushed the syscall-to-x-sys-unix branch from c38054f to 5acfb16 Compare July 21, 2017 10:15
@tklauser
Copy link
Copy Markdown
Contributor Author

I0721 10:00:32.022] +++ [0721 09:58:21] windows/amd64: go build started
I0721 10:00:32.023] # k8s.io/kubernetes/pkg/kubectl
I0721 10:00:32.023] pkg/kubectl/rollback.go:111: undefined: unix.SIGTERM

Apparently pkg/kubectl/rollback.go is also needed for Windows, so syscall.SIGTERM needs to stay there. I just pushed an updated version of the PR.

@tklauser
Copy link
Copy Markdown
Contributor Author

kubemark-e2e-gce failure seems to be the same as #49320

@tklauser
Copy link
Copy Markdown
Contributor Author

/retest

@luxas
Copy link
Copy Markdown
Member

luxas commented Jul 31, 2017

Test the cross-build again:
/test pull-kubernetes-cross

For the pull-kubernetes-e2e-gce-etcd3 flake:
/retest

@thockin
Copy link
Copy Markdown
Member

thockin commented Jul 31, 2017

This needs an associated issue and a closes #12345 in the FIRST COMMENT, or it can not be approved.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 31, 2017
@k8s-github-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: thockin, tklauser

Associated issue: 33399

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

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 31, 2017
@k8s-github-robot
Copy link
Copy Markdown

@k8s-bot test this

Tests are more than 96 hours old. Re-running tests.

@luxas
Copy link
Copy Markdown
Member

luxas commented Jul 31, 2017

/retest

@tklauser
Copy link
Copy Markdown
Contributor Author

tklauser commented Aug 1, 2017

Seems like the results for pull-kubernetes-cross and @k8s-ci-robot
pull-kubernetes-kubemark-e2e-gce weren't picked up, even though they were successful. Maybe due to the Github outage yesterday?

@luxas
Copy link
Copy Markdown
Member

luxas commented Aug 1, 2017

/test pull-kubernetes-cross
/retest

@tklauser
Copy link
Copy Markdown
Contributor Author

tklauser commented Aug 2, 2017

There still seems to be some issue communicating back the status of pull-kubernetes-kubemark-e2-gce :(

/retest

@fejta
Copy link
Copy Markdown
Contributor

fejta commented Aug 3, 2017

I believe the hung status was a prow/plank bug that was fixed earlier this week

/test pull-kubernetes-kubemark-e2e-gce

@tklauser
Copy link
Copy Markdown
Contributor Author

tklauser commented Aug 3, 2017

Thank you @fejta!

@k8s-github-robot
Copy link
Copy Markdown

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 5d24a2c into kubernetes:master Aug 3, 2017
@tklauser tklauser deleted the syscall-to-x-sys-unix branch August 9, 2017 09:26
k8s-github-robot pushed a commit that referenced this pull request Sep 3, 2017
Automatic merge from submit-queue (batch tested with PRs 51666, 49829, 51058, 51004, 50938)

Fix threshold notifier build tags

**What this PR does / why we need it**:
Cross building from darwin is currently broken on the following error:
```
# k8s.io/kubernetes/pkg/kubelet/eviction
pkg/kubelet/eviction/threshold_notifier_unsupported.go:25: NewMemCGThresholdNotifier redeclared in this block
        previous declaration at pkg/kubelet/eviction/threshold_notifier_linux.go:38
```
It looks like #49300 broke the build tags introduced in #38630 and #37384. This fixes the build tag on `threshold_notifier_unsupported.go` as the cgo requirement was removed from `threshold_notifier_linux.go`.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #50935

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
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. release-note-none Denotes a PR that doesn't merit a release note. 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.

9 participants