Repository navigation
Fix docker_container.running not replacing the container when an explicitly set hostname is added, changed or removed - #14
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #14 +/- ##
==========================================
+ Coverage 42.88% 43.22% +0.34%
==========================================
Files 26 27 +1
Lines 6564 6665 +101
Branches 1122 1125 +3
==========================================
+ Hits 2815 2881 +66
- Misses 3494 3529 +35
Partials 255 255
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Is this a cherry-pick from Salt, or new commits? I saw you mentioned missing commits in one of the issues, but neither 3006.x [0] nor 3007.x has these changes. [0] https://github.com/saltstack/salt/blob/3006.x/salt/states/docker_container.py#L1859 |
|
These are new commits. They are from my fork where I was collecting fixes I made while this repo was not populated with docker code. Now that it is, I decided to propose those fixes upstream (i.e., here). The ones I listed as missing commits I didn't make PRs for. I can, but I thought that it is probably easier for you to just do those. |
|
Than you for the PR. I was thinking about this use case So you first let dockermod to set a hostname based on the container ID, later you actively rename it for some task and then you want to have back the default behaviour. I think in |
e46e3ed to
6c19488
Compare
|
You are right. My fix fixed on part, but then opened another issue. I think it is all now addressed. |
m-czernek
left a comment
There was a problem hiding this comment.
Requesting a bug fix here. If you want to play with the test case, the following SLS hits the issue on 2nd and subsequent runs, where the side_running container gets recreated:
base_running:
docker_container.running:
- name: base-01
- image: alpine:latest
- command: sleep 3600
- shutdown_timeout: 1
side_running:
docker_container.running:
- name: side-01
- image: alpine:latest
- command: sleep 3600
- network_mode: container:base-01
- shutdown_timeout: 1
- require:
- docker_container: base_running…name when explicitly set
6c19488 to
3015583
Compare
|
Thanks, good catch! I applied your suggestion, reading network_mode from kwargs (there is no network_mode variable in running()), and added a unit test and a functional test based on your SLS. I added one more fix I noticed, the same for I also GPG signed commits now. |
When the user does not explicitly set a hostname, Docker auto-assigns one based on the container's ID, so the existing and temporary containers always disagree on Hostname even when nothing has actually changed. In that case we must ignore Hostname to avoid spurious recreations. When the user has set a hostname, we need to compare it so that changing the "hostname" argument triggers a container replacement.
Merge requirements satisfied?
[NOTICE] Bug fixes or new features require tests.
Commits signed with GPG?
No