8000 add `-q`/`--quiet` to `ch-image` by lucaudill · Pull Request #1636 · hpc/charliecloud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

add -q/--quiet to ch-image #1636

Merged
merged 41 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a894feb
add \-\-quiet to ch-image
lucaudill Apr 14, 2023
7ff1065
add --quiet to ch-run
lucaudill Apr 14, 2023
1f03ea5
start adding multiple levels of --quiet [skip ci]
lucaudill Apr 17, 2023
fae4096
debugging [skip ci]
lucaudill May 16, 2023
0cf839b
ugghh
lucaudill May 17, 2023
57df5d7
more junk, getting closer
lucaudill May 17, 2023
f94d3d0
more progress
lucaudill May 23, 2023
ee97310
nvm about ch-run actually
lucaudill May 25, 2023
4eafc9e
add documentation, implement a bit
lucaudill May 26, 2023
e2fb0dd
fix ch-run-oci, remove unneccessary (?) change
lucaudill May 26, 2023
315b6ce
update gestalt
lucaudill May 30, 2023
67e8b40
add test
lucaudill May 30, 2023
a033dbb
change some things, fix a test
lucaudill May 31, 2023
1e3387b
Merge branch 'master' into add-quiet_1613
lucaudill May 31, 2023
836eda7
add new opt to completion script
lucaudill May 31, 2023
dcd3ee1
make sane
lucaudill May 31, 2023
6418183
Update bin/ch-image.py.in [skip ci]
lucaudill Jun 5, 2023
6f1cb22
Update bin/ch-image.py.in [skip ci]
lucaudill Jun 5, 2023
345935f
Update test/build/50_ch-image.bats [skip ci]
lucaudill Jun 5, 2023
d52fb8b
Update doc/ch-image.rst [skip ci]
lucaudill Jun 6, 2023
6a4f763
update help, add enum
lucaudill Jun 7, 2023
96d8e62
Merge branch 'master' into add-quiet_1613
lucaudill Sep 5, 2023
6568e2a
Merge branch 'add-quiet_1613' of github.com:hpc/charliecloud into add…
lucaudill Sep 5, 2023
3266e25
remove whitespace
lucaudill Sep 5, 2023
3cc973f
summary table per discussion [skip ci]
reidpr Sep 6, 2023
af79212
Merge branch 'master' into add-quiet_1613
lucaudill Sep 7, 2023
f637dfc
more enum stuff [skip ci]
lucaudill Sep 11, 2023
8fbebde
finish enum stuff
lucaudill Sep 12, 2023
812535e
fix a bug
lucaudill Sep 12, 2023
89e0a4e
Merge branch 'master' into add-quiet_1613
lucaudill Sep 12, 2023
1b2eea2
trailing whitespace
lucaudill Sep 12, 2023
f7939f6
update test
lucaudill Sep 12, 2023
186cde9
fix a test
lucaudill Sep 12, 2023
2faffe7
even more suggestions
lucaudill Sep 13, 2023
1635a55
Update doc/ch-image.rst [skip ci]
lucaudill Sep 13, 2023
030234a
Update doc/faq.rst [skip ci]
lucaudill Sep 13, 2023
f7263be
more suggestions
lucaudill Sep 14, 2023
37b87e1
Merge branch 'add-quiet_1613' of github.com:hpc/charliecloud into add…
lucaudill Sep 14, 2023
f851ec1
more suggestions
lucaudill Sep 14, 2023
0fc4783
disable cache for test
lucaudill Sep 14, 2023
157342a
tidy
reidpr Sep 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
8000
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/ch-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ _im 8000 age_build_opts="-b --bind --build-arg -f --file --force
_image_common_opts="-a --arch --always-download --auth --cache
--cache-large --dependencies -h --help
--no-cache --no-lock --no-xattrs --profile
--rebuild --password-many -s --storage
--rebuild --password-many -q --quiet -s --storage
--tls-no-verify -v --verbose --version"

_image_subcommands="build build-cache delete gestalt
Expand Down
9 changes: 9 additions & 0 deletions bin/ch-image.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def main():
[["--profile"],
{ "action": "store_true",
"help": "dump profile to “./profile.{p,txt}”" }],
[["-q", "--quiet"],
{ "action": "count",
"default": 0,
"help": "print less output (can be repeated)"}],
[["-s", "--storage"],
{ "metavar": "DIR",
"type": fs.Path,
Expand Down Expand Up @@ -240,6 +244,11 @@ def main():
# python-path
tp = sp.add_parser("python-path", "print path to python interpreter in use")
add_opts(tp, misc.gestalt_python_path, deps_check=False, stog_init=False)
# logging
tp = sp.add_parser("logging", "print logging messages at all levels")
add_opts(tp, misc.gestalt_logging, deps_check=False, stog_init=False)
tp.add_argument("--fail", action="store_true",
help="also generate a fatal error")

# import
sp = ap.add_parser("import", "copy external image into storage")
Expand Down
1 change: 1 addition & 0 deletions bin/ch-run-oci.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def args_parse():
args_.no_lock = False
args_.password_many = False
args_.profile = False
args_.quiet = False
args_.storage = None
args_.tls_no_verify = False
args_.no_xattrs = False
Expand Down
14 changes: 10 additions & 4 deletions doc/ch-image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ Common options placed before or after the sub-command:
:code:`--no-xattrs`
Ignore xattrs and ACLs.

:code:`--password-many`
Re-prompt the user every time a registry password is needed.

:code:`--profile`
Dump profile to files :code:`/tmp/chofile.p` (:code:`cProfile` dump
format) and :code:`/tmp/chofile.txt` (text summary). You can convert the
Expand All @@ -98,13 +101,15 @@ Common options placed before or after the sub-command:
subprocesses. Profile data should still be written on fatal errors, but
not if the program crashes.

:code:`-q, --quiet`
Be quieter; can be repeated. Incompatible with :code:`-v` and suppresses
:code:`--debug` regardless of option order. See the :ref:`FAQ entry on
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should revisit the --debug incompatibility? It seems orthogonal now.

Also --debug seems to be undocumented here.

verbosity <faq_verbosity>` for details.

:code:`--rebuild`
Execute all instructions, even if they are build cache hits, except for
:code:`FROM` which is retrieved from cache on hit.

:code:`--password-many`
Re-prompt the user every time a registry password is needed.

:code:`-s`, :code:`--storage DIR`
Set the storage directory (see below for important details).

Expand All @@ -113,7 +118,8 @@ Common options placed before or after the sub-command:
unless you understand the risks.)

:code:`-v`, :code:`--verbose`
Print extra chatter; can be repeated.
Print extra chatter; can be repeated. See the :ref:`FAQ entry on verbosity
<faq_verbosity>` for details.


Architecture
Expand Down
48 changes: 0 additions & 48 deletions doc/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -943,54 +943,6 @@ This form of list should be used unless some API requires something else.
char **list = list_new(sizeof(char *), 0)
list_append((void **)list, &bar, sizeof(char *)); // OK

Logging
-------

Charliecloud uses reasonably standard log levels for its stderr logging. The
verbosity can be increased by up to three :code:`-v` command line arguments.
Both the Python and C code use the same levels by calling logging functions
named by level. The main error can be accompanied by a hint. The levels are:

1. **FATAL**; always printed. Some error condition that makes it impossible
to proceed. The program exits unsuccessfully immediately after printing
the error. Examples: unknown image type, Dockerfile parse error.

2. **WARNING**; always printed. Unexpected condition the user needs to know
about but that should not stop the program. Examples: :code:`ch-run
--mount` with a directory image (which does not use a mount point),
unsupported Dockerfile instructions that are ignored.

3. **INFO**; always printed. Chatter useful enough to always be printed.
Example: progress messages during image download and unpacking. Note
:code:`ch-run` is silent during normal operations and does not have any
INFO logging.

4. **VERBOSE**; printed if :code:`-v` or more. Diagnostic information useful
for debugging user containers, the Charliecloud installation, and
Charliecloud itself. Examples: :code:`ch-run --join` coordination
progress, :code:`ch-image` internal paths, Dockerfile parse tree.

5. **DEBUG**; printed if :code:`-vv` or more. More detailed diagnostic
information useful for debugging Charliecloud. Examples: data structures
unserialized from image registry metadata JSON, image reference parse
tree.

6. **TRACE**; printed if :code:`-vvv`. Grotesquely detailed diagnostic
information for debugging Charliecloud, to the extent it interferes with
normal use. A sensible person might use a `debugger
<https://twitter.com/wesamo__/status/1464764461831663626>`_ instead.
Examples: component-by-component progress of bind-mount target directory
analysis/creation, text of image registry JSON, every single file
unpacked from image layers.

There is no level ERROR; anything important the user needs to know about is
WARNING if we can safely proceed or FATAL if not.

.. warning::

Do not use INFO for *output*. For example, the results of :code:`ch-image
list` just use plain :code:`print()` to stdout.


OCI technical notes
===================
Expand Down
157 changes: 152 additions & 5 deletions doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ of the default 1001:1001), i.e. :code:`--gid=5`. Then, step 4 succeeds because
the call is mapped to :code:`chown("/dev/pts/0", 1000, 1001)` and MATLAB is
happy.

.. _faq_docker2tar-size:

:code:`ch-convert` from Docker incorrect image sizes
----------------------------------------------------

Expand Down Expand Up @@ -1031,7 +1029,6 @@ One fix is to configure your :code:`.bashrc` or equivalent to:
fi
}


How can I build images for a foreign architecture?
--------------------------------------------------

Expand Down Expand Up @@ -1079,7 +1076,6 @@ install :code:`qemu-*-static`, is to populate a chroot for it with the `PRoot
specifying a :code:`qemu-*-static` binary (perhaps obtained by unpacking a
distribution package).


How can I use tarball base images from e.g. linuxcontainers.org?
----------------------------------------------------------------

Expand All @@ -1098,6 +1094,157 @@ linuxcontainers.org uses the opposite order for “le” in the architecture nam
$ wget https://uk.lxd.images.canonical.com/images/alpine/3.15/ppc64el/default/20220304_13:00/rootfs.tar.xz
$ ch-image import rootfs.tar.xz ppc64le/alpine:3.17

.. _faq_verbosity:

How can I control Charliecloud’s quietness or verbosity?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Say something about Charliecloud's own stdout in this section?

--------------------------------------------------------

Charliecloud logs various chatter about what is going on to standard error.
This is distinct from *output*, e.g., :code:`ch-image list` prints the list of
images to standard output. We use reasonably standard log levels:

1. **Error**. Some error condition that makes it impossible to proceed. The
program exits soon after printing the error. Examples: unknown image
type, Dockerfile parse error. (There is an internal distinction between
“fatal” and “error” levels, but this isn’t really meaningful to users.)

2. **Warning**. Unexpected condition the user needs to know about but that
should not stop the program. Examples: :code:`ch-run --mount` with a
directory image (which does not use a mount point), unsupported
Dockerfile instructions that are ignored.

3. **Info**. Chatter useful enough to be printed by default. Example:
progress messages during image download and unpacking. (:code:`ch-run` is
silent during normal operations and does not have any “info” logging.)

4. **Verbose**. Diagnostic information useful for debugging user containers,
the Charliecloud installation, and Charliecloud itself. Examples:
:code:`ch-run --join` coordination progress, :code:`ch-image` internal
paths, Dockerfile parse tree.

5. **Debug**. More detailed diagnostic information useful for debugging
Charliecloud. Examples: data structures unserialized from image registry
metadata JSON, image reference parse tree.

6. **Trace**; printed if :code:`-vvv`. Grotesquely detailed diagnostic
information for debugging Charliecloud, to the extent it interferes with
normal use. A sensible person might use a `debugger
<https://twitter.com/wesamo__/status/1464764461831663626>`_ instead.
Examples: component-by-component progress of bind-mount target directory
analysis/creation, text of image registry JSON, every single file
unpacked from image layers.

Charliecloud also runs sub-programs at various times, notably commands in
:code:`RUN` instructions and :code:`git(1)` to manage the build cache. These
programs have their own standard error and standard output streams, which
Charliecloud either suppresses or passes through depending on verbosity level.

Most Charliecloud programs accept :code:`-v` to increase logging verbosity and
:code:`-q` to decrease it. Generally:

* Each :code:`-v` (up to three) makes Charliecloud noisier.

* :code:`-q` suppresses normal logging.

* :code:`-qq` also suppresses stdout for the program and its subprocesses,
and warnings from the program.

* :code:`-qqq` also suppresses subprocess stderr. (This means subprocesses
are completely silenced no matter what goes wrong!)

This table list which logging is printed at which verbosity levels (✅
indicates printed, ❌ suppressed).

.. list-table::
:header-rows: 1

* -
- :code:`-vvv`
- :code:`-vv`
- :code:`-v`
- def.
- :code:`-q`
- :code:`-qq`
- :code:`-qqq`
* - trace
- ✅
- ❌
- ❌
- ❌
- ❌
- ❌
- ❌
* - debug
- ✅
- ✅
- ❌
- ❌
- ❌
- ❌
- ❌
* - verbose
- ✅
- ✅
- ✅
- ❌
- ❌
- ❌
- ❌
* - info
- ✅
- ✅
- ✅
- ✅
- ❌
- ❌
- ❌
* - program stdout
- ✅
- ✅
- [1]
- [1]
- [1]
- ❌
- ❌
* - subprocess stdout
- ✅
- ✅
- [1]
- [1]
- [1]
- ❌
- ❌
* - warning
- ✅
- ✅
- ✅
- ✅
- ✅
- ❌
- ❌
* - subprocess stderr
- ✅
- ✅
- ✅
- ✅
- ✅
- ✅
- ❌
* - error
- ✅
- ✅
- ✅
- ✅
- ✅
- ✅
- ✅

Notes:

1. Charliecloud handles subprocess stdout on case-by-case basis for these log
levels. For example, sometimes it’s passed through by default (e.g.,
:code:`RUN`) and sometimes it’s captured for internal use (e.g., many
:code:`git(1)` invocations).

.. LocalWords: CAs SY Gutmann AUTH rHsFFqwwqh MrieaQ Za loc mpihello mvo du
.. LocalWords: VirtualSize linuxcontainers jour uk lxd rwxr xr
.. LocalWords: VirtualSize linuxcontainers jour uk lxd rwxr xr qq qqq
4 changes: 2 additions & 2 deletions lib/build_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ def summary_print(self):
print("internal files: %5d %s" % (file_ct, file_suffix))
print("disk used: %5d %s" % (byte_ct, byte_suffix))
# some information directly from Git
if (ch.verbose >= 1):
if (ch.log_level >= ch.Log_Level.VERBOSE):
out = self.git(["count-objects", "-vH"]).stdout
print("Git statistics:")
print(textwrap.indent(out, " "), end="")
Expand All @@ -1185,7 +1185,7 @@ def tree_print(self):
# Note the percent codes are interpreted by Git.
# See: https://git-scm.com/docs/git-log#_pretty_formats
args = ["log", "--graph", "--all", "--reflog", "--topo-order"]
if (ch.verbose == 0):
if (ch.log_level == ch.Log_Level.INFO):
# ref names, subject (instruction), branch heads.
fmt = "%C(auto)%d %Creset%<|(77,trunc)%s"
args.append("--decorate-refs=refs/heads")
Expand Down
Loading
0