Commit graph

109 commits

Author SHA1 Message Date
Chris Evich bfc1b66be1
Cirrus: Fix running Validate task on branches
Followup to dbb9943

Despite skipping the `Smoke` check, it was observed on a *new* branch,
the `validate` task (specifically `git-validation`) will fail.  This
is because:

* `$CIRRUS_LAST_GREEN_CHANGE` will be empty on a new branch.
* `$CIRRUS_BASE_SHA` is always empty for runs triggered by branch-push
* `$EPOCH_TEST_COMMIT` will be set to `YOU_FOUND_A_BUG`.

Fix this by eliminating the `Smoke` task entirely, simplifying all
the `make validate` operations into the `validate` cirrus task.  Ensure
this task does not run when a new branch or tag is pushed.

Also, eliminate the `$CIRRUS_BUILD_ID` value as it's confusing and not
actually used anywhere.  It was formerly used for building VM images,
but this has moved to another repo entirely.

Signed-off-by: Chris Evich <cevich@redhat.com>
2021-01-27 10:35:27 -05:00
Valentin Rothberg caaaa2c5e1 hack/install_golangci.sh: smarter install
Detect if the installed version of golangci-lint is outdated and update
it if needed.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-17 17:15:23 +01:00
Valentin Rothberg f38b7f48cc golangci-lint: install to ./bin
Install golangci-lint to `./bin` instead of `$GOBIN`.  The latter may be
shared with other projects who require a different version.  Having a
shared version of golangci-lint is a reoccurring source of red herrings
on my work station, so I think it's time to split them.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-01-17 17:07:04 +01:00
Chris Evich ec309504c4
[CI:DOCS] Add hook-script example to get_ci_vm.sh
Signed-off-by: Chris Evich <cevich@redhat.com>
2021-01-14 14:26:36 -05:00
Josh Soref 4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
Jhon Honce e55320efde hack/podman-socat captures the API stream
* verify socat and podman binaries exist
* setup a sandboxed podman service
* run podman service with socat proxy to capture API stream
* clean up sandbox leaving the log files for review

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-12-02 16:03:56 -07:00
Daniel J Walsh f62a356515
Remove varlink support from Podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-26 16:50:42 -05:00
Jhon Honce b59465d1cc Fix sed regex to update version in version/version.go
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-11-18 15:21:26 -07:00
OpenShift Merge Robot 2993e97dec
Merge pull request #6442 from Luap99/podman-autocomplete
Shell completion
2020-11-13 16:46:51 +01:00
OpenShift Merge Robot 2fc2d4643e
Merge pull request #8316 from rhatdan/codespell
Fix issues found with codespell
2020-11-12 23:29:51 +01:00
Paul Holzinger f5a2e578eb Maintain consistent order of short and long flag names in docs
Make the order of short and long flag names in the documentation
consistent. Also adjust the man page validaten script to only allow
the `**--long**, **-s**` syntax.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-11-12 21:46:17 +01:00
Daniel J Walsh a7431003b8
Fix issues found with codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-11-12 13:37:38 -05:00
Paul Holzinger b5d1d89a37 Add shell completion with cobra
Allow automatic generation for shell completion scripts
with the internal cobra functions (requires v1.0.0+).

This should replace the handwritten completion scripts
and even adds support for fish. With this approach it is
less likley that completions and code are out of sync.

We can now create the scripts with
- podman completion bash
- podman completion zsh
- podman completion fish

To test the completion run:
source <(podman completion bash)

The same works for podman-remote and podman --remote and
it will complete your remote containers/images with
the correct endpoints values from --url/--connection.

The completion logic is written in go and provided by the
cobra library. The completion functions lives in
`cmd/podman/completion/completion.go`.

The unit test at cmd/podman/shell_completion_test.go checks
if each command and flag has an autocompletion function set.
This prevents that commands and flags have no shell completion set.

This commit does not replace the current autocompletion scripts.

