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(community.docker.docker_volume): labels can be none #702

Merged
merged 4 commits into from
Nov 12, 2023

Conversation

chaoslion
Copy link
Contributor

@chaoslion chaoslion commented Nov 11, 2023

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
}

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"
    }
]
Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! Can you please add a changelog fragment? Thanks!

plugins/modules/docker_volume.py Outdated Show resolved Hide resolved
@chaoslion
Copy link
Contributor Author

Updated the PR with some documentation and the missing changelog fragment.

@felixfontein felixfontein merged commit 4c220c4 into ansible-collections:main Nov 12, 2023
97 checks passed
Copy link
Contributor

patchback bot commented Nov 12, 2023

Backport to stable-2: 💚 backport PR created

✅ Backport PR branch: patchback/backports/stable-2/4c220c4d7405a9f89dde0ecc5e7db6fab7209626/pr-702

Backported as #704

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Nov 12, 2023
* 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
Copy link
Collaborator

@chaoslion thanks a lot for fixing this!

felixfontein pushed a commit that referenced this pull request Nov 12, 2023
* 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 pushed a commit that referenced this pull request Nov 12, 2023
* 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)

Co-authored-by: Alexander Jähnel <[email protected]>
@chaoslion chaoslion deleted the patch-1 branch November 12, 2023 19:37
@chaoslion
Copy link
Contributor Author

Sure thing :)

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