datakit icon indicating copy to clipboard operation
datakit copied to clipboard

CI: local-bridge does not rebuild on new commit

Open Thegaram opened this issue 7 years ago • 3 comments

I am building a local CI workflow based on self-ci, using the local git bridge.

The CI is running fine, but new commits are not picked up until I restart. The readme under local-bridge says: "DataKitCI can be configured to run the CI tests against the project each time a commit is made." What do I need to do to achieve this?

My config looks like this:

bridge:
  command: '--verbosity=debug --metadata-store tcp:datakit:5640 -v me/myproject:/data/repos/myproject'
  image: 'datakit/local-bridge'
  links:
    - datakit
  volumes:
    - '../myproject/.git:/data/repos/myproject/.git:ro'
ci:
  command: '--profile=localhost --metadata-store tcp:datakit:5640 --web-ui=http://localhost:8080/ --canary=me/myproject/heads/master'
  build: .
  links:
    - datakit
  ports:
    - '8080:8080'
  volumes:
    - '../myproject/.git:/mnt/myproject/.git:ro'
    - '/secrets'
    - '/var/run/docker.sock:/var/run/docker.sock'

Thegaram avatar Mar 26 '18 08:03 Thegaram

It used to work, but maybe something changed. Maybe it's the same read-only :ro problem as before?

When it's working correctly, you should see https://github.com/moby/datakit/blob/master/bridge/local/sync.ml#L26 logging a message when something changes, followed by https://github.com/moby/datakit/blob/master/bridge/local/sync.ml#L38.

That will wake https://github.com/moby/datakit/blob/master/bridge/local/sync.ml#L105 and you should see https://github.com/moby/datakit/blob/master/bridge/local/sync.ml#L81. You should then see a new commit appear in the DataKit Git repository with the new head. The CI monitors this and should rebuild.

If on_change isn't being called, maybe something went wrong setting up the watch at https://github.com/moby/datakit/blob/master/bridge/local/sync.ml#L48.

talex5 avatar Mar 27 '18 12:03 talex5

I tried again with local-bridge compiled and run directly (without docker) and it works this way. It seems to be a docker related issue, my container was not picking up the changes from the mounted volumes. This might be related.

Thegaram avatar Apr 03 '18 12:04 Thegaram

Okay it seems like docker does in fact correctly mount volumes. I created a simple container:

FROM alpine:3.5
ENTRYPOINT ["watch", "-n1", "tail /data/.git/logs/refs/heads/master"]

And then ran it, mounting my git repo:

$ docker build -t testvolume -f MyDockerfile .
$ docker run -it --rm -v /path/to/my/repo:/data:ro testvolume

And it correctly picked up any new commit messages. @talex5 do you have any ideas why picking up changes works natively (Mac) but does not work in a container for the local bridge?

Command to run natively:

$ ./main.exe --metadata-store tcp:127.0.0.1:5640 -v me/myproject:/path/to/my/repo

Command to run in a container:

$ docker run -it --rm --network host -v /path/to/my/repo/.git:/data/repos/myproject/.git datakit/local-bridge --metadata-store tcp:127.0.0.1:5640 -v me/myproject:/data/repos/myproject

Thegaram avatar Apr 04 '18 08:04 Thegaram