Closes #6440

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-11-12 11:38:31 +01:00
Ed Santiago b0601cb34a [CI:DOCS] Restore man page cross-checker
Somewhere in the CIv2 migration we lost the man page vs --help
cross-checker. Add it back, by adding it into the man-page-check
Makefile target; this is part of 'make validate', which is run
in CI even on CI:DOCS PRs.

As happens when CI doesn't run, things broke. Man pages got out
of sync with --help. This PR:

 1) Fixes hack/xref-helpmsgs-manpages to deal with the new
    "Options" (instead of "Flags") form of podman help. #8034
    did part of that, but one of my review comments was
    accidentally left out.

 2) Fixes hack/xref-helpmsgs-manpages to deal with the new
    option syntax in man pages, post- #8292, in which each
    option is preceded by four hashes so as to make them
    HTML <h4> elements with named anchors.

 3) Fixes man pages that #8292 accidentally missed.

 4) Adds man page entries for two flags that got added
    to podman but not documented (pod create --network-alias,
    play kube --log-driver)

Fixes: #8296

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-11-11 08:31:30 -07:00
Marcel Bargull 06d2d0c6ef Use CPP, CC and flags in dep check scripts
Allow build systems without standard cc to successfully run the
dependency checking helper scripts from the Makefile.
This supports custom compilers specified by the common CC environment
variable, preprocessors given as CPP and additional preprocessor flags
from CPPFLAGS.
Additional flags from CFLAGS and LDFLAGS are considered for compiling/linking.
Overall, this facilitates cross-compilation and similar setups.

Signed-off-by: Marcel Bargull <marcel.bargull@udo.edu>
2020-11-06 10:44:27 +01:00
Daniel J Walsh 980b1e87d4
Switch use of Flags to Options
Want to have man pages match commands, since we have lots of printed
man pages with using Options, we will change the command line to use
Options in --help.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-10-21 08:37:57 -04:00
Chris Evich 5b7c64cc97
Cirrus: Fix obtaining a CI VM
Also removed automatic exection of setup_environment.sh since most
people using this script are podman developers (not automation/CI
folks).  If executing the automation scripts is necessary, manual
attendance to required variables like `$TEST_FLAVOR` is mandatory.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-10-07 15:29:43 -04:00
OpenShift Merge Robot 0a46b9c9e6
Merge pull request #7696 from jwhonce/wip/version
Refactor version handling in cmd tree
2020-09-21 13:23:20 +00:00
Jhon Honce c4b49afad3 Refactor version handling in cmd tree
* Move from simple string to semver objects
* Change client API Version from '1' to 2.0.0

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-09-18 15:13:58 -07:00
Jordan Christiansen d20a37bf10 Install bats as root
Installing bats to /usr/local requires root privileges. Without this,
`make install.tools` fails. However, if I do `sudo make install.tools`,
then all of the other dependencies and git clones in the current
directory end up owned by root. This limits root privileges to the part
that needs it.

Signed-off-by: Jordan Christiansen <xordspar0@gmail.com>
2020-09-18 12:50:25 -05:00
Daniel J Walsh 526f01cdf5
Fix up errors found by codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-11 06:14:25 -04:00
Paul Holzinger b4adc17614 [CI:DOCS] fix swagger api docs
Separate the volume endpoints into compat and libpod,
as it is done for the other endpoints.

Move the libpod image push endpoint to images.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-23 15:10:22 +02:00
Sascha Grunert ba9f18e2b8
Use bash binary from env instead of /bin/bash for scripts
It's not possible to run any of the scripts on distributions which do
have `bash` not in `/bin`. This is being fixed by using `/usr/bin/env
bash` instead.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-17 10:42:23 +02:00
Ed Santiago 8e11a825e1 Cross-reference *.rst files too
There are a bunch of *.rst files in docs/source, linking sometimes
to man pages and sometimes to other .rst files. These files each
have entries of the following form:

   :doc:`foo <link-to-foo>` Description of foo

...for all podman sub and sub-subcommands 'foo'.

Read all .rst files and make sure that:

  - all entries in a given file are in alphabetical order
  - all link-to-foo targets point to existing doc files
  - every subcommand known by 'podman help' has a corresponding
    doc entry in a .rst file

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-11 08:03:37 -06:00
Ed Santiago ca893b8329 Man pages: assert that subcommands are in order
For each podman*.md file with a subcommand table (podman,
podman-container, etc), assert that the subcommand list
is sorted.

Change is bigger than it should be, because it switches from
nice clean local per-function error counting to using a nasty
global.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-08-11 07:49:10 -06:00
Daniel J Walsh a5e37ad280
Switch all references to github.com/containers/libpod -> podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-28 08:23:45 -04:00
Jhon Honce 964d3300c6 [WIP] Refactor podman system connection
* Add support to manage multiple connections
  * Add connection
  * Remove connection
  * Rename connection
  * Set connection as default
  * Add markdown/man pages
* Fix recursion in hack/xref-helpmsgs-manpages

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-07-22 15:25:44 -07:00
Valentin Rothberg d628de31d7 unit tests: root check
The unit tests currently require running as root.  This has caused some
confusion that justifies adding a root check to `make localunit` and
error out for non-root users instead of starting the tests deemed to
fail.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-21 13:31:43 +02:00
Valentin Rothberg 8489dc4345 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules.  While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
`github.com/containers/libpod/v2`.  The renaming of the imports
was done via `gomove` [1].

[1] https://github.com/KSubedi/gomove

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:50:12 +02:00
Ed Santiago c6090c290e Docs: consistency between man / --help
New functionality in hack/man-page-checker: start cross-
referencing the man page 'Synopsis' line against the
output of 'podman foo --help'. This is part 1, flag/option
consistency. Part 2 (arg consistency) is too big and will
have to wait for later.

flag/option consistency means: if 'podman foo --help'
includes the string '[flags]' in the Usage message,
make sure the man page includes '[*options*]' in its
Synopsis line, and vice-versa. This found several
inconsistencies, which I've fixed.

While doing this I realized that Cobra automatically
includes a 'Flags:' subsection in its --help output
for all subcommands that have defined flags. This
is great - it lets us cross-check against the
usage synopsis, and make sure that '[flags]' is
present or absent as needed, without fear of
human screwups. If a flag-less subcommand ever
gets extended with flags, but the developer forgets
to add '[flags]' and remove DisableFlagsInUseLine,
we now have a test that will catch that. (This,
too, caught two instances which I fixed).

I don't actually know if the new man-page-checker
functionality will work in CI: I vaguely recall that
it might run before 'make podman' does; and also
vaguely recall that some steps were taken to remedy
that.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-06-24 10:39:10 -06:00
Valentin Rothberg 334d3b1ef3 CI: force registry:2.6
For using the `registry:2.6` image. 2.7 and beyond dropped the
`htpasswd` binary from the rootfs which parts of our CI depends
on.

While this is not a sustainable solution (assuming `htpasswd` is gone
for ever), it unblocks the CI for now.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-19 12:58:02 +02:00
Valentin Rothberg b6148b6576 force bats version to v1.1.0
We experienced regression when using the latest `v1.2.0-dev` bats in
Ubuntu 20.04 (see github.com/containers/libpod/pull/6418).  Using
bats v1.1.0 worked in the Ubuntu test VM.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-08 15:21:34 +02:00
Daniel J Walsh 9263ed2ab1
Remove use of ABISupport buildtag
We need to default to building podman. If you specify no build
tags you will not build podman, not podman-remote.

Just using remote flag to indicate podman-remote and !remote for
podman.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-03 15:11:34 -04:00
Ed Santiago b81b865b52 podman-registry: many unrelated fixes
1) fix lost credentials.

    must_pass(), added in #6375, eats the credentials
    generated via 'podman run --entrypoint htpasswd'.
    Run that podman instance directly, and add explicit
    error check.

    (The error and stdout/stderr handling here has gotten
    cumbersome. There must be something I'm missing that
    could make it all simpler.)

 2) fix default podman path.

    When setting $PODMAN, default to the locally built
    one -- there may not be one in $PATH (e.g. in
    Ubuntu, see #6366). This in turn requires us to:

 3) run registry test in integration, not unit test

    It looks like unit tests run before podman is built,
    causing a chicken-egg dilemma. Try to solve that by
    running the new hack/podman-registry-go test in
    integration tests, not unit tests.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-26 08:21:46 -06:00
Ed Santiago f75ad6d5c2 podman-registry helper script: handle errors
My initial revision of the podman-registry helper script
was written in haste, with an enormous tradeoff: no
visibility into any errors. We are now paying for this
in #6366: the script is failing on Ubuntu and we
have no way of knowing why.

This PR adds a must_pass() function used for critical
steps. This runs the action silently; if the command
fails, it displays the failing command name with
full output logs, cleans up the temporary workdir,
and exits with error status.

As a reminder, the reason this is necessary is that
our script convention is to output a series of
environment variables to stdout -- we must therefore
take pains not to emit anything else to stdout.
And, unfortunately, podman and openssl tend to be
rather verbose.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-24 08:10:54 -06:00
Daniel J Walsh 35567e706b
Attempt to turn on additional build tests
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-22 12:55:23 -04:00
Valentin Rothberg dfe0579a2f add go-bindings for hack/podman-registry
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-20 15:12:35 +02:00
Ed Santiago 973d624418 New tool: hack/podman-registry, manages local registry
In response to #6207: this is a helper script intended for
use in starting and stopping a local container registry.
It takes care of port, username, password assignments;
generates a self-signed certificate; and starts the
container in an isolated podman root/runroot to avoid
conflicting with the caller's environment.

Intended usage: invoke from shell script, using 'eval'
to get results into calling process environment. See
help message (-h) for invocation details. This will
work for shell scripts but will be difficult if
called from Go or C - if that is likely to happen,
I'd love to hear suggestions for alternate ways to
get the settings back to the caller.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-05-20 10:22:16 +02:00
Chris Evich 8d54e4855c
Cirrus: Fix image-name hints
This properly prints out image-name hints when executing the hack script
without any arguments.  It is required due to changes made by Ed for
test-name beatification.  An identical change was made and reviewed by
Ed in the containers/storage repo.

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-05-14 15:00:34 -04:00
Valentin Rothberg 09dc701097 podman rmi: refactor logic
While this commit was initially meant to fix #5847, it has turned into a
bigger refactoring which I did not manage to break into smaller pieces:

 * Fix #5847 by refactoring the image-removal logic.

 * Make the api handler for image-removal use the ABI code. This way,
   both (i.e., ABI and Tunnel) end up using the same code.  Achieving
   this code share required to move some code around to prevent circular
   dependencies.

 * Everything in pkg/api (excluding pkg/api/types) must now only be
   accessed from code using `ABISupport`.

 * Avoid imports from entities on handlers to prevent circular
   dependencies.

 * Move `podman system service` logic into `cmd` to prevent circular
   dependencies - it depends on pkg/api.

 * Also remove the build header from infra/abi files.  It will otherwise
   confuse swagger and other tools; errors we cannot fix as go doesn't
   expose a build-tag env variable.

Fixes: #5847
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-21 08:12:25 +02:00
Ed Santiago ba26c763c5 swagger-check: new CI tool to cross-check swagger
New script cross-references r.Handle() and r.HandleFunc()
calls against the preceding '// swagger:operation' comments,
and exits failure (with descriptive error messages) if any
comments do not match the code.

This script should not be necessary: the swagger comments
should be autogenerated from the source code.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-14 11:27:44 -06:00
Jhon Honce e0847f5457 V2 podman system service
* Added support for system service
* Enabled linting on the varlinkapi source, needed to support V2
  service command
* Added support for PODMAN_SOCKET

Skip linting deprecated code

Rather than introduce bugs by correcting deprecated code, linting the
code is being skipped. Code that is being ported into V2 is being
checked.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-04-07 19:22:10 -07:00
Ed Santiago 108ab380f1 podmanv2-retry - new helper for testing v2
./hack/podmanv2-retry will first invoke $PODMAN_V2 with given
arguments. If that fails with any of the following errors:

    unrecognized command
    unknown flag
    unknown shorthand

...it will run $PODMAN_FALLBACK with the same arguments.
Output and exit code will be those of the final podman command,
although be aware that stderr and stdout are combined.

This is a quick-hack script intended for use in v2 testing, to
test implemented commands without noise from unimplemented ones.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-04-01 14:14:00 -06:00
OpenShift Merge Robot 49a7856f2e
Merge pull request #5465 from edsantiago/man_page_option_checker
New test: man page cross-ref against --help
2020-03-19 16:53:02 +01:00
Ed Santiago 81005f463e New test: man page cross-ref against --help
New hack/xref-helpmsgs-manpages script, added to CI 'gate'
task, runs 'podman [subcommand] --help' and cross-references
against man pages in docs/source/markdown/podman*.1.md

See #5453 and #5460 for instances of the problems the
script has found.

The careful reader will find an alarming number of special-case
bypasses. These are a tradeoff I am making: to get perfect
coverage with no handwaving, it would be necessary to make
drastic changes to some man pages, and I believe those would
be counterproductive.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-03-18 11:03:26 -06:00
Valentin Rothberg f4e873c4e1 auto updates
Add support to auto-update containers running in systemd units as
generated with `podman generate systemd --new`.

`podman auto-update` looks up containers with a specified
"io.containers.autoupdate" label (i.e., the auto-update policy).

If the label is present and set to "image", Podman reaches out to the
corresponding registry to check if the image has been updated.  We
consider an image to be updated if the digest in the local storage is
different than the one of the remote image.  If an image must be
updated, Podman pulls it down and restarts the container.  Note that the
restarting sequence relies on systemd.

At container-creation time, Podman looks up the "PODMAN_SYSTEMD_UNIT"
environment variables and stores it verbatim in the container's label.
This variable is now set by all systemd units generated by
`podman-generate-systemd` and is set to `%n` (i.e., the name of systemd
unit starting the container).  This data is then being used in the
auto-update sequence to instruct systemd (via DBUS) to restart the unit
and hence to restart the container.

Note that this implementation of auto-updates relies on systemd and
requires a fully-qualified image reference to be used to create the
container.  This enforcement is necessary to know which image to
actually check and pull.  If we used an image ID, we would not know
which image to check/pull anymore.

Fixes: #3575
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-03-17 17:18:56 +01:00
Chris Evich d0782e7839
Cirrus: Fix gate image & false-positive exits
A number of scripts relating to tooling used and the gate container
image were not exiting upon errors as intended.  Coupled with
external service unavailability (i.e. downloading golangci-lint)
was observed to cause difficult to debug failures.

This change corrects the scripts inside/out of the gate container as
well as fixes many golang related path consistency problems vs other CI
jobs.  After this change, all jobs use consistent path names reducing
the number of special-case overrides needed.

Lastly, I also made a documentation-pass, updating/correcting as needed,
including documenting a likely local validation-failure mode, related to
`$EPOCH_TEST_COMMIT`.  This is dependent on the developers git
environment, so documentation is the only possible "fix".

Signed-off-by: Chris Evich <cevich@redhat.com>
2020-03-02 08:50:54 -05:00
Chris Evich 42f04bbdaf
Cirrus: Fix not growing Fedora root
Signed-off-by: Chris Evich <cevich@redhat.com>
2020-02-28 09:54:35 -05:00
Brent Baude e3b31a3ab8 implement reverse reader for log reads
in cases where the log file exceeds the available memory of a system, we had a bug that triggered an oom because the entire logfile was being read when the tail parameter was given.  this reads in chunks and is more or less memory safe.

fixes: #5131

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-02-20 10:22:45 -06:00
Matthew Heon 662eab1672 Fix a syntax error in hack/release.sh
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-01-31 10:55:17 -05:00