Trouble in Authentication to Bitbucket in version 0.9.0-alpha.4

Hey All,

We are trialing Drone for our CI/CD platform ( have been using drone 0.8.7 without any issues so far),now we are looking at using drone for windows containers deployments. So, for POC, I have been trying to get 0.9.0-alpah.4. having some issues with getting repository loaded. I have given as much info as possible. Please let me know if you need any more.

Drone Version: 0.9.0-alpha.4

Running Environment:

SSL offloading is done at ELB in AWS and forwards traffic to Drone Server running in k8s

ELB listens on 443

Server listens on port 80

Environment Variable:

DRONE_LOGS_DEBUG: "true"
DRONE_DATABASE_DRIVER: "postgres"
DRONE_DATABASE_DATASOURCE: "xxxxx"

DRONE_BITBUCKET_CLIENT_ID: "XXXXX"
DRONE_BITBUCKET_CLIENT_SECRET: "YYYYY" 
DRONE_RUNNER_CAPACITY: 2
DRONE_SERVER_PROTO: "https"
DRONE_SERVER_HOST: "drone.mycompany.com"
DRONE_RPC_SERVER: "https://drone.mycompany.com"
DRONE_USER_FILTER: "mycompany_org"
DRONE_REPOSITORY_FILTER: "mycompany_org"
#DRONE_TLS_AUTOCERT: true
DRONE_PROVIDER: "bitbucket"
DRONE_OPEN: "true"
DRONE_ORGS: "mycompany_org"
DRONE_ADMIN: "myname"

Bitbucket OAUTH redirect url: https://drone.mycompany.com/login

Server Logs:

{"level":"debug","ip":"x.x.x.x","path":"/login?state=6e661e92759805f5&code=Kn3T34SJTmJd6mPcjF","method":"GET","request_id":"bfh3daofl4vcj4d2ujrg","login":"my_user","time":"2018-11-07T00:49:47Z","message":"attempting authentication"}

{"level":"error","ip":"x.x.x.x","path":"/login?state=6e661e92759805f5&code=Kn3T34SJTmJd6mPcjF","method":"GET","request_id":"bfh3daofl4vcj4d2ujrg","login":"my_user","error":"pq: column \"user_machine\" does not exist","time":"2018-11-07T00:49:47Z","message":"cannot select user"}

{"level":"debug","ip":"x.x.x.x","path":"/api/user","method":"GET","request_id":"bfh3daofl4vcj4d2uju0","time":"2018-11-07T00:49:47Z","message":"authentication required"}

{"level":"debug","ip":"x.x.x.x","path":"/api/user","method":"GET","request_id":"bfh3daofl4vcj4d2uju0","time":"2018-11-07T00:49:47Z","message":"guest access"}

{"level":"debug","ip":"x.x.x.x","path":"/api/stream","method":"GET","request_id":"bfh3daofl4vcj4d2ujug","time":"2018-11-07T00:49:47Z","message":"event stream opened"}

{"level":"debug","ip":"x.x.x.x","path":"/api/repos/login/error/builds","method":"GET","request_id":"bfh3daofl4vcj4d2ujv0","error":"pq: column \"repo_uid\" does not exist","repository":"login/error","time":"2018-11-07T00:49:47Z","message":"repository not found"}

{"level":"debug","ip":"x.x.x.x","path":"/api/repos/login/error/builds","method":"GET","request_id":"bfh3daofl4vcj4d2ujv0","time":"2018-11-07T00:49:47Z","message":"guest access"}

{"level":"debug","ip":"x.x.x.x","path":"/api/repos/login/error","method":"GET","request_id":"bfh3daofl4vcj4d2ujvg","error":"pq: column \"repo_uid\" does not exist","repository":"login/error","time":"2018-11-07T00:49:47Z","message":"repository not found"}

{"level":"debug","ip":"x.x.x.x","path":"/api/repos/login/error","method":"GET","request_id":"bfh3daofl4vcj4d2ujvg","time":"2018-11-07T00:49:47Z","message":"guest access"}

{"level":"debug","ip":"x.x.x.x","path":"/api/user","method":"GET","request_id":"bfh3de8fl4vcj4d2uk20","time":"2018-11-07T00:50:01Z","message":"authentication required"}

{"level":"debug","ip":"x.x.x.x","path":"/api/user","method":"GET","request_id":"bfh3de8fl4vcj4d2uk20","time":"2018-11-07T00:50:01Z","message":"guest access"}

{"level":"debug","ip":"x.x.x.x","path":"/api/stream","method":"GET","request_id":"bfh3de8fl4vcj4d2uk2g","time":"2018-11-07T00:50:01Z","message":"event stream opened"}

{"level":"debug","ip":"x.x.x.x","path":"/api/repos/login/error","method":"GET","request_id":"bfh3de8fl4vcj4d2uk30","error":"pq: column \"repo_uid\" does not exist","repository":"login/error","time":"2018-11-07T00:50:01Z","message":"repository not found"}

