Skip to content
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

Merged

Conversation

shanepelletier
Copy link
Contributor

The docker registry can be configured to provide prometheus metrics, but
the charm currently does not have the option to enable this option. This
change adds the ability to enable this option, using the
prometheus-metrics and debug-port charm configuration options. There
is no way to only enable prometheus metrics, so enabling the
configuration option also enables other debug URLs such as /debug/vars.
It is expected that the other debugging URLs will be less relevant to
users of this charm, and so prometheus-metrics was chosen as the name
of the configuration option.

This change also adds a small bit of fanciness by updating the ports
displayed in the output of juju status dynamically based on their
values and the value of the prometheus-metrics option.

Fixes https://bugs.launchpad.net/layer-docker-registry/+bug/2034475

The test suite currently uses an f-string, which are only supported
beginning with Python 3.6. On some systems, tox attempts to run the
tests using Python 3.5, causing a test failure from invalid syntax. This
change fixes the issue by ensuring that tox always uses Python 3.6.
This is required for building and deploying the charm on newer versions
of charmcraft and/or Ubuntu.
The docker registry can be configured to provide prometheus metrics, but
the charm currently does not have the option to enable this option. This
change adds the ability to enable this option, using the
`prometheus-metrics` and `debug-port` charm configuration options. There
is no way to only enable prometheus metrics, so enabling the
configuration option also enables other debug URLs such as /debug/vars.
It is expected that the other debugging URLs will be less relevant to
users of this charm, and so `prometheus-metrics` was chosen as the name
of the configuration option.

This change also adds a small bit of fanciness by updating the ports
displayed in the output of `juju status` dynamically based on their
values and the value of the `prometheus-metrics` option.

Fixes https://bugs.launchpad.net/layer-docker-registry/+bug/2034475
The unit tests for this project use GitHub Actions, which install a
single version of Python during execution. The previous change to use
python 3.6 for tests does not work in such an environment, and so this
commit undos that one.
Copy link
Contributor

@addyess addyess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty reasonable except for the dead link in the comments and the random python packages included

Comment on lines 74 to 75
# debug https://docs.docker.com/registry/configuration/#debug
# The debug server always listens on port 5001, with debug-port used
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

# 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']
Copy link
Contributor

Choose a reason for hiding this comment

The 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 5001 from above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, I based this off the registry-port config option.

wheelhouse.txt Outdated
Comment on lines 1 to 2
calver
hatchling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, why are these packages included? Neither are used.

Suggested change
calver
hatchling

Copy link
Contributor

@addyess addyess Oct 30, 2023

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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!

Copy link
Contributor

@addyess addyess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve, but since i can't seem to merge it

Copy link
Contributor

@kwmonroe kwmonroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!!

@addyess addyess merged commit 5498ed5 into canonical:master Oct 31, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants