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

update callback_dir copy and mounting behavior #1089

Conversation

TheRealHaoLiu
Copy link
Member

#1088

  • enhance callback_mount copy_if_needed check to include unmountable location /usr
  • add option to specify location when copying callback plugin
  • if callback dir copy is needed copy to artifact directory rather than /tmp

Signed-off-by: Hao Liu haoli@redhat.com

@TheRealHaoLiu TheRealHaoLiu requested a review from a team as a code owner June 3, 2022 00:32
- enhance callback_mount copy_if_needed check to include unmountable location `/usr`
- add option to specify location when copying callback plugin
- if callback dir copy is needed copy to artifact directory rather than /tmp

Signed-off-by: Hao Liu <haoli@redhat.com>
@TheRealHaoLiu TheRealHaoLiu force-pushed the enhance-callback-plugin-mount branch from eb3a409 to 39107af Compare June 3, 2022 00:34
tmp_path = tempfile.mkdtemp(prefix='ansible_runner_plugins_')
register_for_cleanup(tmp_path)
host_path = os.path.join(tmp_path, 'callback')
if callback_dir.startswith('/usr') or not is_dir_owner(callback_dir):
Copy link
Member Author

Choose a reason for hiding this comment

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

add check for if the source is from an unmountable dir (/usr)

Copy link
Member

Choose a reason for hiding this comment

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

I'm curious if we could have some more descriptive criteria than .startswith. What is it about the /usr folder that makes it un-mountable, and can we check that criteria more directly?

Comment on lines +78 to +83
if copy_dir is None:
tmp_path = tempfile.mkdtemp(prefix='ansible_runner_plugins_')
register_for_cleanup(tmp_path)
host_path = os.path.join(tmp_path, 'callback')
else:
host_path = os.path.join(copy_dir, 'callback')
Copy link
Member Author

Choose a reason for hiding this comment

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

does not change how callback_mount when call like before
callback_mount(copy_if_needed=False) will still behave like before

@@ -505,7 +505,7 @@ def wrap_args_for_containerization(self, args, execution_mode, cmdline_args):
self._update_volume_mount_paths(new_args, "{}".format(self.private_data_dir), dst_mount_path="/runner", labels=":Z")

# Mount the stdout callback plugin from the ansible-runner code base
mount_paths = callback_mount(copy_if_needed=True)
mount_paths = callback_mount(copy_if_needed=True, copy_dir="{}/artifacts".format(self.private_data_dir))
Copy link
Member Author

Choose a reason for hiding this comment

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

$private_data_dir/artifacts is a good candidate for copying the callback plugin to for the following reasons

  1. clean up after run like tmpdir so no accumulation of garbage
  2. have to be (and is therefore always) mountable by the container that are created

host_path = os.path.join(tmp_path, 'callback')
if callback_dir.startswith('/usr') or not is_dir_owner(callback_dir):
if copy_dir is None:
tmp_path = tempfile.mkdtemp(prefix='ansible_runner_plugins_')
Copy link
Member

Choose a reason for hiding this comment

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

Probably better to get rid of this entirely. You have a good case that the artifacts dir is a better location, and if it doesn't cause any problems with testing, then we should use that location in all cases, and I'd say copy_dir shouldn't be an argument here.

Copy link
Member Author

Choose a reason for hiding this comment

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

what is the best way to get the correct private_data_dir from the context of this function?

reason why i preserve the previous method signature is because i do not know what else is relying on this method (internal or imported by other project)

TheRealHaoLiu added a commit to TheRealHaoLiu/ansible-runner that referenced this pull request Jun 3, 2022
@TheRealHaoLiu
Copy link
Member Author

#1093 alternative fix proposal

@Shrews Shrews added the needs_triage New item that needs to be triaged label Jun 7, 2022
@Shrews Shrews linked an issue Jun 7, 2022 that may be closed by this pull request
@eqrx eqrx removed the needs_triage New item that needs to be triaged label Jun 14, 2022
@TheRealHaoLiu
Copy link
Member Author

closed due to alternative proposal #1093 being accepted

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.

fail to create container when ansible-runner is installed in /usr
4 participants