{"level":"debug","ip":"x.x.x.x","path":"/api/repos/login/error","method":"GET","request_id":"bfh3de8fl4vcj4d2uk30","time":"2018-11-07T00:50:01Z","message":"guest access"}

{"level":"debug","ip":"x.x.x.x","path":"/api/repos/login/error/builds","method":"GET","request_id":"bfh3de8fl4vcj4d2uk3g","error":"pq: column \"repo_uid\" does not exist","repository":"login/error","time":"2018-11-07T00:50:01Z","message":"repository not found"}

Bitbucket client id and secrets works on drone version 0.8.7 and deployments are going through

Thanks in Advance

I see database errors indicating missing columns. Did you try to upgrade an existing instance or database? This is not currently possible without a migration script (which I have yet to create). So for a POC you should install from scratch, with an empty database.

Hey Brad,

Thanks for the pointer. I have delete and recreated brand new cluster with new database. Now Drone server is running but when I try to build, I get

Initialized empty Git repository in /drone/src/.git/
+ git fetch origin +refs/heads/master:
fatal: unable to access 'https://bitbucket.org/my_org/repo.git/': Could not resolve host: bitbucket.org

on DIND container - I did

docker run --network=foo -t -i alpine ping -c 1 bitbucket.org
PING bitbucket.org (18.205.93.1): 56 data bytes

seems to be resolving fine

On DIND I could find

time="2018-11-07T04:27:59.695855963Z" level=warning msg="Running modprobe bridge br_netfilter failed with message: ip: can't find device 'bridge'\nbridge                118784  1 br_netfilter\nstp                    16384  1 bridge\nllc                    16384  2 bridge,stp\nip: can't find device 'br_netfilter'\nbr_netfilter           24576  0 \nbridge                118784  1 br_netfilter\nmodprobe: can't change directory to '/lib/modules': No such file or directory\n, error: exit status 1"
time="2018-11-07T04:27:59.699152427Z" level=warning msg="Running modprobe nf_nat failed with message: `ip: can't find device 'nf_nat'\nnf_nat_ipv6            16384  1 ip6table_nat\nnf_nat_masquerade_ipv4    16384  1 ipt_MASQUERADE\nnf_nat_ipv4            16384  1 iptable_nat\nnf_nat                 24576  4 nf_nat_ipv6,xt_nat,nf_nat_masquerade_ipv4,nf_nat_ipv4\nnf_conntrack          114688  9 nf_conntrack_ipv6,nf_nat_ipv6,nf_conntrack_netlink,ip_vs,nf_nat_masquerade_ipv4,nf_conntrack_ipv4,nf_nat_ipv4,xt_conntrack,nf_nat\nmodprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1"
time="2018-11-07T04:27:59.702456667Z" level=warning msg="Running modprobe xt_conntrack failed with message: `ip: can't find device 'xt_conntrack'\nxt_conntrack           16384 18 \nx_tables               36864 17 ip6_tables,xt_multiport,xt_set,iptable_mangle,iptable_raw,xt_statistic,xt_nat,xt_recent,ipt_REJECT,xt_tcpudp,xt_comment,xt_mark,ipt_MASQUERADE,xt_addrtype,iptable_filter,ip_tables,xt_conntrack\nnf_conntrack          114688  9 nf_conntrack_ipv6,nf_nat_ipv6,nf_conntrack_netlink,ip_vs,nf_nat_masquerade_ipv4,nf_conntrack_ipv4,nf_nat_ipv4,xt_conntrack,nf_nat\nmodprobe: can't change directory to '/lib/modules': No such file or directory`, error: exit status 1"
time="2018-11-07T04:27:59.759048274Z" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address"
time="2018-11-07T04:27:59.796482008Z" level=info msg="Loading containers: done."
time="2018-11-07T04:27:59.812725568Z" level=info msg="Docker daemon" commit=0ffa825 graphdriver(s)=overlay2 version=18.06.0-ce
time="2018-11-07T04:27:59.812853982Z" level=info msg="Daemon has completed initialization"
time="2018-11-07T04:27:59.825307834Z" level=warning msg="Could not register builder git source: failed to find git binary: exec: \"git\": executable file not found in $PATH"
time="2018-11-07T04:27:59.829821858Z" level=info msg="API listen on [::]:2375"
time="2018-11-07T04:27:59.829921996Z" level=info msg="API listen on /var/run/docker.sock"

On Agent I could see

{"level":"info","server":"http://localhost:8080","threads":1,"time":"2018-11-07T04:27:59Z","message":"starting the build runner"}

Not sure from where “http://localhost:8080” coming from

Corresponding server logs

{"level":"debug","step_status":"failure","step_name":"clone","step_id":29,"time":"2018-11-07T04:10:37Z","message":"updating step status"}
{"level":"error","error":"clone : exit code 128","repo":"my_org/my_repo","build":16,"stage":1,"time":"2018-11-07T04:10:37Z","message":"execution failed"}
{"level":"debug","stage_id":16,"time":"2018-11-07T04:10:37Z","message":"stage is complete. teardown"}