Skip to content

Gometalinter fixups for non-x86#34759

Merged
yongtang merged 4 commits intomoby:masterfrom
kolyshkin:gometalinter
Sep 18, 2017
Merged

Gometalinter fixups for non-x86#34759
yongtang merged 4 commits intomoby:masterfrom
kolyshkin:gometalinter

Conversation

@kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Sep 6, 2017

Two Three patches fixing things broken for non-x86 platforms after introducing gometalinter and additional linters. Please see commit messages.

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@seemethere seemethere left a comment

Choose a reason for hiding this comment

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

LGTM

@kolyshkin kolyshkin requested a review from tianon as a code owner September 7, 2017 19:07
@kolyshkin
Copy link
Contributor Author

I have just added one more commit. Quoting the changelog:

gometalinter: enable gc, increase deadline

I have run into two separate issues while doing 'make all' on armhf
(a Scaleway C1 machine, same as used in CI). This commit fixes both.

  1. There were a lot of "not enough memory" errors, and after that
    in a few runs gometalinter just stuck forever on FUTEX_WAIT with
    no children left.

Looking into docs, I found the --enable-gc option which solved the issue.

  1. Timeout of 2 minutes is not enough for the abovementioned platform.
    The longest running linter is goimports which takes almost 6 minutes to run.

Set the timeout to the observable run time plus roughly 30%.

@kolyshkin
Copy link
Contributor Author

kolyshkin commented Sep 7, 2017

The only remaining issue I see is go vet segfaults; filed a bug to golang: golang/go#21794

UPDATE this is a known issue fixed in go1.9

Copy link
Member

Choose a reason for hiding this comment

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

This can be overridden on the command line. Maybe we can set an environment variable for arm and keep the lower deadline? The environment variable can be used to set the command line flag in hack/validate/gometalinter

Really this should be able to run in a few seconds, so if it's this slow there is a problem somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed it takes under a minute on my (quite powerful) laptop, but about 6 minutes on a Scaleway C1 machine (which is in general pretty slow, as it's single 32-bit ARM CPU).

What about something like this:

diff --git a/hack/validate/gometalinter b/hack/validate/gometalinter
index 9830659d6..596370826 100755
--- a/hack/validate/gometalinter
+++ b/hack/validate/gometalinter
@@ -1,6 +1,18 @@
 #!/usr/bin/env bash
 set -e -o pipefail
 
+# Timeout is different depending on the arch. Values below are empirical.
+case $(uname -m) in
+       armv7l)
+               TIMEOUT=10m
+               ;;
+       *)
+               TIMEOUT=2m
+               ;;
+esac
+
 SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-gometalinter --config $SCRIPTDIR/gometalinter.json ./...
+gometalinter --deadline "$TIMEOUT" --config $SCRIPTDIR/gometalinter.json ./...

Copy link
Member

Choose a reason for hiding this comment

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

That could work, but is the timeout really dependent on the arch, or is it more about the particular host?

Maybe we can just do --deadline "${GOMETALINTER_TIMEOUT-2m}" and set that env value in Dockerfile.armhf ?

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, will redo. I also discovered that a run on AARCH64 does not fit into 2m either.

@dnephin
Copy link
Member

dnephin commented Sep 8, 2017

The EnableGC=true will be really good, I was having problems with it swapping on my desktop.

@kolyshkin kolyshkin force-pushed the gometalinter branch 4 times, most recently from ec13110 to 42b1369 Compare September 12, 2017 21:50
Since commit d7e2c4c ("Use gometalinter for linting") command
"make all" fails on all the non-default platforms (i.e. ARMs, PPC, and
s390) in this way:

	# make all
	...
	Congratulations!  All commits are properly signed with the DCO!
	/go/src/github.com/docker/docker/hack/validate/gometalinter: line 6: gometalinter: command not found
	Makefile:105: recipe for target 'all' failed
	make: *** [all] Error 127

Make sure gometalinter is installed for those platforms

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit reverts a hunk of commit 2f5f0af ("Add unconvert linter")
and adds a hint for unconvert linter to ignore excessive conversion as
it is required on 32-bit platforms (e.g. armhf).

The exact error on armhf is this:

	19:06:45 ---> Making bundle: dynbinary (in bundles/17.06.0-dev/dynbinary)
	19:06:48 Building: bundles/17.06.0-dev/dynbinary-daemon/dockerd-17.06.0-dev
	19:10:58 # github.com/docker/docker/daemon/graphdriver/overlay
	19:10:58 daemon/graphdriver/overlay/copy.go:161: cannot use stat.Atim.Sec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:161: cannot use stat.Atim.Nsec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:162: cannot use stat.Mtim.Sec (type int32) as type int64 in argument to time.Unix
	19:10:58 daemon/graphdriver/overlay/copy.go:162: cannot use stat.Mtim.Nsec (type int32) as type int64 in argument to time.Unix

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
I have run into two separate issues while doing 'make all' on armhf
(a Scaleway C1 machine, same as used in CI). This commit fixes both.

1. There were a lot of "not enough memory" errors, and after that
in a few runs gometalinter just stuck forever on FUTEX_WAIT with
no children left.

Looking into docs, I found the --enable-gc option which solved the issue.

[Update: this has already been added]

2. Timeout of 2 minutes is not enough for the abovementioned platform.
The longest running linter is goimports which takes almost 6 minutes to run.

Set the timeout to the observable run time roughly doubled.

In addition, ARM platforms does not have too much RAM (2GB), so
running too many processes in parallel might be problematic. Limit
it by using -j2

[v2: make the timeout arch-dependent, also tested on aarch64 (2m15s)]
[v3: moved timeout setting to Dockerfiles]
[v4: generalized to GOMETALINTER_OPTS, added -j2 for ARM platforms]
[v5: rebase to master]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This is mostly to include the following fix:
alecthomas/gometalinter@78e3fbd90a20b03a

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@thaJeztah
Copy link
Member

Does this depend on upgrading to Go 1.9 first?

@dnephin
Copy link
Member

dnephin commented Sep 13, 2017

I don't think so, why would it?

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

gometalinter --config $SCRIPTDIR/gometalinter.json ./...
# CI platforms differ, so per-platform GOMETALINTER_OPTS can be set
# from a platform-specific Dockerfile, otherwise let's just set
# (somewhat pessimistic) default of 10 minutes.
Copy link
Member

Choose a reason for hiding this comment

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

very pessimistic 😁

@thaJeztah
Copy link
Member

I saw this comment; that's why I wondered:

UPDATE this is a known issue fixed in go1.9

@kolyshkin
Copy link
Contributor Author

@thaJeztah it's just I found a (not quite related) issue with a linter which is fixed in Go 1.9. This is not a regression caused by these commits.

The overall reason for this series is more chances for make all on alternative (non-x86_64) platforms to succeed.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM (sorry already thought I did, 😊)

@yongtang
Copy link
Member

All tests passed 😅

@yongtang yongtang merged commit 65e88d9 into moby:master Sep 18, 2017
@kolyshkin kolyshkin deleted the gometalinter branch January 16, 2018 22:31
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.

6 participants