Skip to content

Move subp into its own module.#416

Merged
blackboxsw merged 2 commits into
canonical:masterfrom
smoser:feature/move-subp
Jun 8, 2020
Merged

Move subp into its own module.#416
blackboxsw merged 2 commits into
canonical:masterfrom
smoser:feature/move-subp

Conversation

@smoser
Copy link
Copy Markdown
Collaborator

@smoser smoser commented Jun 5, 2020

This was painful, but it finishes a TODO from cloudinit/subp.py.

It moves the following from util to subp:
ProcessExecutionError
subp_blob_in_tempfile
subp
which
target_path

It is arguable that 'target_path' could be moved to a 'path_utils' or
something, but in order to use it from subp and also from utils,
we had to get it out of utils.

@smoser smoser force-pushed the feature/move-subp branch from aed0f01 to 4f3e15e Compare June 6, 2020 02:09
@igalic
Copy link
Copy Markdown
Collaborator

igalic commented Jun 6, 2020

looking at this diff makes me think we should extract the service handling code into its own set of functions

ooooooor, move them into distro 😅

@smoser smoser force-pushed the feature/move-subp branch from 4f3e15e to 231bda7 Compare June 8, 2020 14:05
This was painful, but it finishes a TODO from cloudinit/subp.py.

It moves the following from util to subp:
  ProcessExecutionError
  subp
  which
  target_path

I moved subp_blob_in_tempfile into cc_chef, which is its only caller.
That saved us from having to deal with it using write_file
and temp_utils from subp (which does not import any cloudinit things now).

It is arguable that 'target_path' could be moved to a 'path_utils' or
something, but in order to use it from subp and also from utils,
we had to get it out of utils.
@smoser smoser force-pushed the feature/move-subp branch from 231bda7 to 2dfe43c Compare June 8, 2020 15:40
Add myself to list of those that have signed cla.
@blackboxsw blackboxsw self-assigned this Jun 8, 2020
Comment thread cloudinit/subp.py
return None


def is_exe(fpath):
Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw Jun 8, 2020

Choose a reason for hiding this comment

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

Can we make this private since it's only a helper function used locally which is not intended for external consumers?

def _is_exe(fpath)?

I also wonder about pulling over runparts into cloudinit.subp too and actually have it call _is_exe instead of the duplicate logic " if os.path.isfile(exe_path) and os.access(exe_path, os.X_OK): "

Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

Looks good, three somewhat minor notes.

  1. is_exe -> _is_exe
  2. Can we move util.runparts -> subp.runparts
  3. subp.runparts to call _is_exe too

@smoser
Copy link
Copy Markdown
Collaborator Author

smoser commented Jun 8, 2020

Looks good, three somewhat minor notes.

1. is_exe -> _is_exe

2. Can we move util.runparts -> subp.runparts

3. subp.runparts  to call _is_exe too

I think I agree with all of these, but suggest that maybe they are all sane as follow-on.

Thoughts?

@smoser
Copy link
Copy Markdown
Collaborator Author

smoser commented Jun 8, 2020

Looks good, three somewhat minor notes.

1. is_exe -> _is_exe

OK, I went ahead and did this one.

@smoser smoser force-pushed the feature/move-subp branch 2 times, most recently from e704e4d to e977ff8 Compare June 8, 2020 16:36
@blackboxsw
Copy link
Copy Markdown
Collaborator

Looks good, three somewhat minor notes.

1. is_exe -> _is_exe

2. Can we move util.runparts -> subp.runparts

3. subp.runparts  to call _is_exe too

I think I agree with all of these, but suggest that maybe they are all sane as follow-on.

Thoughts?

Yes let's pull in parts 2 & 3 as a separate PR.

Copy link
Copy Markdown
Collaborator

@blackboxsw blackboxsw 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 this,

Let's move runparts out of util as a separate exercise so we also can leverage is_exe from subp.subp (and thin out function definitions in util).

@blackboxsw blackboxsw merged commit 3c551f6 into canonical:master Jun 8, 2020
smoser added a commit to smoser/cloud-init that referenced this pull request Jun 8, 2020
This was brought up in review of canonical#416.
Makes sense to remove the local copy of "is this executable file".
smoser added a commit to smoser/cloud-init that referenced this pull request Jun 8, 2020
runparts (run a directory of scripts) seems to fit well in subp
module.  The request to move it there was raised in canonical#416.
@smoser smoser mentioned this pull request Jun 8, 2020
smoser added a commit to smoser/cloud-init that referenced this pull request Jun 8, 2020
runparts (run a directory of scripts) seems to fit well in subp
module.  The request to move it there was raised in canonical#416.
@smoser
Copy link
Copy Markdown
Collaborator Author

smoser commented Jun 8, 2020

2 -> #420
3 -> #419

smoser added a commit to smoser/cloud-init that referenced this pull request Jun 8, 2020
runparts (run a directory of scripts) seems to fit well in subp
module.  The request to move it there was raised in canonical#416.

Replace use of logexc with LOG.debug as logexc comes from util.
blackboxsw pushed a commit that referenced this pull request Jun 8, 2020
runparts (run a directory of scripts) seems to fit well in subp
module.  The request to move it there was raised in #416.

Replace use of logexc with LOG.debug as logexc comes from util.
smoser added a commit to smoser/cloud-init that referenced this pull request Jun 8, 2020
This was brought up in review of canonical#416.
Makes sense to remove the local copy of "is this executable file".
blackboxsw pushed a commit that referenced this pull request Jun 8, 2020
This was brought up in review of #416.
Makes sense to remove the local copy of "is this executable file".
@raharper raharper mentioned this pull request Jul 10, 2020
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.

3 participants