jimzucker / github-webhooks

Framework and Docker Container for running Webhooks on your GitHub repo.
MIT License
0 stars 1 forks source link

Timing issue Get README.md sometimes fails #5

Open jimzucker opened 4 years ago

jimzucker commented 4 years ago

Usually doing a Get to verify README.md exists works but periodically it fails, but UI shows README.md. This looks like a timing issue.

➜  git-webhooks git:(master) ✗ docker logs -f ae0de7332748c866257fa2fd5002b574a66f1696e4b8a71609ec722d08a9d6f2
[2020-02-10 05:40:53] INFO  WEBrick 1.4.2
[2020-02-10 05:40:53] INFO  ruby 2.6.5 (2019-10-01) [x86_64-linux]
== Sinatra (v2.0.8.1) has taken the stage on 4567 for development with backup from WEBrick
[2020-02-10 05:40:53] INFO  WEBrick::HTTPServer#start: pid=1 port=4567
2020-02-10 05:41:05 - SystemExit - exit:
    ./github_webhooks.rb:98:in `exit'
    ./github_webhooks.rb:98:in `exec_request'
    ./github_webhooks.rb:134:in `repository_default'
    ./github_webhooks.rb:164:in `repository_webhook'
    ./github_webhooks.rb:190:in `block in <main>'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1636:in `call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1636:in `block in compile!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:987:in `block (3 levels) in route!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1006:in `route_eval'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:987:in `block (2 levels) in route!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1035:in `block in process_route'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1033:in `catch'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1033:in `process_route'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:985:in `block in route!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:984:in `each'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:984:in `route!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1098:in `block in dispatch!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1072:in `block in invoke'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1072:in `catch'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1072:in `invoke'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1095:in `dispatch!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:919:in `block in call!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1072:in `block in invoke'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1072:in `catch'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1072:in `invoke'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:919:in `call!'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:908:in `call'
    /usr/local/bundle/gems/rack-protection-2.0.8.1/lib/rack/protection/xss_header.rb:18:in `call'
    /usr/local/bundle/gems/rack-protection-2.0.8.1/lib/rack/protection/path_traversal.rb:16:in `call'
    /usr/local/bundle/gems/rack-protection-2.0.8.1/lib/rack/protection/json_csrf.rb:26:in `call'
    /usr/local/bundle/gems/rack-protection-2.0.8.1/lib/rack/protection/base.rb:50:in `call'
    /usr/local/bundle/gems/rack-protection-2.0.8.1/lib/rack/protection/base.rb:50:in `call'
    /usr/local/bundle/gems/rack-protection-2.0.8.1/lib/rack/protection/frame_options.rb:31:in `call'
    /usr/local/bundle/gems/rack-2.1.2/lib/rack/logger.rb:17:in `call'
    /usr/local/bundle/gems/rack-2.1.2/lib/rack/common_logger.rb:35:in `call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:231:in `call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:224:in `call'
    /usr/local/bundle/gems/rack-2.1.2/lib/rack/head.rb:14:in `call'
    /usr/local/bundle/gems/rack-2.1.2/lib/rack/method_override.rb:24:in `call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/show_exceptions.rb:22:in `call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:194:in `call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1951:in `call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1503:in `block in call'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1730:in `synchronize'
    /usr/local/bundle/gems/sinatra-2.0.8.1/lib/sinatra/base.rb:1503:in `call'
    /usr/local/bundle/gems/rack-2.1.2/lib/rack/handler/webrick.rb:88:in `service'
    /usr/local/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
    /usr/local/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
    /usr/local/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'
172.17.0.1 - - [10/Feb/2020:05:41:04 UTC] "POST /github_webhook HTTP/1.1" 500 139751
- -> /github_webhook
192.30.252.90 - - [10/Feb/2020:05:41:05 +0000] "POST /github_webhook HTTP/1.1" 200 - 0.0035
172.17.0.1 - - [10/Feb/2020:05:41:05 UTC] "POST /github_webhook HTTP/1.1" 200 0
- -> /github_webhook
192.30.252.98 - - [10/Feb/2020:05:41:06 +0000] "POST /github_webhook HTTP/1.1" 200 - 0.0007
172.17.0.1 - - [10/Feb/2020:05:41:06 UTC] "POST /github_webhook HTTP/1.1" 200 0
jimzucker commented 4 years ago

Example of successful run, you can see get returned successfully.

[INFO] Processing object= repository, action= created on repo= StrategicDevOps/docker1 by jimzucker
[INFO] Getting Authorized User:  method= Get, url= https://api.github.com/user
[INFO] Checking existance of README.md:  method= Get, url= https://api.github.com/repos/StrategicDevOps/docker1/contents/README.md
[INFO] Ignoring object = before, action =
140.82.115.250 - - [10/Feb/2020:05:45:56 +0000] "POST /github_webhook HTTP/1.1" 200 - 0.0008
172.17.0.1 - - [10/Feb/2020:05:45:56 UTC] "POST /github_webhook HTTP/1.1" 200 0
[INFO] Processing object= repository, action= created on repo= StrategicDevOps/docker1 by jimzucker
[INFO] Getting Authorized User:  method= Get, url= https://api.github.com/user
[INFO] Checking existance of README.md:  method= Get, url= https://api.github.com/repos/StrategicDevOps/docker1/contents/README.md
[INFO] Ignoring object = before, action =
140.82.115.250 - - [10/Feb/2020:05:45:56 +0000] "POST /github_webhook HTTP/1.1" 200 - 0.0008
172.17.0.1 - - [10/Feb/2020:05:45:56 UTC] "POST /github_webhook HTTP/1.1" 200 0
- -> /github_webhook
[INFO] Defaulting Repository Settings:  method= Patch, url= https://api.github.com/repos/StrategicDevOps/docker1
[INFO] Ignoring object = ref_type, action =
192.30.252.99 - - [10/Feb/2020:05:45:56 +0000] "POST /github_webhook HTTP/1.1" 200 - 0.0007
172.17.0.1 - - [10/Feb/2020:05:45:56 UTC] "POST /github_webhook HTTP/1.1" 200 0
- -> /github_webhook
[INFO] Protecting master branch:  method= Put, url= https://api.github.com/repos/StrategicDevOps/docker1/branches/master/protection
[INFO] Defaulting Repository Settings:  method= Post, url= https://api.github.com/repos/StrategicDevOps/docker1/issues
192.30.252.97 - - [10/Feb/2020:05:45:57 +0000] "POST /github_webhook HTTP/1.1" 200 - 3.2338
172.17.0.1 - - [10/Feb/2020:05:45:54 UTC] "POST /github_webhook HTTP/1.1" 200 383
- -> /github_webhook
[INFO] Ignoring object = issue, action = opened
140.82.115.249 - - [10/Feb/2020:05:45:58 +0000] "POST /github_webhook HTTP/1.1" 200 - 0.0036
172.17.0.1 - - [10/Feb/2020:05:45:58 UTC] "POST /github_webhook HTTP/1.1" 200 0
- -> /github_webhook
[INFO] Ignoring object = repository, action = deleted
140.82.115.251 - - [10/Feb/2020:05:46:33 +0000] "POST /github_webhook HTTP/1.1" 200 - 0.0008
172.17.0.1 - - [10/Feb/2020:05:46:33 UTC] "POST /github_webhook HTTP/1.1" 200 0
- -> /github_webhook
== Sinatra has ended his set (crowd applauds)
jimzucker commented 4 years ago

Fixed temporarily by added a 30 second pause, will research to see if there is a better fix.