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

[ansible] Fix docker shell plugin #1253

Merged
merged 4 commits into from
Dec 4, 2019

Conversation

msosyak
Copy link
Contributor

@msosyak msosyak commented Dec 2, 2019

Description of PR

Update docker shell plugin to be compatible with ansible 2.8.7
Summary:
Fixes #1243

Type of change

  • Bug fix
  • [] Testbed and Framework(new/improvement)
  • [] Test case(new/improvement)

Approach

How did you do it?

Add a description of the plugin. https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.4.html#configuration
Fixed base method call

How did you verify/test it?

Run few testcases

Any platform specific information?

N/A

Supported testbed topology if it's a new test case?

N/A

Documentation

@msosyak
Copy link
Contributor Author

msosyak commented Dec 2, 2019

@lguohan @qiluo-msft Please review. This is the fix for #1243

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comment

def build_module_command(self, env_string, shebang, cmd, arg_path=None, rm_tmp=None):
def remove(self, path, recurse=False):
if not self.container:
self.container = self.get_option('ansible_python_interpreter').split()[3]
Copy link
Contributor

@qiluo-msft qiluo-msft Dec 3, 2019

Choose a reason for hiding this comment

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

self.get_option('ansible_python_interpreter').split()[3] [](start = 29, length = 56)

This logic is not robust.
If this case not self.container happens in your test? If not, we can just fallback to base class function. #Closed

Copy link
Contributor Author

@msosyak msosyak Dec 3, 2019

Choose a reason for hiding this comment

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

If I am right this module was made just for one thing, to execute tasks inside the container on the host. And it retrieves the container name from shebang in build_module_command which is not anything else as ansible_python_interpreter. And for this plugin, it should look like docker exec -i <container> python what is not obvious. So I just put get_option('ansible_python_interpreter') under if to minimize get_option calls.

For any case changed this to the same approach as in build_module_command.

For me, it looks like is better to define mandatory ansible_container option for this plugin, change remove and build_module_command to use it as a container name source and replace

vars:
    ansible_shell_type: docker
    ansible_python_interpreter: docker exec -i swss python

to

vars:
    ansible_shell_type: docker
    ansible_container: swss

I could do this in separate PR if you accept.
Or maybe it is the time to look to the docker connection plugin.

Copy link
Contributor

@qiluo-msft qiluo-msft 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!

maybe it is the time to look to the docker connection plugin

I am not sure if latest version vanilla docker connection could fit. If yes, we could deprecate this plugin.

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.

Docker shell module failed in the latest sonic-mgmt
3 participants