Drillster / drone-volume-cache

Drone plugin for caching to a locally mounted volume
MIT License
109 stars 42 forks source link

Rsync fails when caching with drone exec #15

Closed DCRichards closed 6 years ago

DCRichards commented 6 years ago

Drone cli version: 0.7.0 OS: OSX 10.12.6

I encounter the following error when using caching with drone exec:

rsync: failed to set permissions on "/pipeline/src/node_modules/.bin/handlebars": Not supported (95)                                                                                                                                                           │ 71     mount:
rsync: failed to set permissions on "/pipeline/src/node_modules/.bin/uglifyjs": Not supported (95)                                                                                                                                                             │ 72       - app/build
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]                                                                                                                                              │ 73       - build
panic: runtime error: slice bounds out of range [recovered]                                                                                                                                                                                                    │ 74       - .gradle
        panic: runtime error: slice bounds out of range                                                                                                                                                                                                        │ 75     volumes:
                                                                                                                                                                                                                                                               │ 76       - /tmp/cache:/cache
goroutine 1 [running]:                                                                                                                                                                                                                                         │ 77
panic(0x822140, 0xc82000a060)                                                                                                                                                                                                                                  │ 78   slack:
        /usr/local/go/src/runtime/panic.go:481 +0x3e6                                                                                                                                                                                                          │ 79     image: plugins/slack
github.com/drone-plugins/drone-slack/vendor/github.com/urfave/cli.HandleAction.func1(0xc8200d1418)                                                                                                                                                             │ 80     username: drone
        /go/src/github.com/drone-plugins/drone-slack/vendor/github.com/urfave/cli/app.go:476 +0x417                                                                                                                                                            │ 81     channel: android-dev #TODO: Set the channel here if it's different
panic(0x822140, 0xc82000a060)                                                                                                                                                                                                                                  │ 82     secrets: [ slack_webhook ]
        /usr/local/go/src/runtime/panic.go:443 +0x4e9                                                                                                                                                                                                          │ 83     when:
main.message(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc8200d214c, 0x4, 0x0, 0x0, ...)                                                                                                                                                                                   │ 84       status: [ failure ]
        /go/src/github.com/drone-plugins/drone-slack/plugin.go:93 +0x40a                                                                                                                                                                                       │ 85
main.Plugin.Exec(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc8200d214c, 0x4, 0x0, 0x0, ...)                                                                                                                                                                               │ 86   slack:
        /go/src/github.com/drone-plugins/drone-slack/plugin.go:56 +0x7d                                                                                                                                                                                        │ 87     image: plugins/slack
main.run(0xc8200c2f00, 0x0, 0x0)                                                                                                                                                                                                                               │ 88     username: drone
        /go/src/github.com/drone-plugins/drone-slack/main.go:190 +0x983                                                                                                                                                                                        │ 89     channel: android-dev #TODO: Set the channel here if it's different
reflect.Value.call(0x780780, 0x9708e8, 0x13, 0x8a9398, 0x4, 0xc8200d1378, 0x1, 0x1, 0x0, 0x0, ...)                                                                                                                                                             │ 90     secrets: [ slack_webhook ]
        /usr/local/go/src/reflect/value.go:435 +0x120d                                                                                                                                                                                                         │ 91     when:
reflect.Value.Call(0x780780, 0x9708e8, 0x13, 0xc8200d1378, 0x1, 0x1, 0x0, 0x0, 0x0)                                                                                                                                                                            │ 92       event: [ tag ]
        /usr/local/go/src/reflect/value.go:303 +0xb1                                                                                                                                                                                                           │~
github.com/drone-plugins/drone-slack/vendor/github.com/urfave/cli.HandleAction(0x780780, 0x9708e8, 0xc8200c2f00, 0x0, 0x0)                                                                                                                                     │~
        /go/src/github.com/drone-plugins/drone-slack/vendor/github.com/urfave/cli/app.go:485 +0x2ee                                                                                                                                                            │~
github.com/drone-plugins/drone-slack/vendor/github.com/urfave/cli.(*App).Run(0xc820001080, 0xc82000a210, 0x1, 0x1, 0x0, 0x0)                                                                                                                                   │~
        /go/src/github.com/drone-plugins/drone-slack/vendor/github.com/urfave/cli/app.go:244 +0xb05                                                                                                                                                            │~
main.main()                                                                                                                                                                                                                                                    │~
        /go/src/github.com/drone-plugins/drone-slack/main.go:146 +0x17eb                                                                                                                                                                                       │~
2017/10/12 13:54:17 drone_step_3 : exit code 2```

My project is a simple node based project with the following setup for the cache:

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
    mount:
      - ./node_modules
    volumes:
      - /tmp/cache:/cache

Could this be a permissions issue relating to /tmp/cache? Looking in /tmp/cache however, I am able to see node_modules.

mjwwit commented 6 years ago

I'm sorry I didn't get around to this before... It's been a busy time for me..

This is probably an issue with the mounted volume. MacOS does not natively support Docker, which is why it's run inside a VM. Everything inside this VM works just fine, but a mounted volume will persist changes to the host. If, however, the VM filesystem tries to do something that's not supported by the host, you got yourself an error.

I'm not sure I can fix this though. The plugin isn't doing anything wrong. Are you using Docker for Mac or the older Docker Toolbox?

DCRichards commented 6 years ago

Hey @mjwwit, no worries, thanks for getting back to me.

I'm using the latest Docker for mac: 17.09.0-ce, build afdb6d4.

Is there a good way to get more info or debug this a little further myself?

mjwwit commented 6 years ago

Well, you can run the project outside of Drone like this: https://github.com/Drillster/drone-volume-cache#usage

If you need more logging, just clone this repo, add some additional echos, build your own image and run that. If you can isolate which file permissions are causing the issue we may be able to figure out a solution.

DCRichards commented 6 years ago

Sure thing, I'll look into it and let you know how I get on!

DCRichards commented 6 years ago

Aha... symlinks. Everything in node_modules/.bin/ is a symlink and this causes issues for rsync as it tries to resolve and copy it as a symlink, which seems to fail (I'm not 100% sure why... not sure what issue docker volumes have with it). We could run with -L which will create the file rather than as a symlink? As long as binary correctly exists in .bin/ it will be accessible to any node scripts right? And the same with any other files of other kinds which are symlinks.

mjwwit commented 6 years ago

The purpose of caching something is to make sure the file system is as close to the original as possible. If I start replacing links with the actual files that'd be changing the file system, which may cause way more problems than the one you're having. We should see why Docker for Mac can't deal with symlinks and get that fixed instead.

mjwwit commented 6 years ago

I'm closing this as it's an issue of Docker for Mac.