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

Fix GetCurrentContainerID() and corresponding test #345

Merged
merged 2 commits into from
Apr 12, 2021
Merged

Fix GetCurrentContainerID() and corresponding test #345

merged 2 commits into from
Apr 12, 2021

Conversation

buchdag
Copy link
Member

@buchdag buchdag commented Apr 9, 2021

This PR adds a fall back container ID matching function to the hostname based container ID matching function introduced in #336, in order to fix the regression with containers using a custom hostname.

The GetCurrentContainerID() function will try the hostname based container ID matching function on all files before using the fallback function in case it didn't get a valid container ID. Its signature has been altered to allow testing it with real files reads instead of testing only the matching functions. This slightly increased test coverage from 62.1 % to 64.2 %.

/proc/1/cpuset has been added as a third alternative to /proc/self/cgroup and /proc/self/mountinfo (it's one of the container ID source we use on nginx-proxy/acme-companion).

matchDockerCurrentContainerID() has been renamed to matchContainerIDWithHostname() for clarity. Claiming it matches the current container ID feels a bit untrue, as it just match a 64 characters hex starting with 12 characters HOSTNAME.

buchdag added 2 commits April 10, 2021 00:44
The hostname method can fail if the host name name has been customised.
The fallback method match the first 64 characters hex string found.
Perform the tests with real file reads instead
of just testing the matching functions
@buchdag
Copy link
Member Author

buchdag commented Apr 9, 2021

Forgot that: the matchECSCurrentContainerID() function has been removed entirely as ECS changed its cgroup format a long time ago and it wasn't matching anything anymore.

@buchdag
Copy link
Member Author

buchdag commented Apr 12, 2021

@jwilder Is there anything blocking the merge ?

@jwilder jwilder merged commit c830c3f into nginx-proxy:master Apr 12, 2021
@jwilder
Copy link
Collaborator

jwilder commented Apr 12, 2021

Nope. I hit the wrong approve option.

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.

2 participants