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
Network options break idempotence for both container and pod #555
Comments
This information is available on containers in the output of
Though pods don't show it (their containers do). I wonder if it would not be easier to parse the I am happy to help implement a fix if I know how it should be fixed |
I encountered the same issue. The task that creates the pod looks like this:
Running the playbook with --diff shows, for the second run:
Looks like podman_network_info parses the network options incorrectly. |
I am also affected by this issue.
That very thought also occurred to me and pushed me to create the following workaround:
The whole thing is not exactly elegant, and it likely comes with many caveats, but here it is: - set_fact:
container_create_reference: |
{% set ref = container.create_args %}
{% set ccr = ["podman", "container", "run", "--name"] %}
{% set _ = ccr.append(ref.name) %}
{% if 'hostname' in ref: %}
{% set _ = ccr.append("--hostname") %}
{% set _ = ccr.append(ref.hostname) %}
{% endif %}
{% for key in ('network', 'publish'): %}
{% for value in ref.get(key, []): %}
{% set _ = ccr.append("--" + key) %}
{% set _ = ccr.append(value) %}
{% endfor %}
{% endfor %}
{% for key, value in ref.get("env", {}).items(): %}
{% set _ = ccr.append("--env") %}
{% set _ = ccr.append(key + "=" + value) %}
{% endfor %}
{% if 'restart_policy' in ref: %}
{% set _ = ccr.append("--restart=" + ref.restart_policy) %}
{% endif %}
{% for value in ref.get("volumes", []): %}
{% set _ = ccr.append("--volume") %}
{% set _ = ccr.append(value) %}
{% endfor %}
{% set _ = ccr.append("--detach=True") %}
{% set _ = ccr.append(ref.image) %}
{{ ccr }}
- block:
- shell: |-
podman container inspect '{{container.create_args.name}}' | jq -c '.[0].Config.CreateCommand'
changed_when: False
register: create_command
rescue:
- set_fact:
create_command:
stdout: '[]'
- when:
- 'create_command.stdout|from_json != container_create_reference'
containers.podman.podman_container:
state: started
args: '{{ container.create_args }}' |
@BenjaminSchubert @kristvanbesien @xavierog should be fixed for containers by #745 |
I have not tested yet, but a brief look at https://github.com/containers/ansible-podman-collections/pull/745/files reflects only one item that might be related with this issue: the addition of the @sshnaidm could you (briefly) clarify what #745 brings to this issue? |
Related: containers#555 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
I run: tasks:
- name: Test
containers.testpodman.podman_network:
name: test
- name: Test
containers.testpodman.podman_container:
name: test
network:
- "test:alias=testing"
image: docker.io/containous/whoami
- name: Test
containers.testpodman.podman_network:
name: test
- name: Test
containers.testpodman.podman_container:
name: test
network:
- "test:alias=testing"
image: docker.io/containous/whoami and seems ok:
I completely gave up on networking calculation from inspection, it changes drastically from version to version, and just look at |
Related: containers#555 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This new commit looks definitely better -- I'll give it a try (likely on Friday). |
Related: #555 Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
@sshnaidm It works! After git-cloning your latest commits, I removed my 58-line long |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
When creating a pod or a container, and providing network options, idempotence breaks and pods/containers always get restarted
Steps to reproduce the issue:
ansible-playbook playbook.yml
Describe the results you received:
Notice that the second time, the container changed state, it should not have
Describe the results you expected:
Nothing changed, the container should not have changed
Additional information you deem important (e.g. issue happens only occasionally):
This happens also for pods
Version of the
containers.podman
collection:Output of
ansible --version
:Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):The text was updated successfully, but these errors were encountered: