-
Notifications
You must be signed in to change notification settings - Fork 60
Conversation
@qwofford, what do you think of this proposal? Alternate names include deform, edit, and mutate. It would be nice not to implement the save prompt, i.e., only have the behavior with |
I like this proposal. I hadn't considered the implications of running concurrent interactive sessions on the same deployed container. The note in the documentation about an explicit need for |
I think this might be a slightly greedy hope...but in reference to the warning block of text here...it would be really nice (and unique among container runtimes?) if we somehow stored a series of Dockerfile commands that represents the build cache too. Anything from a Dockerfile could be stored directly, and then anything from a This could get us the interactive functionality we want without diverging too far from best practices at the end of the day. |
This is a cool idea. I can think of a couple approaches:
|
@reidpr I'm ready for you to have a look at my progress so far |
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.
Nice work! I think next steps are:
- Write docs describing the behavior we've discussed and you've implemented, including particularly the different behaviors depending on where the input is coming from.
- Make the cache behavior like import.
bin/ch-image.py.in
Outdated
# modify | ||
sp = ap.add_parser("modify", "foo") | ||
add_opts(sp, build.modify, deps_check=True, stog_init=True) | ||
sp.add_argument("-c", metavar="CMD", action="append", default=[], nargs="*", help="foo") |
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 think you probably want nargs=1
(the default?) and just repeat the option for multiple values (action="append"
does this). nargs="+"
and nargs="*"
can cause problems though I don't recall the details.
lib/build.py
Outdated
# FIXME: This is super kludgey | ||
cli.tag = cli.out |
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.
You can tell argparse
to put the value of --out
in tag
when you declare the command line option. That seems reasonable to me. Or, maybe do the reverse: rename cli.tag
to cli.out
?
lib/build.py
Outdated
for line in sys.stdin: | ||
# execute each line (analogous to RUN) | ||
commands.append(line) | ||
if (commands != []): |
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 wonder if the -c
, interactive stdin, and non-interactive stdin cases are sufficiently different that they should be dispatched to different functions? In any case, we should explain the situation and why the decisions made were made.
lib/build.py
Outdated
for line in sys.stdin: | ||
# execute each line (analogous to RUN) | ||
commands.append(line) |
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.
This won’t work due to the shell’s complicated rules about line breaks. I’d treat the input as an opaque blob to pass on to the shell’s stdin.
lib/build.py
Outdated
if (commands != []): | ||
tree = modify_tree_make(src_image.ref, commands) | ||
|
||
# FIXME: Be more DRY in this section |
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.
yeah that's probably essential for merging
lib/build.py
Outdated
# “Flatten” commands array | ||
for c in cli.c: | ||
commands += c |
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.
The need for this will go away if you remove nargs="*"
.
Regarding exit codes, I analyzed all man pages in §1 and §8 on man7.org to find codes that were rarely used by other software (e.g., code 0 is documented by 464 man pages and code 122 by none).
Thus, a plausible summary of unused or rarely-used exit codes has two parts. Exit codes used only by
|
code | description (quoted) |
---|---|
31 | FTP could not use REST. The REST command failed. This command is used for resumed FTP transfers. |
33 | HTTP range error. The range "command" did not work. |
49 | Malformed telnet option. |
84 | The FTP PRET command failed |
87 | Unable to parse FTP file list. |
Exit codes not documented by any man page
100–122 inclusive.
Exit codes ≥128
These are commonly used by shells and other programs that run subprocesses to indicate the child was killed by a signal. E.g. su(1)
: “If the command was killed by a signal, su returns the number of the signal plus 128”.
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.
Solid. In particular the clear, well-written comments continue.
I think my main criticism is that the logic of selecting the mode is mixed in with carrying out that mode. Is there a way to just (1) figure out the mode, then (2) do the setup (build tree or run interactive session, then (3) call build.main()
or misc.import()
? Possibly in a new modify.py
?
Also I suspect you should validate (a) cache behavior and (b) parse trees.
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.
Great work; thanks Lucas. A few nits but I’m not sure it’s worth holding up merge over those?
if (cli.interactive): | ||
ch.FATAL("script mode incompatible with interactive mode") | ||
mode = Modify_Mode.SCRIPT | ||
elif (sys.stdin.isatty() or (cli.interactive)): |
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.
elif (sys.stdin.isatty() or (cli.interactive)): | |
elif (sys.stdin.isatty() or cli.interactive): |
df_children.append(im.Tree(lark.Token('RULE', 'from_'), | ||
[im.Tree(lark.Token('RULE', 'image_ref'), | ||
[lark.Token('IMAGE_REF', str(src_img))], | ||
meta) | ||
], meta)) |
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.
Helper function might be clearer here?
Closes #1400.