-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow enabling prometheus metrics #67
Changes from 4 commits
b01ed03
f192a5c
486403f
39229d7
0a9d507
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,15 @@ def configure_registry(): | |
if os.path.isfile(tls_ca): | ||
http['tls']['clientcas'] = [tls_ca] | ||
docker_volumes[tls_ca] = '/etc/docker/registry/ca.crt' | ||
|
||
# debug https://docs.docker.com/registry/configuration/#debug | ||
# The debug server always listens on port 5001, with debug-port used | ||
# for mapping from the host network only. | ||
if charm_config.get('prometheus-metrics'): | ||
http['debug'] = { | ||
'addr': '0.0.0.0:5001', | ||
'prometheus': {'enabled': charm_config['prometheus-metrics']}, | ||
} | ||
registry_config['http'] = http | ||
|
||
# log (https://docs.docker.com/registry/configuration/#log) | ||
|
@@ -418,6 +427,7 @@ def start_registry(name=None, run_args=None): | |
charm_config = hookenv.config() | ||
image = charm_config.get('registry-image') | ||
port = charm_config.get('registry-port') | ||
debug_port = charm_config.get('debug-port') | ||
if not name: | ||
name = charm_config.get('registry-name') | ||
|
||
|
@@ -431,10 +441,11 @@ def start_registry(name=None, run_args=None): | |
level=hookenv.ERROR) | ||
raise | ||
else: | ||
# NB: config determines the port, but the container always listens to 5000 | ||
# NB: config determines the port, but the container always listens to 5000 and | ||
# 5001 | ||
# https://docs.docker.com/registry/deploying/#customize-the-published-port | ||
cmd = ['docker', 'run', '-d', '-p', '{}:5000'.format(port), | ||
'--restart', 'unless-stopped'] | ||
'-p', '{}:5001'.format(debug_port), '--restart', 'unless-stopped'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, okay so we're port-forwarding the debug-port into the hard-coded port There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, I based this off the |
||
# HTTP/HTTPS proxy configuration | ||
http_proxy = charm_config.get('registry-http-proxy') | ||
if http_proxy: | ||
|
@@ -456,8 +467,18 @@ def start_registry(name=None, run_args=None): | |
level=hookenv.ERROR) | ||
raise | ||
|
||
previous_registry_port = charm_config.previous('registry-port') | ||
previous_debug_port = charm_config.previous('debug-port') | ||
|
||
if previous_registry_port: | ||
hookenv.close_port(previous_registry_port) | ||
hookenv.open_port(port) | ||
|
||
if previous_debug_port: | ||
hookenv.close_port(previous_debug_port) | ||
if charm_config.get('prometheus-metrics'): | ||
hookenv.open_port(debug_port) | ||
|
||
|
||
def stop_registry(name=None, remove=True): | ||
'''Stop a registry container. | ||
|
@@ -470,6 +491,7 @@ def stop_registry(name=None, remove=True): | |
''' | ||
charm_config = hookenv.config() | ||
port = charm_config.get('registry-port') | ||
debug_port = charm_config.get('debug-port') | ||
if not name: | ||
name = charm_config.get('registry-name') | ||
|
||
|
@@ -494,6 +516,7 @@ def stop_registry(name=None, remove=True): | |
raise | ||
|
||
hookenv.close_port(port) | ||
hookenv.close_port(debug_port) | ||
|
||
|
||
def write_tls(ca, cert, key): | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,2 @@ | ||||||
calver | ||||||
hatchling | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, why are these packages included? Neither are used.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I resolved an issue in the layer-docker which was requiring these packages. Please try without them @shanepelletier There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I was pretty sure I needed them for something. I've removed them now, thanks for fixing the root cause! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this link is a 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fun, looks like the registry was recently donated to the CNCF (as noted at https://docs.docker.com/registry/). Would you like all the URLs updated in this PR, or in a separate one? I've changed this URL specifically since it's directly related to the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah... just the one is fine.