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

[PR #702/4c220c4d backport][stable-2] fix(community.docker.docker_volume): labels can be none #704

Conversation

patchback[bot]
Copy link
Contributor

@patchback patchback bot commented Nov 12, 2023

This is a backport of PR #702 as merged into main (4c220c4).

Catch case where volume labels can be None (it`s the default when creating a volume).

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

community.docker.docker_volume

ADDITIONAL INFORMATION
(ansi-debug-py3.11) ~/test # docker volume create foo
foo
(ansi-debug-py3.11) ~/test # docker volume inspect foo
[
    {
        "CreatedAt": "2023-11-12T08:06:39Z",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/foo/_data",
        "Name": "foo",
        "Options": null,
        "Scope": "local"
    }
]
(ansi-debug-py3.11) ~/test # ansible localhost -mcommunity.docker.docker_volume  -a'{"volume_name":"foo","recreate":"options-changed","state":"present","label
s":{"merry":"christmas"}}'
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no
 attribute 'get'
localhost | FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1699776709.2802129-75992-15114258512832
6/AnsiballZ_docker_volume.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1699776709.2802129-
75992-151142585128326/AnsiballZ_docker_volume.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAM
S)\n  File \"/root/.ansible/tmp/ansible-tmp-1699776709.2802129-75992-151142585128326/AnsiballZ_docker_volume.py\", line 47, in invoke_mod
ule\n    runpy.run_module(mod_name='ansible_collections.community.docker.plugins.modules.docker_volume', init_globals=dict(_module_fqn='a
nsible_collections.community.docker.plugins.modules.docker_volume', _modlib_path=modlib_path),\n  File \"<frozen runpy>\", line 226, in r
un_module\n  File \"<frozen runpy>\", line 98, in _run_module_code\n  File \"<frozen runpy>\", line 88, in _run_code\n  File \"/tmp/ansib
le_community.docker.docker_volume_payload_bppcq2tj/ansible_community.docker.docker_volume_payload.zip/ansible_collections/community/docke
r/plugins/modules/docker_volume.py\", line 348, in <module>\n  File \"/tmp/ansible_community.docker.docker_volume_payload_bppcq2tj/ansibl
e_community.docker.docker_volume_payload.zip/ansible_collections/community/docker/plugins/modules/docker_volume.py\", line 331, in main\n
  File \"/tmp/ansible_community.docker.docker_volume_payload_bppcq2tj/ansible_community.docker.docker_volume_payload.zip/ansible_collecti
ons/community/docker/plugins/modules/docker_volume.py\", line 168, in __init__\n  File \"/tmp/ansible_community.docker.docker_volume_payl
oad_bppcq2tj/ansible_community.docker.docker_volume_payload.zip/ansible_collections/community/docker/plugins/modules/docker_volume.py\", 
line 281, in present\n  File \"/tmp/ansible_community.docker.docker_volume_payload_bppcq2tj/ansible_community.docker.docker_volume_payloa
d.zip/ansible_collections/community/docker/plugins/modules/docker_volume.py\", line 232, in has_different_config\nAttributeError: 'NoneTy
pe' object has no attribute 'get'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

* fix(community.docker.docker_volume): labels can be none

catch case where volume labels can are done (default) eg:

$ docker volume inspect foo
[
    {
        "CreatedAt": "2023-11-11T12:55:23+01:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/foo/_data",
        "Name": "foo",
        "Options": {},
        "Scope": "local"
    }
]

* Update plugins/modules/docker_volume.py

Co-authored-by: Felix Fontein <[email protected]>

* add(community.docker.docker_volume): changelog fragment

* Update changelogs/fragments/702-docker-volume-label-none.yaml

Co-authored-by: Felix Fontein <[email protected]>

---------

Co-authored-by: Felix Fontein <[email protected]>
(cherry picked from commit 4c220c4)
@felixfontein felixfontein force-pushed the patchback/backports/stable-2/4c220c4d7405a9f89dde0ecc5e7db6fab7209626/pr-702 branch from f16bd66 to 2188812 Compare November 12, 2023 10:26
@felixfontein felixfontein merged commit 35de5b3 into stable-2 Nov 12, 2023
75 checks passed
@felixfontein felixfontein deleted the patchback/backports/stable-2/4c220c4d7405a9f89dde0ecc5e7db6fab7209626/pr-702 branch November 12, 2023 11:03
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