CiscoCloud / distributive

Unit testing for the cloud
Apache License 2.0
147 stars 20 forks source link

docker build fails due to incorrect time #99

Closed nyanshak closed 8 years ago

nyanshak commented 8 years ago

Expected: Running docker build . successfully builds a working Dockerfile to do testing Actual:

docker build .
Sending build context to Docker daemon 17.66 MB
Step 0 : FROM gliderlabs/alpine:3.2
 ---> 2cc966a5578a
Step 1 : MAINTAINER Langston Barrett <langston@aster.is> (@siddharthist)
 ---> Using cache
 ---> 78055b570203
Step 2 : RUN apk update && apk add go git && rm -rf /var/cache/apk/*
 ---> Using cache
 ---> ae4e568ca940
Step 3 : WORKDIR /gopath/src/github.com/CiscoCloud/distributive
 ---> Using cache
 ---> 423bbd08b2d3
Step 4 : RUN mkdir -p /gopath/{bin,src}
 ---> Using cache
 ---> beff8d25e2f5
Step 5 : ENV GOPATH /gopath
 ---> Using cache
 ---> 3e6d63c5e5fe
Step 6 : ENV GOBIN /gopath/bin
 ---> Using cache
 ---> 2775caa16cd6
Step 7 : ENV PATH $PATH:/gopath/bin
 ---> Using cache
 ---> 6e101cf806ee
Step 8 : RUN go get github.com/tools/godep
 ---> Using cache
 ---> 9c3015fa1f81
Step 9 : ADD . /gopath/src/github.com/CiscoCloud/distributive
 ---> Using cache
 ---> 7e3ab42c0b89
Step 10 : RUN go get .
 ---> Running in dde73be3297e
# cd .; git clone https://go.googlesource.com/crypto /gopath/src/golang.org/x/crypto
Cloning into '/gopath/src/golang.org/x/crypto'...
fatal: unable to access 'https://go.googlesource.com/crypto/': SSL certificate problem: certificate is not yet valid
package github.com/Sirupsen/logrus
    imports golang.org/x/crypto/sha3: exit status 128

Cause: Incorrect time causes SSL certificate verification to fail while trying to 'go get' dependencies. Environment: docker-machine using virtualbox on Mac OS X 10.11.1 Beta (El Capitan) [pretty sure this is not relevant] Possible fix: run ntpd somewhere in Dockerfile, e.g.: RUN ntpd -d -q -n -p 0.pool.ntp.org After applying that fix, I get something like this:

[distributive] vi Dockerfile                                                                            13:24:20  ☁  master ☂ ⚡
[distributive] docker build .                                                                           13:24:32  ☁  master ☂ ⚡
Sending build context to Docker daemon 17.66 MB
Step 0 : FROM gliderlabs/alpine:3.2
 ---> 2cc966a5578a
Step 1 : MAINTAINER Langston Barrett <langston@aster.is> (@siddharthist)
 ---> Using cache
 ---> 78055b570203
Step 2 : RUN apk update && apk add go git && rm -rf /var/cache/apk/*
 ---> Using cache
 ---> ae4e568ca940
Step 3 : WORKDIR /gopath/src/github.com/CiscoCloud/distributive
 ---> Using cache
 ---> 423bbd08b2d3
Step 4 : RUN mkdir -p /gopath/{bin,src}
 ---> Using cache
 ---> beff8d25e2f5
Step 5 : ENV GOPATH /gopath
 ---> Using cache
 ---> 3e6d63c5e5fe
Step 6 : ENV GOBIN /gopath/bin
 ---> Using cache
 ---> 2775caa16cd6
Step 7 : ENV PATH $PATH:/gopath/bin
 ---> Using cache
 ---> 6e101cf806ee
Step 8 : RUN go get github.com/tools/godep
 ---> Using cache
 ---> 9c3015fa1f81
Step 9 : ADD . /gopath/src/github.com/CiscoCloud/distributive
 ---> ad4f34062739
Removing intermediate container 4c949fc9f4ac
Step 10 : RUN ntpd -d -q -n -p 0.pool.ntp.org
 ---> Running in 9cc3c08e55e6
ntpd: sending query to 129.6.15.28
ntpd: reply from 129.6.15.28: offset:+0.018460 delay:0.040662 status:0x24 strat:1 refid:0x53544341 rootdelay:0.000000 reach:0x01
ntpd: sending query to 129.6.15.28
ntpd: reply from 129.6.15.28: offset:+0.022690 delay:0.046904 status:0x24 strat:1 refid:0x53544341 rootdelay:0.000000 reach:0x03
ntpd: sending query to 129.6.15.28
ntpd: reply from 129.6.15.28: offset:+0.026806 delay:0.057891 status:0x24 strat:1 refid:0x53544341 rootdelay:0.000000 reach:0x07
ntpd: sending query to 129.6.15.28
ntpd: reply from 129.6.15.28: offset:+0.020584 delay:0.042334 status:0x24 strat:1 refid:0x53544341 rootdelay:0.000000 reach:0x0f
ntpd: sending query to 129.6.15.28
ntpd: reply from 129.6.15.28: offset:+0.020087 delay:0.041306 status:0x24 strat:1 refid:0x53544341 rootdelay:0.000000 reach:0x1f
 ---> 508942a4bc1c
Removing intermediate container 9cc3c08e55e6
Step 11 : RUN go get .
 ---> Running in 15afa759ae6a
 ---> 17a8d2376a34
Removing intermediate container 15afa759ae6a
Step 12 : RUN go build .
 ---> Running in feb89e6b455e
 ---> e7ffbd6f7d39
Removing intermediate container feb89e6b455e
Step 13 : CMD distributive -f /gopath/src/github.com/CiscoCloud/distributive/samples/filesystem.json -d  --verbosity info
 ---> Running in ebdb6d4b7515
 ---> 6c634de687cf
Removing intermediate container ebdb6d4b7515
Successfully built 6c634de687cf

[distributive] docker run 6c634de687cf                                                                  13:25:23  ☁  master ☂ ⚡
time="2015-10-16T18:25:44Z" level=info msg="Creating checklist(s)..." path="/gopath/src/github.com/CiscoCloud/distributive/samples/filesystem.json" type=file
time="2015-10-16T18:25:44Z" level=info msg="Running checklist File"
time="2015-10-16T18:25:44Z" level=info msg="Running checklist Directory"
time="2015-10-16T18:25:44Z" level=info msg="Running checklist Symlink"
time="2015-10-16T18:25:44Z" level=info msg="Running checklist checksum"
time="2015-10-16T18:25:44Z" level=info msg="Running checklist checksum"
time="2015-10-16T18:25:44Z" level=info msg="Running checklist FileMatches"
time="2015-10-16T18:25:44Z" level=info msg="Running checklist Permissions"
time="2015-10-16T18:25:44Z" level=info msg="Running checklist DiskUsage"
time="2015-10-16T18:25:44Z" level=info msg="Report from checklist" checklist="Filesystem checks" report="↴\nTotal: 8\nPassed: 2\nFailed: 6\nOther: 0\nNo such file or directory: /swapfile\nNo such file or directory: /home/lb/Dropbox/workspace/www\nChecksums do not match for file: /proc/cpuinfo:\n\tSpecified: d41d8cd98f00b204e9800998ecf8427e\n\tActual: 7893716ba2111356aef27c7f6e53a802\nChecksums do not match for file: /proc/cpuinfo:\n\tSpecified: da39a3ee5e6b4b0d3255bfef95601890afd80709\n\tActual: 732d25bb0decd00b5d5fd52497ea34e9fdbed427\nFile does not match regexp:\n\tFile: /proc/net/tcp\n\tRegexp: \\d{8}\nFile did not have permissions: -rw-rw-rw-"

I'm not sure that that is the expected result of running the test, but at least I can get to the point of running the tests.

langston-barrett commented 8 years ago

Yep! That is the expected result. Would you mind submitting a pull request for that fix? Thanks for noticing!

nyanshak commented 8 years ago

I just realized this is probably not 100% distributive's fault here. It was definitely related to my environment, as docker-machine will not auto-sync on Mac OS X. By running docker-machine ssh default 'sudo ntpclient -s -h pool.ntp.org' before trying to build, it builds correctly. It's my mistake, but docker containers pull the time from the underlying host (in this case the virtualbox driver), which does not keep its time in sync. I can still submit a pull request if you'd like, but fixing the problem with virtualbox time syncing would go to the root cause.

nyanshak commented 8 years ago

Related to https://github.com/boot2docker/boot2docker/issues/840 or https://github.com/boot2docker/boot2docker/issues/290

langston-barrett commented 8 years ago

Ah, gotcha. Yeah, let's wait on upstream rather than adding a patch here. Maybe we can add a comment with the fix for those using b2d?

nyanshak commented 8 years ago

Yeah, it's strange though. I can see this in boot2docker's crontab, which should restart ntpd every minute:

# restart ntpd to combat laptop sleep + VM pause
0 * * * * killall ntpd > /dev/null 2>&1; /etc/rc.d/ntpd

However, that still didn't seem to fix the problem for me. I'll raise it upstream.

langston-barrett commented 8 years ago

Can you post your updated Dockerfile after sucessfully applying your fix, or if it's convenient, create a PR with a Dockerfile that has that line commented out?

nyanshak commented 8 years ago

Created pull request https://github.com/CiscoCloud/distributive/pull/100