Skip to content

Commit

Permalink
Merge pull request #157 from bastelfreak/register_debug
Browse files Browse the repository at this point in the history
Add extra logging when registering/unregistering
  • Loading branch information
bastelfreak authored Dec 13, 2022
2 parents f6a64a6 + fc662ea commit 0a1bb8d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/puppet_x/gitlab/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'json'
require 'net/http'
require 'uri'
require 'puppet'

module PuppetX
module Gitlab
Expand Down Expand Up @@ -44,7 +45,17 @@ def self.request(url, http_method, options, proxy, ca_file)
end
request = http_method.new(uri.request_uri, headers)
request.body = options.to_json
http.request(request)

begin
http.request(request)
rescue Net::OpenTimeout
msg = if http.proxy?
"Timeout connecting to proxy #{http.proxy_address} when trying to register/unregister gitlab runner"
else
"Timeout connecting to #{http.address} when trying to register/unregister gitlab runner"
end
raise Puppet::Error, msg
end
end

def self.validate(response)
Expand All @@ -55,11 +66,13 @@ def self.validate(response)
module Runner
def self.register(host, options, proxy = nil, ca_file = nil)
url = "#{host}/api/v4/runners"
Puppet.info "Registering gitlab runner with #{host}"
PuppetX::Gitlab::APIClient.post(url, options, proxy, ca_file)
end

def self.unregister(host, options, proxy = nil, ca_file = nil)
url = "#{host}/api/v4/runners"
Puppet.info "Unregistering gitlab runner with #{host}"
PuppetX::Gitlab::APIClient.delete(url, options, proxy, ca_file)
end
end
Expand Down

0 comments on commit 0a1bb8d

Please sign in to comment.