-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
[docker_container] Failing on non-string env values #49843
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is a good idea. We have no clue what exactly the user wanted (yes
/true
/True
/..., no
/false
/False
/...), and we currently simply select a random variant (true
/false
). It's probably better to fail and advise the user to quote this correctly. The official values accepted by YAML as booleans are y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF
(see here).
The clean_dict_booleans_for_docker_api
function has so far been used in situations where certain boolean strings are more likely (namely true
and false
). But here, any of these variants is equally likely.
Instead of making a random choice, we should fail when we find a non-string (the same problem is true if the user writes 1.00
, which will end up as 1.0
by being converted to a float
first -- depending on the context this is ok, or absolutely not ok).
env
of Python booleans
@felixfontein Alright, I've redone it all to error out on non-string values. I've had my fair share of issues with YAML in the past, but I didn't realize that data loss was one of them. Totally with you - failure (with a helpful error message) is better than silent data loss. ready_for_review |
test/integration/targets/docker_container/tasks/tests/options.yml
Outdated
Show resolved
Hide resolved
Co-Authored-By: DBendit <David@ibendit.com>
Updated. ready_for_review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bot_status |
Componentschangelogs/fragments/49843-docker_container-wrap-env.yaml lib/ansible/modules/cloud/docker/docker_container.py test/integration/targets/docker_container/tasks/tests/options.yml Metadatawaiting_on: maintainer |
* devel: Fix yum/dnf handling of URIs that don't end in .rpm (ansible#49912) [docker_container] Failing on non-string env values (ansible#49843) [docker_volume] Checking option minimal versions (ansible#49839) Support for cache_from parameter in docker_image module (ansible#49787) Move verify up so approle and other methods work as intended.
@felixfontein I completely had! Thank you for the reminder. Still trying to get back into the swing of things post-holidays |
@DBendit no problem :) There will probably be a new 2.7 release next week, so backports should probably be there until next Monday or so. (If you don't have time, I can also create them, just tell me.) |
* [docker_container] Failing on non-string env values Fixes ansible#49802 * Clarify failure message Co-Authored-By: DBendit <David@ibendit.com> * Fixup from review
* [docker_container] Failing on non-string env values Fixes ansible#49802 * Clarify failure message Co-Authored-By: DBendit <David@ibendit.com> * Fixup from review (cherry picked from commit d62d717)
* [docker_container] Failing on non-string env values (#49843) * [docker_container] Failing on non-string env values Fixes #49802 * Clarify failure message Co-Authored-By: DBendit <David@ibendit.com> * Fixup from review (cherry picked from commit d62d717) * Turn fail into warning for 2.7 backport. * Fix test for backport The behaviour in the backport is to warn rather than error
SUMMARY
Fixes #49802
Fail the module when non-string env values are used. Avoids issues (documented by @felixfontein below) around data loss due to YAML parsing.
ISSUE TYPE
COMPONENT NAME
docker_container
ADDITIONAL INFORMATION
N/A