Unable to trigger build with the downstream plugin

Since moving my drone installation to a new server, triggering downstream builds using the plugin does not seem to work anymore.
Output from the pipeline step:

latest: Pulling from plugins/downstream
Digest: sha256:b7924a1048636fbcf7ce9f0e706017c9b5ed705aa440ee8a76b387575f8b33e8
Status: Image is up to date for plugins/downstream:latest
time="2021-08-05T22:25:54Z" level=error msg="execution failed: unable to trigger build for user/repo@main"

I’ve tried the following:

  • Made sure there is a build in the other repo for drone to trigger
  • Removed and re-entered the drone_token secret (all other secrets work fine)
  • Just retried the build a bunch of times

It does not seem to make a difference if I’m retrying a build or if I restart a previous build.

Any idea how to debug this? From the code, it looks like it is ignoring the error, there’s nothing in the drone server logs either.

This is the pipeline:

kind: pipeline
name: trigger-desktop-update
trigger:
  branch:
    - main
  event:
    - push
depends_on:
  - release-latest
steps:
  - name: trigger
    image: plugins/downstream
    settings:
      server: https://drone.tld
      token:
        from_secret: drone_token
      repositories:
        - user/repo@main

I have used this plugin recently and have not had any issues. Did you look at the drone server logs (with debug enabled) to see why it might have failed? Can you confirm the request is reaching the Drone server (maybe it is a dns issue)? I also recommend taking a look at the source code (you can compile from source) to see if you can figure out what is wrong https://github.com/drone-plugins/drone-downstream

I’ll try again with debug logging enabled but so far there’s nothing in the logs.

From the code, it looks like it is ignoring the error returned when the build is restarted so I’m not sure how to actually debug this.

If you are already looking at the code, my recommendation would be to modify the code and see if that helps you debug further. For example, maybe instead of ignoring the error, you could print it out? And if that helps, perhaps consider submitting the change as a pull request back to the repository.

I’ll try that.

Running the server with debug logs enabled didn’t get any results.

When debug mode is enabled, Drone writes a log entry for every http request. If you don’t see anything in the logs it would tell me that the request is not reaching the Drone server (meaning there is some sort of networking or dns issue). It sounds like printing out the error (currently being ignored by the plugin) might help you determine the root cause.

Kind of embarrassing, looks like I’ve set DRONE_DEBUG=true and not DRONE_LOGS_DEBUG=true. No wonder nothing was printed.

I’ve fixed that and now there’s a whole bunch of messages, just need to wait until it gets to the downstream trigger step. I also changed the plugin to one with a fix by me, so hopefully we should get something usable.

Now here’s something from the plugin:

 client error 401: {\"message\":\"Unauthorized\"}\n"

And something in the drone server logs:

host_1  | {"level":"debug","msg":"manager: updating step status","step.id":599,"step.name":"trigger","step.status":"running","time":"2021-08-05T23:04:31Z"}
host_1  | {"level":"debug","msg":"api: root access granted","name":"frontend","namespace":"vikunja","request-id":"1wKQCLTyJQcx1yVAAKm63VFOMxa","time":"2021-08-05T23:04:31Z","user.admin":true,"user.login":"kolaente"}
host_1  | {"level":"debug","msg":"api: read access granted","name":"desktop","namespace":"vikunja","request-id":"1wKQCgpQCRMZAgOlXPExLBKc54H","time":"2021-08-05T23:04:34Z","visibility":"public"}
host_1  | {"level":"debug","msg":"api: guest access","request-id":"1wKQCgpQCRMZAgOlXPExLBKc54H","time":"2021-08-05T23:04:34Z"}
host_1  | {"fields.time":"2021-08-05T23:04:34Z","latency":2966144,"level":"debug","method":"GET","msg":"","remote":"192.168.192.2:56246","request":"/api/repos/vikunja/desktop/builds/latest?branch=main","request-id":"1wKQCgpQCRMZAgOlXPExLBKc54H","time":"2021-08-05T23:04:34Z"}
host_1  | {"level":"debug","msg":"api: read access granted","name":"desktop","namespace":"vikunja","request-id":"1wKQCgnWkufGLYNXXNa5Mi05vna","time":"2021-08-05T23:04:34Z","visibility":"public"}
host_1  | {"level":"debug","msg":"api: authentication required for write access","name":"desktop","namespace":"vikunja","request-id":"1wKQCgnWkufGLYNXXNa5Mi05vna","time":"2021-08-05T23:04:34Z"}
host_1  | {"level":"debug","msg":"api: guest access","request-id":"1wKQCgnWkufGLYNXXNa5Mi05vna","time":"2021-08-05T23:04:34Z"}
host_1  | {"fields.time":"2021-08-05T23:04:34Z","latency":934113,"level":"debug","method":"POST","msg":"","remote":"192.168.192.2:56246","request":"/api/repos/vikunja/desktop/builds/644","request-id":"1wKQCgnWkufGLYNXXNa5Mi05vna","time":"2021-08-05T23:04:34Z"}
host_1  | {"level":"debug","msg":"manager: updating step status","step.id":599,"step.name":"trigger","step.status":"failure","time":"2021-08-05T23:04:35Z"}
host_1  | {"fields.time":"2021-08-05T23:04:35Z","latency":4214631522,"level":"debug","method":"GET","msg":"","remote":"192.168.192.2:56426","request":"/api/stream/vikunja/frontend/2567/3/2","request-id":"1wKQCLTyJQcx1yVAAKm63VFOMxa","time":"2021-08-05T23:04:35Z"}
host_1  | {"level":"debug","msg":"manager: stage is complete. teardown","stage.id":204,"time":"2021-08-05T23:04:35Z"}

So it looks like the token has only read access but needs write access?

Here’s what I changed: drone-downstream/impl.go at fix/error-logging · kolaente/drone-downstream · GitHub

I’ve just re-added the token again and it seems to work now. Not sure at what point I’ve messed it up before.