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

[DEPRECATION WARNING]: The 'return_code' return key is deprecated. Please use 'rc' instead. #413

Closed
erikgb opened this issue Mar 19, 2022 · 5 comments
Labels
type/question Further information is requested

Comments

@erikgb
Copy link

erikgb commented Mar 19, 2022

SUMMARY

It seems like this deprecation warning is emitted - even if all usage is migrated to rc.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

kubernetes.core.k8s_exec

ANSIBLE VERSION
ansible [core 2.12.3]
  config file = None
  configured module search path = ['/home/ansible/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/ansible/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.11 (main, Mar 18 2022, 16:45:24) [GCC 10.2.1 20210110]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
# /usr/local/lib/python3.9/site-packages/ansible_collections
Collection      Version
--------------- -------
kubernetes.core 2.3.0
CONFIGURATION
ANSIBLE_FORCE_COLOR(env: ANSIBLE_FORCE_COLOR) = True
DEFAULT_LOAD_CALLBACK_PLUGINS(env: ANSIBLE_LOAD_CALLBACK_PLUGINS) = True
DEFAULT_STDOUT_CALLBACK(env: ANSIBLE_STDOUT_CALLBACK) = yaml
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False
INTERPRETER_PYTHON(env: ANSIBLE_PYTHON_INTERPRETER) = auto
OS / ENVIRONMENT

Debian-flavoured container image from based on official python image.

STEPS TO REPRODUCE
  kubernetes.core.k8s_exec:
    pod: <pod-name>
    container: <container-name>
    command: <some command>
  register: command_status
  retries: 7
  delay: 3
  until: command_status.rc == 0
EXPECTED RESULTS

Task runs successfully, with no warnings.

ACTUAL RESULTS
[DEPRECATION WARNING]: The 'return_code' return key is deprecated. Please use 
'rc' instead. This feature will be removed from kubernetes.core in version 
4.0.0. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
@Akasurde
Copy link
Member

@erikgb Thanks for reporting this issue. Due to Ansible Core engine changes, we moved from return_code to rc. We need to provide deprecation warnings to the user as per Ansible Development Guidelines. You may want to disable this warning by using deprecation_warnings=False in ansible.cfg. Apart from that, I do not have any other solution on top of my head right now.

@tima @gravesm @abikouo What do you think about this?

Thanks.

@gravesm
Copy link
Member

gravesm commented Mar 21, 2022

We have no way to know what fields of the return value are used, or even if the return value is used at all. This is a limitation of Ansible and there's not much we can do about this. As a general rule, we issue warnings for any breaking changes for a period of time before the breaking change is made.

@gravesm gravesm added the type/question Further information is requested label Mar 21, 2022
@erikgb
Copy link
Author

erikgb commented Mar 21, 2022

Thanks @gravesm, makes sense. The wording on the deprecation message can maybe be improved a little, to not confuse the user, but I understand that the collection cannot know if/how the return values are used. Closing issue.

@erikgb erikgb closed this as completed Mar 21, 2022
@gravesm
Copy link
Member

gravesm commented Mar 21, 2022

It's a legitimate complaint. If you can think of a better way to phrase this we'd happily accept a PR.

@erikgb
Copy link
Author

erikgb commented Mar 21, 2022

Here is a suggestion, but it might need some adjustments since I am not native in English. 😅

[DEPRECATION WARNING]: The 'return_code' return key is renamed to 'rc'.
To allow users to migrate to the new name, both keys are returned for now.
Old name ('return_code') will be removed from kubernetes.core in version 4.0.0.
Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

I also found this feature idea, that could have mended this: ansible/ansible#49900.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants