Goodbye Cirrus

Removing remaining cirrus specific files that we no longer use in the
new CI setup.

Fixes: #28829

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2026-06-01 20:31:43 +02:00
parent 66e7c06073
commit 3743b9f806
No known key found for this signature in database
GPG key ID: EB145DD938A3CAF2
20 changed files with 0 additions and 2762 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,92 +0,0 @@
---
# Format Ref: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
# Required to un-FUBAR default ${{github.workflow}} value
name: check_cirrus_cron
on:
# Note: This only applies to the main branch.
schedule:
# N/B: This should correspond to a period slightly after
# the last job finishes running. See job defs. at:
# https://cirrus-ci.com/settings/repository/6707778565701632
- cron: '03 03 * * 1-5'
# Debug: Allow triggering job manually in github-actions WebUI
workflow_dispatch: {}
# Allow reuse of this workflow by other repositories
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows
workflow_call:
secrets:
SECRET_CIRRUS_API_KEY:
required : true
ACTION_MAIL_SERVER:
required: true
ACTION_MAIL_USERNAME:
required: true
ACTION_MAIL_PASSWORD:
required: true
ACTION_MAIL_SENDER:
required: true
env:
# CSV listing of e-mail addresses for delivery failure or error notices
RCPTCSV: podman-monitor@lists.podman.io
# Filename for table of build-id to cron-name data
# (must be in $GITHUB_WORKSPACE/artifacts/)
ID_NAME_FILEPATH: './artifacts/id_name.txt'
permissions:
contents: read
jobs:
cron_failures:
runs-on: ubuntu-latest
steps:
# This is where the scripts live
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: containers/podman
ref: 'main'
persist-credentials: false
- name: Get failed cron names and Build IDs
id: cron
run: './.github/actions/check_cirrus_cron/cron_failures.sh'
- if: steps.cron.outputs.failures > 0
shell: bash
run: './.github/actions/check_cirrus_cron/make_email_body.sh'
- if: steps.cron.outputs.failures > 0
name: Send failure notification e-mail
# Ref: https://github.com/dawidd6/action-send-mail
uses: dawidd6/action-send-mail@42942bc2f8fba4e611b459a018967a6a7c78c68c # v17
with:
server_address: ${{secrets.ACTION_MAIL_SERVER}}
server_port: 465
username: ${{secrets.ACTION_MAIL_USERNAME}}
password: ${{secrets.ACTION_MAIL_PASSWORD}}
subject: Cirrus-CI cron build failures on ${{github.repository}}
to: ${{env.RCPTCSV}}
from: ${{secrets.ACTION_MAIL_SENDER}}
body: file://./artifacts/email_body.txt
- if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ github.job }}_artifacts
path: artifacts/*
- if: failure()
name: Send error notification e-mail
uses: dawidd6/action-send-mail@42942bc2f8fba4e611b459a018967a6a7c78c68c # v17
with:
server_address: ${{secrets.ACTION_MAIL_SERVER}}
server_port: 465
username: ${{secrets.ACTION_MAIL_USERNAME}}
password: ${{secrets.ACTION_MAIL_PASSWORD}}
subject: Github workflow error on ${{github.repository}}
to: ${{env.RCPTCSV}}
from: ${{secrets.ACTION_MAIL_SENDER}}
body: "Job failed: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"

View file

@ -1,21 +0,0 @@
{
"cniVersion": "0.4.0",
"name": "do-not-use-google-subnets",
"plugins": [
{
"type": "bridge",
"name": "do-not-use-google-subnets",
"bridge": "do-not-use-google-subnets",
"ipam": {
"type": "host-local",
"ranges": [
[
{
"subnet": "10.128.0.0/9"
}
]
]
}
}
]
}

View file

@ -1,88 +0,0 @@
The following is a list (incomplete) of the primary contexts and runtime
"modes" supported by podman CI. Note that there may be additional checks
done regarding "skipping work" in the `runner.sh` script. This document
only details the controls at the `.cirrus.yml` level.
## Visualization
The relationship between tasks can be incredibly hard to understand by
staring at the YAML.
[A tool exists](https://github.com/containers/automation/tree/main/cirrus-task-map)
for producing a graph (flow-chart) of the `.cirrus.yml` file. A (possibly
outdated) example of it's output can be seen below:
![cirrus-task-map output](https://github.com/containers/podman/wiki/cirrus-map.svg)
## Implementation notes
+ The `skip` conditional should never be used for tasks.
While it's arguably easier to read that `only_if`, it leads to a cluttered
status output that's harder to page through when reviewing PRs. As opposed
to `only_if` which will bypass creation of the task (at runtime) completely.
Also, by sticking to one conditional style, it's easier to reuse the YAML
statements across multiple tasks.
+ The only variables which can be used as part of conditions are defined by
Cirrus-CI.
[The list is documented](https://cirrus-ci.org/guide/writing-tasks/#environment-variables). Reference to any variables defined in YAML will **not** behave how
you expect, don't use them!
* Some Cirrus-CI defined variables contain non-empty values outside their
obvious context. For example, when running for a PR a task will have
`$CIRRUS_BRANCH` set to `pull/<number>`.
* Conditions which use positive or negative regular-expressions have several
"flags" set: "Multi-line" and "Case-insensitive".
## Testing
Executing most of the modes can be mocked by forcing values for (otherwise)
Cirrus-CI defined variables. For example `$CIRRUS_TAG`. As of the publishing
of this document, it's not possible to override the behavior of `$CIRRUS_PR`.
## Cirrus Task contexts and runtime modes
By default cirrus will trigger task depending on the source changes.
It is implemented using the `only_if` field for the cirrus tasks, this logic
uses the following main rules:
- Never skip on cron runs: `$CIRRUS_PR == ''`
- Never skip when using the special `CI:ALL` title: `$CIRRUS_CHANGE_TITLE =~ '.*CI:ALL.*'`, see below.
- Never skip when a danger file is changed, these files contain things that can
affect any tasks so the code cannot skip it. It includes
- `.cirrus.yml` (cirrus changes)
- `Makefile` (make targets are used to trigger tests)
- `hack/ci/**` (cirrus scripts to run the tests)
- `vendor/**` (dependency updates)
- `test/tools/**` (test dependency code, i.e. ginkgo)
- `hack/**` (contains scripts used by several tests)
- `version/rawversion/*` (podman version changes, intended to ensure all release PRs test everything to not release known broken code)
After that, task-specific rules are added, check [.cirrus.yml](../../.cirrus.yml) for them.
Another common rule used there is `(changesInclude('**/*.go', '**/*.c', '**/*.h') && !changesIncludeOnly('test/**', 'pkg/machine/e2e/**'))`.
This rule defines the set of source code. Podman uses both go and c source code (including header files),
however as some tests are also using go code we manually exclude the test
directories from this list.
### Intended `[CI:ALL]` behavior:
As of June 2024, the default Cirrus CI setup skips tasks that it deems
unnecessary, such as running e2e or system tests on a doc-only PR (see
#23174). This string in a PR title forces all CI jobs to run.
### Intended `[CI:NEXT]` behavior:
If and only if the PR is in **draft-mode**, update Fedora CI VMs at runtime
to the latest packages available in the podman-next COPR repo. These packages
represent primary podman dependencies, and are regularly built from their
upstream repos. These are **runtime changes** only, and will not persist
or impact other PRs in any way.
The intent is to temporarily support testing of updates with the latest podman
code & tests. To help prevent accidents, when the PR is not in draft-mode, the
presence of the magic string will cause VM-setup script to fail, until the magic
is removed.
**Note:** When changing the draft-status of PR, you will need to re-push a
commit-change before Cirrus-CI will notice the draft-status update (i.e.
pressing the re-run button **is not** good enough).

View file

@ -1,193 +0,0 @@
#!/bin/bash
#
# tests for lib.sh
#
# To ensure consistent sorting
export LC_ALL=C
###############################################################################
# BEGIN code to define a clean safe environment
# Envariables which we should keep; anything else, we toss.
declare -a keep_env_list=(IFS HOME PATH SECRET_ENV_RE
PASSTHROUGH_ENV_EXACT
PASSTHROUGH_ENV_ATSTART
PASSTHROUGH_ENV_ANYWHERE
PASSTHROUGH_ENV_RE
TMPDIR tmpdir keep_env rc_file testnum_file)
declare -A keep_env
for i in "${keep_env_list[@]}"; do
keep_env[$i]=1
done
# END code to define a clean safe environment
###############################################################################
# BEGIN test scaffolding
tmpdir=$(mktemp --tmpdir --directory lib-sh-tests.XXXXXXX)
# shellcheck disable=SC2154
trap 'status=$?; rm -rf $tmpdir;exit $status' 0
# Needed by lib.sh, but we don't actually need anything in it
touch "$tmpdir"/common_lib.sh
# Iterator and return code. Because some tests run in subshells (to avoid
# namespace pollution), variables aren't preserved. Use files to track them.
testnum_file=$tmpdir/testnum
rc_file=$tmpdir/rc
echo 0 >"$testnum_file"
echo 0 >"$rc_file"
# Helper function: runs passthrough_envars(), compares against expectations
function check_passthrough {
testnum=$(< "$testnum_file")
testnum=$((testnum + 1))
echo $testnum > "$testnum_file"
# shellcheck disable=SC2046,SC2005,SC2116
actual="$(echo $(passthrough_envars))"
if [[ "$actual" = "$1" ]]; then
# Multi-level echo flattens newlines, makes success messages readable
# shellcheck disable=SC2046,SC2005,SC2116
echo $(echo "ok $testnum $2")
else
echo "not ok $testnum $2"
echo "# expected: $1"
echo "# actual: $actual"
echo 1 >| "$rc_file"
fi
}
# END test scaffolding
###############################################################################
# vars and a function needed by lib.sh
# shellcheck disable=SC2034
{
AUTOMATION_LIB_PATH=$tmpdir
CIRRUS_BASE_SHA=x
CIRRUS_TAG=x
function warn() {
:
}
# shellcheck disable=all
source $(dirname "$0")/lib.sh
}
# Our environment is now super-polluted. Clean it up, preserving critical env.
while read -r v;do
if [[ -z "${keep_env[$v]}" ]]; then
unset "$v" 2>/dev/null
fi
done < <(compgen -A variable)
# begin actual tests
check_passthrough "" "with empty environment"
#
# Now set all sorts of secrets, which should be excluded
#
# shellcheck disable=SC2034
{
ACCOUNT_ABC=1
ABC_ACCOUNT=1
ABC_ACCOUNT_DEF=1
GCEFOO=1
GCPBAR=1
SSH123=1
NOTSSH=1
SSH=1
PASSWORD=1
MYSECRET=1
SECRET2=1
TOKEN=1
check_passthrough "" "secrets are filtered"
}
# These are passed through only when they match EXACTLY.
readarray -d '|' -t pt_exact <<<"$PASSTHROUGH_ENV_EXACT"
# shellcheck disable=SC2048
for s in ${pt_exact[*]}; do
# Run inside a subshell, to avoid cluttering environment
(
eval "${s}=1" # This is the only one that should be passed
eval "a${s}=1"
eval "${s}z=1"
eval "YYY_${s}_YYY=1"
eval "ZZZ_${s}=1"
eval "${s}_ZZZ=1"
# Only the exact match should be passed
check_passthrough "$s" "exact match only: $s"
)
done
# These are passed through only when they match AT THE BEGINNING.
#
# Also, we run this _entire_ test inside a subshell, cluttering the
# environment, so we're testing that passthrough_envars can handle
# and return long lists of unrelated matches. Kind of a pointless
# test, there's not really any imaginable way that could fail.
(
# Inside the subshell. Start with null expectations.
expect=
# WARNING! $PASSTHROUGH_ENV_ATSTART must be in alphabetical order,
# because passthrough_envars always returns a sorted list and (see
# subshell comments above) we're incrementally adding to our env.
readarray -d '|' -t pt_atstart <<<"$PASSTHROUGH_ENV_ATSTART"
# shellcheck disable=SC2048
for s in ${pt_atstart[*]}; do
eval "${s}=1"
eval "${s}123=1"
eval "NOPE_${s}=1"
eval "NOR_${s}_EITHER=1"
if [[ -n "$expect" ]]; then
expect+=" "
fi
expect+="$s ${s}123"
check_passthrough "$expect" "at start only: $s"
done
)
# These are passed through if they match ANYWHERE IN THE NAME
readarray -d '|' -t pt_anywhere <<<"$PASSTHROUGH_ENV_ANYWHERE"
# shellcheck disable=SC2048
for s in ${pt_anywhere[*]}; do
(
eval "${s}=1"
eval "${s}z=1"
eval "z${s}=1"
eval "z${s}z=1"
check_passthrough "${s} ${s}z z${s} z${s}z" "anywhere: $s"
)
done
# And, to guard against null runs of the above loops, hardcoded tests of each:
# shellcheck disable=SC2034
(
CI=1
CI_FOO=1
CIRRUS_BAR=1
GOPATH=gopath
GOPATH_NOT=not
ROOTLESS_USER=rootless
ZZZ_NAME=1
check_passthrough "CI CIRRUS_BAR CI_FOO GOPATH ROOTLESS_USER ZZZ_NAME" \
"final handcrafted sanity check"
)
# Final check
check_passthrough "" "Environment remains unpolluted at end"
# Done
# shellcheck disable=all
exit $(<"$rc_file")

View file

@ -1,38 +0,0 @@
#!/bin/bash
# This script is intended to be called by Cirrus-CI on a Mac M1 persistent worker.
# It performs a best-effort attempt at cleaning up from one task execution to the next.
# Since it run both before and after tasks, it must exit cleanly if there was a cleanup
# failure (i.e. file or directory not found).
# Help anybody debugging side-effects, since failures are ignored (by necessity).
set +e -x
# These are the main processes which could leak out of testing.
killall podman vfkit gvproxy make go ginkgo
# Golang will leave behind lots of read-only bits, ref:
# https://go.dev/ref/mod#module-cache
# However other tools/scripts could also set things read-only.
# At this point in CI, we really want all this stuff gone-gone,
# so there's actually zero-chance it can interfere.
chmod -R u+w /private/tmp/ci/* /private/tmp/ci/.??*
# This is defined as $TMPDIR during setup. Name must be kept
# "short" as sockets may reside here. Darwin suffers from
# the same limited socket-pathname character-length restriction
# as Linux.
rm -rf /private/tmp/ci/* /private/tmp/ci/.??*
# Don't change or clobber anything under $CIRRUS_WORKING_DIR for
# the currently running task. But make sure we have write permission
# (go get sets dependencies ro) for everything else, before removing it.
# First make everything writeable - see the "Golang will..." comment above.
# shellcheck disable=SC2154
find "${ORIGINAL_HOME:-$HOME}/ci" -mindepth 1 -maxdepth 1 \
-not -name "*task-${CIRRUS_TASK_ID}*" -prune -exec chmod -R u+w '{}' +
find "${ORIGINAL_HOME:-$HOME}/ci" -mindepth 1 -maxdepth 1 \
-not -name "*task-${CIRRUS_TASK_ID}*" -prune -exec rm -rf '{}' +
# Bash scripts exit with the status of the last command.
true

View file

@ -1,29 +0,0 @@
#!/bin/bash
set -euo pipefail
# This script is intended to be called by Cirrus-CI on a Mac M1 persistent worker.
# It runs /after/ `mac_setup.sh` to help developers debug any environment
# related issues. It must not make any actually changes to the environment.
# Many variables can affect operations, make them all known to assist debugging.
echo "Selection of current env. vars:"
for env_var_name in $(awk 'BEGIN{for(v in ENVIRON) print v}' | grep -Eiv '(^PATH$)|(^BASH_FUNC)|(^_.*)' | sort)
do
echo " ${env_var_name}=${!env_var_name}"
done
# The latest toolchain is always installed when instances are created. Make it known
# what version that actually is.
go version
# Golang is sensitive to a collection of key variables. Make them known to assist
# with any debugging. N/B: Most filepath values should point somewhere under $HOME/ci/
go env
# The latest version is installed system-wide when instances are created. Make the
# current version known.
vfkit --version
# Make the current version of krunkit known.
krunkit --version

View file

@ -1,46 +0,0 @@
#!/bin/bash
#
# This script is what runs mac tests. It is invoked from .cirrus.yml
#
# Yep, some of this is adapted from runner.sh. We can't actually
# use that as a library, because Macintosh bash and awk lack
# features we need.
set -euo pipefail
# Name pattern for logformatter output file, derived from environment
function output_name() {
# .cirrus.yml defines this as a short readable string for web UI
std_name_fmt=$(sed -ne 's/^.*std_name_fmt \"\(.*\)\"/\1/p' <.cirrus.yml)
test -n "$std_name_fmt" || die "Could not grep 'std_name_fmt' from .cirrus.yml"
# Interpolate envariables. 'set -u' throws fatal if any are undefined
(
set -u
eval echo "$std_name_fmt" | tr ' ' '-'
)
}
function logformatter() {
# Mac awk barfs on this, syntax error
# awk --file "${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/timestamp.awk" \
# shellcheck disable=SC2154
"${CIRRUS_WORKING_DIR}/${SCRIPT_BASE}/logformatter" "$(output_name)"
}
# Defined by .cirrus.yml
# shellcheck disable=SC2154
case "$TEST_FLAVOR" in
machine-applehv)
export CONTAINERS_MACHINE_PROVIDER="applehv"
;;
machine-libkrun)
export CONTAINERS_MACHINE_PROVIDER="libkrun"
;;
*)
echo "Unknown/unsupported \$TEST_FLAVOR value '$TEST_FLAVOR'."
exit 1
esac
make localmachine 2>&1 | logformatter

View file

@ -1,53 +0,0 @@
#!/bin/bash
# This script is intended to be called by Cirrus-CI on a Mac M1 persistent worker.
# It runs after the preparatory `mac_cleanup.sh` to performs all the user-level
# environment setup required to execute testing. It assumes whatever system-wide
# setup is required, has already happened and was successful.
set -euo pipefail
# Confirm rosetta is installed/enabled and working
if ! arch -arch x86_64 /usr/bin/uname -m; then
# This likely means whatever script used to prepare this mac failed
# and/or did not execute `sudo softwareupdate --install-rosetta --agree-to-license`
echo "Rosetta doesn't appear to be installed, or is non-functional."
exit 1
fi
# The otherwise standard `/etc/ci_environment` file cannot be used in this
# context, because the system is shared for multiple tasks. Instead, persist
# env. vars required during /subsequent/ testing steps via a "magic" Cirrus-CI
# mechanism. These cannot be set in the task YAML because they would interfere
# with repo. cloning and task preparation.
# Ref:
# https://cirrus-ci.org/guide/tips-and-tricks/#setting-environment-variables-from-scripts
# Tests expect to call compiled binaries first, make sure they're found first.
# shellcheck disable=SC2154
echo "PATH=$CIRRUS_WORKING_DIR/bin/darwin:$PATH" >> $CIRRUS_ENV
# Post-task cleanup needs to know the actual user home directory
# shellcheck disable=SC2154
echo "ORIGINAL_HOME=$HOME" >> $CIRRUS_ENV
# Help isolate CI-operations from system-operations and simplify task cleanup.
# shellcheck disable=SC2154
echo "HOME=$HOME/ci" >> $CIRRUS_ENV
# shellcheck disable=SC2154
echo "TMPDIR=/private/tmp/ci" >> $CIRRUS_ENV
# Removed completely during cleanup.
mkdir -p /private/tmp/ci
# Add policy.json
mkdir -p $HOME/ci/.config/containers
cp pkg/machine/ocipull/policy.json /$HOME/ci/.config/containers/
# Some test operations & checks require a git "identity"
# N/B: $HOME in this context does not include the /ci part automatically
# (see above) but it will when the next Cirrus-CI "_script" section
# takes over.
git config --file "$HOME/ci/.gitconfig" \
--add safe.directory $CIRRUS_WORKING_DIR

View file

@ -1,42 +0,0 @@
#!/bin/bash
set -eo pipefail
# shellcheck source=hack/ci/lib.sh
source $(dirname $0)/lib.sh
# Skip this entire script when run under nightly treadmill cron job.
#
# Treadmill vendors in containers/<many>, which may bring in new versions
# of other dependencies such as cobra, which may change the completion
# files, which gives us a failure that we don't care one whit about.
# The purpose of the treadmill is to check for incompatibilities with
# other closely-tied container modules.
# shellcheck disable=SC2154
if [[ "$CIRRUS_CRON" = "treadmill" ]]; then
echo "[in treadmill; skipping $(basename $0)]"
exit 0
fi
# This script attempts to confirm all included go modules from
# other sources match what is expected in `vendor/modules.txt`
# vs `go.mod`. Also make sure that the generated bindings in
# `pkg/bindings/...` are in sync with the code. It's intended
# for use after successfully building podman, to prevent wasting
# time on tests that might otherwise succeed with bad/ugly/invalid
# code.
source /etc/automation_environment
source $AUTOMATION_LIB_PATH/common_lib.sh
# Defined by the CI system
# shellcheck disable=SC2154
cd $CIRRUS_WORKING_DIR
# Note, make completions and make vendor will already be run in _run_build()
# so do not run them again for no reason. This just makes CI slower.
showrun make -C test/tools vendor
SUGGESTION="run 'make vendor', 'make -C test/tools vendor' and 'make completions' and commit all changes" ./hack/tree_status.sh
showrun make generate-bindings
SUGGESTION="run 'make generate-bindings' and commit all changes" ./hack/tree_status.sh

View file

@ -1,68 +0,0 @@
#!/bin/bash
set -eo pipefail
# This script attempts to confirm functional networking and
# connectivity to essential external servers. It also verifies
# some basic environmental expectations and shell-script sanity.
# It's intended for use early on in the podman CI system, to help
# prevent wasting time on tests that can't succeed due to some
# outage, failure, or missed expectation.
set -a
source /etc/automation_environment
source $AUTOMATION_LIB_PATH/common_lib.sh
# shellcheck source=hack/ci/lib.sh
source $(dirname $0)/lib.sh
set +a
req_env_vars CI DEST_BRANCH IMAGE_SUFFIX TEST_FLAVOR TEST_ENVIRON \
PODBIN_NAME PRIV_NAME DISTRO_NV AUTOMATION_LIB_PATH \
SCRIPT_BASE CIRRUS_WORKING_DIR FEDORA_NAME \
VM_IMAGE_NAME
# Defined by the CI system
# shellcheck disable=SC2154
cd $CIRRUS_WORKING_DIR
msg "Checking Cirrus YAML"
# Defined by CI config.
# shellcheck disable=SC2154
showrun $SCRIPT_BASE/cirrus_yaml_test.py
msg "Checking for leading tabs in system tests"
if grep -n ^$'\t' test/system/*; then
die "Found leading tabs in system tests. Use spaces to indent, not tabs."
fi
# Only need to check CI-stuffs on a single build-task, there's
# generally one latest fedora task so use that one. In some cases
# when we have to drop testing for the prior fedora task we may
# run twice on current fedora but this is not a problem.
# Envars all defined by CI config.
# shellcheck disable=SC2154
if [[ "${DISTRO_NV}" == "$FEDORA_NAME" ]]; then
msg "Checking shell scripts"
showrun shellcheck --format=tty \
--shell=bash --external-sources \
--enable add-default-case,avoid-nullary-conditions,check-unassigned-uppercase \
--exclude SC2046,SC2034,SC2090,SC2064 \
--wiki-link-count=0 --severity=warning \
$SCRIPT_BASE/*.sh \
./.github/actions/check_cirrus_cron/* \
hack/get_ci_vm.sh
# Tests for lib.sh
showrun ${SCRIPT_BASE}/lib.sh.t
# Run this during daily cron job to prevent a GraphQL API change/breakage
# from impacting every PR. Down-side being if it does fail, a maintainer
# will need to do some archaeology to find it.
# Defined by CI system
# shellcheck disable=SC2154
if [[ "$CIRRUS_CRON" == "main" ]]; then
export PREBUILD=1
showrun bash ${CIRRUS_WORKING_DIR}/.github/actions/check_cirrus_cron/test.sh
fi
fi

View file

@ -1,466 +0,0 @@
#!/usr/bin/env bash
# This script is intended to be executed early by automation before
# performing other substantial operations. It relies heavily on
# desired setup information being passed in environment variables
# from Cirrus-CI and/or other orchestration tooling. To that end,
# VM's must always be considered single-purpose, single-use,
# disposable entities. i.e. One setup, one test, then always discarded.
set -e
# shellcheck source=./hack/ci/lib.sh
source $(dirname $0)/lib.sh
showrun echo "starting"
die_unknown() {
local var_name="$1"
req_env_vars var_name
local var_value="${!var_name}"
die "Unknown/unsupported \$$var_name '$var_value'"
}
msg "************************************************************"
msg "Setting up runtime environment"
msg "************************************************************"
show_env_vars
req_env_vars USER HOME GOSRC SCRIPT_BASE TEST_FLAVOR TEST_ENVIRON \
PODBIN_NAME PRIV_NAME DISTRO_NV DEST_BRANCH
# Verify basic dependencies
for depbin in go rsync unzip sha256sum curl make python3 git
do
if ! type -P "$depbin" &> /dev/null
then
warn "$depbin binary not found in $PATH"
fi
done
# Bypass git safety/security checks when operating in a throwaway environment
showrun git config --global --add safe.directory $GOSRC
# Special case: "composefs" is not a valid setting but it's useful for
# readability in .cirrus.yml. Here we translate that to overlayfs (the
# actual filesystem) along with extra magic envariables.
# Be sure to do this before writing /etc/ci_environment.
export CI_DESIRED_COMPOSEFS=
# shellcheck disable=SC2154
if [[ "$CI_DESIRED_STORAGE" = "composefs" ]]; then
CI_DESIRED_STORAGE="overlay"
# composefs is root only
if [[ "$PRIV_NAME" == "root" ]]; then
CI_DESIRED_COMPOSEFS="+composefs"
# KLUDGE ALERT! Magic options needed for testing composefs.
# This option was intended for passing one arg to --storage-opt
# but we're hijacking it to pass an extra option+arg. And it
# actually works.
export STORAGE_OPTIONS_OVERLAY='overlay.use_composefs=true --pull-option=enable_partial_images=true --pull-option=convert_images=true'
fi
fi
# Ensure that all lower-level contexts and child-processes have
# ready access to higher level orchestration (e.g Cirrus-CI)
# variables.
echo -e "\n# Begin single-use VM global variables (${BASH_SOURCE[0]})" \
> "/etc/ci_environment"
(
while read -r env_var; do
printf -- "%s=%q\n" "${env_var}" "${!env_var}"
done <<<"$(passthrough_envars)"
) >> "/etc/ci_environment"
# This is a possible manual maintenance gaff, i.e. forgetting to update a
# *_NAME variable in .cirrus.yml. check to be sure at least one comparison
# matches the actual OS being run. Ignore details, such as debian point-release
# number and/or '-aarch64' suffix.
# shellcheck disable=SC2154
grep -q "$DISTRO_NV" <<<"$OS_REL_VER" || \
grep -q "$OS_REL_VER" <<<"$DISTRO_NV" || \
grep -q "rawhide" <<<"$DISTRO_NV" || \
die "Automation spec. '$DISTRO_NV'; actual host '$OS_REL_VER'"
# Only allow this script to execute once
if ((${SETUP_ENVIRONMENT:-0})); then
# Comes from automation library
# shellcheck disable=SC2154
warn "Not executing $SCRIPT_FILENAME again"
exit 0
fi
cd "${GOSRC}/"
mkdir -p /etc/containers/containers.conf.d
# Only cgroups v2 is supported, die if anything else.
[[ "$CG_FS_TYPE" == "cgroup2fs" ]] || \
die "Only cgroups v2 CI VMs are supported, not: '$CG_FS_TYPE'"
if ((CONTAINER==0)); then # Not yet running inside a container
showrun echo "conditional setup for CONTAINER == 0"
# Discovered reemergence of BFQ scheduler bug in kernel 5.8.12-200
# which causes a kernel panic when system is under heavy I/O load.
# Disable the I/O scheduler (a.k.a. elevator) for all environments,
# leaving optimization up to underlying storage infrastructure.
testfs="/" # mountpoint that experiences the most I/O during testing
msg "Querying block device owning partition hosting the '$testfs' filesystem"
# Need --nofsroot b/c btrfs appends subvolume label to `source` name
testdev=$(findmnt --canonicalize --noheadings --nofsroot \
--output source --mountpoint $testfs)
msg " found partition: '$testdev'"
testdisk=$(lsblk --noheadings --output pkname --paths $testdev)
msg " found block dev: '$testdisk'"
testsched="/sys/block/$(basename $testdisk)/queue/scheduler"
if [[ -n "$testdev" ]] && [[ -n "$testdisk" ]] && [[ -e "$testsched" ]]; then
msg " Found active I/O scheduler: $(cat $testsched)"
if [[ ! "$(<$testsched)" =~ \[none\] ]]; then
msg " Disabling elevator for '$testsched'"
echo "none" > "$testsched"
else
msg " Elevator already disabled"
fi
else
warn "Sys node for elevator doesn't exist: '$testsched'"
fi
fi
# Which distribution are we testing on.
case "$OS_RELEASE_ID" in
debian)
showrun echo "No-op conditional setup for debian"
;;
fedora)
showrun echo "conditional setup for fedora"
if ((CONTAINER==0)); then
# All SELinux distros need this for systemd-in-a-container
msg "Enabling container_manage_cgroup"
showrun setsebool container_manage_cgroup true
fi
;;
*) die_unknown OS_RELEASE_ID
esac
# Force the requested storage driver for both system and e2e tests.
# This is (sigh) different because e2e tests have their own special way
# of ignoring system defaults.
# shellcheck disable=SC2154
showrun echo "Setting CI_DESIRED_STORAGE [=$CI_DESIRED_STORAGE$CI_DESIRED_COMPOSEFS] for *system* tests"
conf=/etc/containers/storage.conf
if [[ -e $conf ]]; then
die "FATAL! INTERNAL ERROR! Cannot override $conf"
fi
cat <<EOF >$conf
[storage]
driver = "$CI_DESIRED_STORAGE"
EOF
if [[ -n "$CI_DESIRED_COMPOSEFS" ]]; then
# composefs only works as root so we must set it in the rootful config
mkdir /etc/containers/storage.rootful.conf.d/
conf=/etc/containers/storage.rootful.conf.d/99-composefs.conf
cat <<EOF >>$conf
# BEGIN CI-enabled composefs
[storage.options]
pull_options = {enable_partial_images = "true", use_hard_links = "false", ostree_repos="", convert_images = "true"}
[storage.options.overlay]
use_composefs = "true"
# END CI-enabled composefs
EOF
fi
# mount a tmpfs for the container storage to speed up the IO
# side effect is we clear all potentially pre existing data so we know we always start "clean"
mount -t tmpfs -o size=75%,mode=0700 none /var/lib/containers
# shellcheck disable=SC2154
showrun echo "Setting CI_DESIRED_STORAGE [=$CI_DESIRED_STORAGE] for *e2e* tests"
echo "STORAGE_FS=$CI_DESIRED_STORAGE" >>/etc/ci_environment
if ((CONTAINER==0)); then # not yet inside a container
# Load null_blk to use /dev/nullb0 for testing block
# devices limits
modprobe null_blk nr_devices=1 || :
fi
# Required to be defined by caller: The environment where primary testing happens
# shellcheck disable=SC2154
showrun echo "about to set up for TEST_ENVIRON [=$TEST_ENVIRON]"
case "$TEST_ENVIRON" in
host)
# The e2e tests wrongly guess `--cgroup-manager` option
# under some runtime contexts like rootless.
# shellcheck disable=SC2154
if [[ "$CG_FS_TYPE" == "cgroup2fs" ]] || [[ "$PRIV_NAME" == "root" ]]
then
warn "Forcing CGROUP_MANAGER=systemd"
echo "CGROUP_MANAGER=systemd" >> /etc/ci_environment
else
warn "Forcing CGROUP_MANAGER=cgroupfs"
echo "CGROUP_MANAGER=cgroupfs" >> /etc/ci_environment
fi
;;
container)
if ((CONTAINER==0)); then # not yet inside a container
warn "Force loading iptables modules"
# Since CRIU 3.11, uses iptables to lock and unlock
# the network during checkpoint and restore. Needs
# the following two modules loaded on the host.
modprobe ip6table_nat || :
modprobe iptable_nat || :
else
warn "Forcing CGROUP_MANAGER=cgroupfs"
echo "CGROUP_MANAGER=cgroupfs" >> /etc/ci_environment
# There's no practical way to detect userns w/in a container
# affected/related tests are sensitive to this variable.
warn "Disabling usernamespace integration testing"
echo "SKIP_USERNS=1" >> /etc/ci_environment
# In F35 the hard-coded default
# (from containers-common-1-32.fc35.noarch) is 'journald' despite
# the upstream repository having this line commented-out.
# Containerized integration tests cannot run with 'journald'
# as there is no daemon/process there to receive them.
cconf="/usr/share/containers/containers.conf"
note="- commented-out by setup_environment.sh"
if grep -Eq '^log_driver.+journald' "$cconf"; then
warn "Patching out $cconf journald log_driver"
sed -r -i -e "s/^log_driver(.*)/# log_driver\1 $note/" "$cconf"
fi
fi
;;
*) die_unknown TEST_ENVIRON
esac
# Required to be defined by caller: Are we testing as root or a regular user
showrun echo "about to set up for PRIV_NAME [=$PRIV_NAME]"
case "$PRIV_NAME" in
root)
# shellcheck disable=SC2154
if [[ "$TEST_FLAVOR" = "sys" || "$TEST_FLAVOR" = "apiv2" ]]; then
# Used in local image-scp testing
setup_rootless
echo "PODMAN_ROOTLESS_USER=$ROOTLESS_USER" >> /etc/ci_environment
echo "PODMAN_ROOTLESS_UID=$ROOTLESS_UID" >> /etc/ci_environment
fi
;;
rootless)
# load kernel modules since the rootless user has no permission to do so
modprobe ip6_tables || :
modprobe ip6table_nat || :
setup_rootless
;;
*) die_unknown PRIV_NAME
esac
# Root user namespace
for which in uid gid;do
if ! grep -qE '^containers:' /etc/sub$which; then
echo 'containers:10000000:1048576' >>/etc/sub$which
fi
done
# FIXME! experimental workaround for #16973, the "lookup cdn03.quay.io" flake.
#
# If you are reading this on or after April 2023:
# * If we're NOT seeing the cdn03 flake any more, well, someone
# should probably figure out how to fix systemd-resolved, then
# remove this workaround.
#
# * If we're STILL seeing the cdn03 flake, well, this "fix"
# didn't work and should be removed.
#
# Either way, this block of code should be removed after March 31 2023
# because it creates a system that is not representative of real-world Fedora.
#
# 2024-01-25 update: ha ha. This fix has proven so popular that it is
# being used by other groups who were seeing the cdn03 flake. Looks like
# we're stuck with it.
if ((CONTAINER==0)); then
nsswitch=/etc/authselect/nsswitch.conf
if [[ -e $nsswitch ]]; then
if grep -q -E 'hosts:.*resolve' $nsswitch; then
showrun echo "Disabling systemd-resolved"
sed -i -e 's/^\(hosts: *\).*/\1files dns myhostname/' $nsswitch
systemctl stop systemd-resolved
rm -f /etc/resolv.conf
# NetworkManager may already be running, or it may not....
systemctl start NetworkManager
sleep 1
systemctl restart NetworkManager
# ...and it may create resolv.conf upon start/restart, or it
# may not. Keep restarting until it does. (Yes, I realize
# this is cargocult thinking. Don't care. Not worth the effort
# to diagnose and solve properly.)
retries=10
while ! test -e /etc/resolv.conf;do
retries=$((retries - 1))
if [[ $retries -eq 0 ]]; then
die "Timed out waiting for resolv.conf"
fi
systemctl restart NetworkManager
sleep 5
done
fi
fi
fi
# Required to be defined by caller: Are we testing podman or podman-remote client
# shellcheck disable=SC2154
case "$PODBIN_NAME" in
podman) ;;
remote) ;;
*) die_unknown PODBIN_NAME
esac
# As of July 2024, CI VMs come built-in with a registry.
LCR=/var/cache/local-registry/local-cache-registry
if [[ -x $LCR ]]; then
# Images in cache registry are prepopulated at the time
# VMs are built. If any PR adds a dependency on new images,
# those must be fetched now, at VM start time. This should
# be rare, and must be fixed in next automation_images build.
while read new_image; do
$LCR cache $new_image
done < <(grep '^[^#]' test/NEW-IMAGES || true)
fi
# Required to be defined by caller: The primary type of testing that will be performed
# shellcheck disable=SC2154
showrun echo "about to set up for TEST_FLAVOR [=$TEST_FLAVOR]"
case "$TEST_FLAVOR" in
validate-source)
# NOOP
;;
altbuild)
# Defined in .cirrus.yml
# shellcheck disable=SC2154
if [[ "$ALT_NAME" =~ RPM ]]; then
showrun bigto dnf install -y glibc-minimal-langpack go-rpm-macros rpkg rpm-build shadow-utils-subid-devel
fi
;;
docker-py)
remove_packaged_podman_files
showrun make install PREFIX=/usr ETCDIR=/etc
virtualenv .venv/docker-py
source .venv/docker-py/bin/activate
showrun pip install --upgrade pip
showrun pip install --requirement $GOSRC/test/python/requirements.txt
;;
build) make clean ;;
unit)
showrun make .install.ginkgo
;;
compose_v2)
showrun dnf -y remove docker-compose
showrun curl --fail -SL https://github.com/docker/compose/releases/download/v2.32.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
showrun chmod +x /usr/local/bin/docker-compose
;& # Continue with next item
apiv2)
msg "Installing previously downloaded/cached packages"
virtualenv .venv/requests
source .venv/requests/bin/activate
showrun pip install --upgrade pip
showrun pip install --requirement $GOSRC/test/apiv2/python/requirements.txt
;& # continue with next item
int)
showrun make .install.ginkgo
;&
sys)
# when run nightly check for system test leaks
# shellcheck disable=SC2154
if [[ "$CIRRUS_CRON" != '' ]]; then
export PODMAN_BATS_LEAK_CHECK=1
fi
;&
upgrade_test) ;&
bud) ;&
bindings) ;&
endpoint)
showrun echo "Entering shared endpoint setup"
# Use existing host bits when testing is to happen inside a container
# since this script will run again in that environment.
# shellcheck disable=SC2154
if [[ "$TEST_ENVIRON" =~ host ]]; then
if ((CONTAINER)); then
die "Refusing to config. host-test in container";
fi
remove_packaged_podman_files
make install PREFIX=/usr ETCDIR=/etc EXTRA_BUILDTAGS="$TEST_BUILD_TAGS"
elif [[ "$TEST_ENVIRON" == "container" ]]; then
if ((CONTAINER)); then
remove_packaged_podman_files
make install PREFIX=/usr ETCDIR=/etc EXTRA_BUILDTAGS="$TEST_BUILD_TAGS"
fi
else
die "Invalid value for \$TEST_ENVIRON=$TEST_ENVIRON"
fi
install_test_configs
;;
farm)
showrun loginctl enable-linger $ROOTLESS_USER
showrun ssh $ROOTLESS_USER@localhost systemctl --user enable --now podman.socket
remove_packaged_podman_files
showrun make install PREFIX=/usr ETCDIR=/etc
install_test_configs
;;
machine-linux)
showrun dnf install -y podman-gvproxy* virtiofsd
# Bootstrap this link if it isn't yet in the package; xref
# https://github.com/containers/podman/pull/22920
if ! test -L /usr/libexec/podman/virtiofsd; then
showrun ln -sfr /usr/libexec/virtiofsd /usr/libexec/podman/virtiofsd
fi
remove_packaged_podman_files
showrun make install PREFIX=/usr ETCDIR=/etc
# machine-os image changes too frequently, can't use image cache
install_test_configs nocache
;;
swagger)
showrun make .install.swagger
;;
release) ;;
*) die_unknown TEST_FLAVOR
esac
# See ./hack/ci/CIModes.md.
# Vars defined by cirrus-ci
# shellcheck disable=SC2154
if [[ ! "$OS_RELEASE_ID" =~ "debian" ]] && \
[[ "$CIRRUS_CHANGE_TITLE" =~ CI:NEXT ]]
then
showrun echo "Entering setup for CI:NEXT"
# shellcheck disable=SC2154
if [[ "$CIRRUS_PR_DRAFT" != "true" ]]; then
die "Magic 'CI:NEXT' string can only be used on DRAFT PRs"
fi
showrun dnf copr enable rhcontainerbot/podman-next -y
# DNF ignores repos that don't exist. For example, updates-testing is not
# enabled on Fedora N-1 CI VMs. Don't updated everything, isolate just the
# podman-next COPR updates.
showrun dnf update -y \
"--enablerepo=copr:copr.fedorainfracloud.org:rhcontainerbot:podman-next" \
"--disablerepo=copr:copr.fedorainfracloud.org:sbrivio:passt" \
"--disablerepo=fedora*" "--disablerepo=updates*"
fi
# Must be the very last command. Prevents setup from running twice.
echo 'SETUP_ENVIRONMENT=1' >> /etc/ci_environment
echo -e "\n# End of global variable definitions" \
>> /etc/ci_environment
msg "Global CI Environment vars.:"
grep -Ev '^#' /etc/ci_environment | sort | indent
showrun echo "finished"

View file

@ -1,20 +0,0 @@
# This script is intended to be piped into by automation, in order to
# mark output lines with timing information. For example:
# /path/to/command |& awk --file timestamp.awk
BEGIN {
STARTTIME=systime()
printf "[%s] START", strftime("%T")
printf " - All [+xxxx] lines that follow are relative to %s.\n", strftime("%FT%TZ", systime(), 1)
}
{
printf "[%+05ds] %s\n", systime()-STARTTIME, $0
}
END {
printf "[%s] END", strftime("%T")
printf " - [%+05ds] total duration since %s\n", systime()-STARTTIME, strftime("%FT%TZ", systime(), 1)
}

View file

@ -1,108 +0,0 @@
# MIT License
#
# Copyright (c) Microsoft Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE
# This script is an adapted version of
# https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1
#Requires -RunAsAdministrator
[CmdletBinding()]
Param (
$LogProfile = $null
)
Set-StrictMode -Version Latest
$folder = "WslLogs" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss")
mkdir -p $folder | Out-Null
if ($LogProfile -eq $null -Or ![System.IO.File]::Exists($LogProfile))
{
if ($LogProfile -eq $null)
{
$url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp"
}
elseif ($LogProfile -eq "storage")
{
$url = "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_storage.wprp"
}
else
{
Write-Error "Unknown log profile: $LogProfile"
exit 1
}
$LogProfile = "$folder/wsl.wprp"
try {
Invoke-WebRequest -UseBasicParsing $url -OutFile $LogProfile
}
catch {
throw
}
}
reg.exe export HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKCU.txt 2>&1 | Out-Null
reg.exe export HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Lxss $folder/HKLM.txt 2>&1 | Out-Null
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\P9NP $folder/P9NP.txt 2>&1 | Out-Null
reg.exe export HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WinSock2 $folder/Winsock2.txt 2>&1 | Out-Null
# Skipping the next reg.exe command because it's failing with error
# "ERROR: The system was unable to find the specified registry key or value"
# on the CI server (Windows Server 2022)
# reg.exe export "HKEY_CLASSES_ROOT\CLSID\{e66b0f30-e7b4-4f8c-acfd-d100c46c6278}" $folder/wslsupport-proxy.txt 2>&1 | Out-Null
reg.exe export "HKEY_CLASSES_ROOT\CLSID\{a9b7a1b9-0671-405c-95f1-e0612cb4ce7e}" $folder/wslsupport-impl.txt 2>&1 | Out-Null
Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" > $folder/windows-version.txt
Get-Service wslservice -ErrorAction Ignore | Format-list * -Force > $folder/wslservice.txt
$wslconfig = "$env:USERPROFILE/.wslconfig"
if (Test-Path $wslconfig)
{
Copy-Item $wslconfig $folder | Out-Null
}
get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux -ErrorAction Ignore > $folder/appxpackage.txt
get-acl "C:\ProgramData\Microsoft\Windows\WindowsApps" -ErrorAction Ignore | Format-List > $folder/acl.txt
Get-WindowsOptionalFeature -Online > $folder/optional-components.txt
bcdedit.exe > $folder/bcdedit.txt
$uninstallLogs = "$env:TEMP/wsl-uninstall-logs.txt"
if (Test-Path $uninstallLogs)
{
Copy-Item $uninstallLogs $folder | Out-Null
}
$wprOutputLog = "$folder/wpr.txt"
wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
if ($LastExitCode -Ne 0)
{
Write-Host -ForegroundColor Yellow "Log collection failed to start (exit code: $LastExitCode), trying to reset it."
wpr.exe -cancel 2>&1 >> $wprOutputLog
wpr.exe -start $LogProfile -filemode 2>&1 >> $wprOutputLog
if ($LastExitCode -Ne 0)
{
Write-Host -ForegroundColor Red "Couldn't start log collection (exitCode: $LastExitCode)"
}
}
Write-Host "`nWSL Log collection is running."

View file

@ -1,45 +0,0 @@
# MIT License
#
# Copyright (c) Microsoft Corporation.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE
# This script is an adapted version of
# https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1
#Requires -RunAsAdministrator
Set-StrictMode -Version Latest
# get the directory that has a name that starts with WslLogs
$folder = Get-ChildItem -Directory | Where-Object { $_.Name -like "WslLogs*" } | Select-Object -First 1
$wprOutputLog = "$folder/wpr.txt"
Write-Host "Saving WSL logs..."
wpr.exe -stop $folder/logs.etl 2>&1 >> $wprOutputLog
$logArchive = "$(Resolve-Path $folder).zip"
Compress-Archive -Path $folder -DestinationPath $logArchive
Remove-Item $folder -Recurse
$fileName = (Get-Item $logArchive).Name
$parentFolder = (Get-Item $logArchive).Directory.Parent.FullName
Move-Item -Path $logArchive -Destination $parentFolder
Write-Host -ForegroundColor Green "Logs saved in: ${parentFolder}/${fileName}"

View file

@ -1,48 +0,0 @@
#!/usr/bin/env powershell
. $PSScriptRoot\win-lib.ps1
. $PSScriptRoot\..\win-installer\utils.ps1
if ($Env:CIRRUS_CI -eq "true") {
$WIN_INST_FOLDER = "$ENV:CIRRUS_WORKING_DIR\repo\contrib\win-installer"
$RELEASE_DIR = "$ENV:CIRRUS_WORKING_DIR\repo"
} else {
$WIN_INST_FOLDER = "$PSScriptRoot\..\win-installer"
$ENV:WIN_INST_VER = "9.9.9"
$RELEASE_DIR = Resolve-Path -Path "$PSScriptRoot\..\..\contrib\win-installer\current"
if ($null -eq $ENV:CONTAINERS_MACHINE_PROVIDER) { $ENV:CONTAINERS_MACHINE_PROVIDER = 'wsl' }
}
$ENV:PODMAN_ARCH = Get-Current-Architecture # on Cirrus CI this should always be amd64
# To get the a GitHub release ID run the following command:
# curl -s -H "Accept: application/vnd.github+json" \
# https://api.github.com/repos/containers/podman/releases/tags/v5.8.2 | jq '.id'
$ENV:LATEST_GH_RELEASE_ID = "308971529" # v5.8.2
$NEXT_WIN_INST_VER="9.9.10"
# Download the previous installer to test a major update
if (!$env:PREV_SETUP_EXE_PATH) {
$env:PREV_SETUP_EXE_PATH = Get-Podman-Setup-From-GitHub $ENV:LATEST_GH_RELEASE_ID
}
#########################################################
# Build and test the new windows installer msi package
#########################################################
$installer_folder = Resolve-Path -Path "$WIN_INST_FOLDER"
# Note: consumes podman-remote-release-windows_amd64.zip from repo.tar.zst
Run-Command "${installer_folder}\build.ps1 -Version `"$Env:WIN_INST_VER`" -Architecture `"$ENV:PODMAN_ARCH`" -LocalReleaseDirPath `"$RELEASE_DIR`""
# Build a v9.9.10 installer to test an update from current to next version
Run-Command "${installer_folder}\build.ps1 -Version `"$NEXT_WIN_INST_VER`" -Architecture `"$ENV:PODMAN_ARCH`" -LocalReleaseDirPath `"$RELEASE_DIR`""
# Run the installer silently and WSL/HyperV install options disabled (prevent reboots)
$command = "${installer_folder}\test.ps1 "
$command += "-scenario all "
$command += "-provider $ENV:CONTAINERS_MACHINE_PROVIDER "
$command += "-msiPath `"${installer_folder}\podman-$ENV:WIN_INST_VER.msi`" "
$command += "-nextMsiPath `"${installer_folder}\podman-$NEXT_WIN_INST_VER.msi`" "
$command += "-previousSetupExePath `"$env:PREV_SETUP_EXE_PATH`""
Run-Command "${command}"

View file

@ -1,20 +0,0 @@
#!/usr/bin/env powershell
. $PSScriptRoot\win-lib.ps1
Set-Location "$ENV:CIRRUS_WORKING_DIR\repo"
Write-Host "Saving selection of CI env. vars."
# Env. vars will not pass through win-sess-launch.ps1
Get-ChildItem -Path "Env:\*" -include @("PATH", "Chocolatey*", "CIRRUS*", "TEST_*", "CI_*") `
| Export-CLIXML "$ENV:TEMP\envars.xml"
# Recent versions of WSL are packaged as a Windows store app running in
# an appX container, which is incompatible with non-interactive
# session 0 execution (where the cirrus agent runs).
# Run verification under an interactive session instead.
Write-Host "Spawning new session to execute $PSScriptRoot\win-podman-machine-test.ps1"
# Can't use Run-Command(), would need overly-complex nested quoting
powershell.exe -File "$PSScriptRoot\win-sess-launch.ps1" `
"$PSScriptRoot\win-podman-machine-test.ps1"
Check-Exit

View file

@ -1,57 +0,0 @@
#!/usr/bin/env powershell
. $PSScriptRoot\win-lib.ps1
Write-Host "Recovering env. vars."
Import-CLIXML "$ENV:TEMP\envars.xml" | % {
Write-Host " $($_.Name) = $($_.Value)"
Set-Item "Env:$($_.Name)" "$($_.Value)"
}
if ($Env:TEST_FLAVOR -eq "machine-wsl") {
# FIXME: Test-modes should be definitively set and positively asserted.
# Otherwise if the var. goes out-of-scope, defaults change, or definition
# fails: Suddenly assumed behavior != actual behaviorr, esp. if/when only
# quickly glancing at a green status check-mark.
$Env:CONTAINERS_MACHINE_PROVIDER = "" # IMPLIES WSL
} elseif ($Env:TEST_FLAVOR -eq "machine-hyperv") {
$Env:CONTAINERS_MACHINE_PROVIDER = "hyperv"
} else {
Write-Host "Unsupported value for `$TEST_FLAVOR '$Env:TEST_FLAVOR'"
Exit 1
}
# Make sure an observer knows the value of this critical variable (consumed by tests).
Write-Host " CONTAINERS_MACHINE_PROVIDER = $Env:CONTAINERS_MACHINE_PROVIDER"
Write-Host "`n"
# The repo.tar.zst artifact was extracted here
Set-Location "$ENV:CIRRUS_WORKING_DIR\repo"
# Tests hard-code this location for podman-remote binary, make sure it actually runs.
Run-Command ".\bin\windows\podman.exe --version"
# Add policy.json to filesystem for podman machine pulls
New-Item -ItemType "directory" -Path "$env:AppData\containers"
Copy-Item -Path pkg\machine\ocipull\policy.json -Destination "$env:AppData\containers"
# Set TMPDIR to fast storage, see cirrus.yml setup_disk_script for setup Z:\
# TMPDIR is used by the machine tests paths, while TMP and TEMP are the normal
# windows temporary dirs. Just to ensure everything uses the fast disk.
$Env:TMPDIR = 'Z:\'
$Env:TMP = 'Z:\'
$Env:TEMP = 'Z:\'
Write-Host "`nRunning podman-machine e2e tests"
if ($Env:TEST_FLAVOR -eq "machine-wsl") {
# Output info so we know what version we are testing.
wsl --version
Run-Command "$PSScriptRoot\win-collect-wsl-logs-start.ps1"
}
try {
Run-Command ".\winmake localmachine"
} finally {
if ($Env:TEST_FLAVOR -eq "machine-wsl") {
Run-Command "$PSScriptRoot\win-collect-wsl-logs-stop.ps1"
}
}

View file

@ -1,98 +0,0 @@
# Runs a script and established interactive session (session 1) and
# tunnels the output such that WSL operations will complete
$ErrorActionPreference = 'Stop'
$syms = [char[]]([char]'a'..[char]'z') +
[char[]]([char]'A'..[char]'Z') +
[char[]]([char]'0'..[char]'9')
if ($Args.Length -lt 1) {
Write-Object "Usage: " + $MyInvocation.MyCommand.Name + " <script>"
Exit 1;
}
# Shuffle a 32 character password from $syms
function GenerateRandomPassword {
param(
[int]$length = 32
)
$rnd = [byte[]]::new($length)
[System.Security.Cryptography.RandomNumberGenerator]::create().getBytes($rnd)
$password = ($rnd | % { $syms[$_ % $syms.length] }) -join ''
return $password
}
function RegenPassword {
param($username)
$maxAttempts = 3
for ($attempts = 0; $attempts -lt $maxAttempts; $attempts++) {
$password = GenerateRandomPassword
try{
$encPass = ConvertTo-SecureString $password -AsPlainText -Force
Set-LocalUser -Name $username -Password $encPass
return $password
} catch {
# In case we catch a flake like here
# https://github.com/containers/podman/issues/23468
# we want to know what happened and retry.
Write-Host "Error generating password."
Write-Host "Username: $username"
Write-Host "Generated Password: $password"
Write-Host "Error Message: $_"
}
}
}
$runScript = $Args[0]
$nil > tmpout
$cwd = Get-Location
Write-Output "Location: $cwd"
# Reset the password to a new random pass since it's needed in the
# clear to reauth.
$pass = RegenPassword "Administrator"
$ljob = Start-Job -ArgumentList $cwd -ScriptBlock {
param($cwd)
Get-Content -Wait "$cwd\tmpout"
}
$pjob = Start-Job -ArgumentList $cwd,$runScript,$pass -ScriptBlock {
param($cwd, $runScript, $pass)
$pwargs = @("-NonInteractive", "-WindowStyle", "hidden")
$command = "& { powershell.exe $pwargs -File " +
$runScript + " 3>&1 2>&1 > `"$cwd\tmpout`";" +
"Exit `$LastExitCode }"
$encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($command))
& psexec -accepteula -w $cwd -i 1 -u Administrator -p $pass `
powershell.exe $pwargs -EncodedCommand $encoded
if ($LASTEXITCODE -ne 0) {
throw "failure running psexec"
}
}
while ($pjob.State -eq 'Running') {
Start-Sleep -Milliseconds 200
Receive-Job $ljob
}
Start-Sleep 2
Stop-Job $ljob
while ($ljob.HasMoreData) {
Receive-Job $ljob
Start-Sleep -Milliseconds 200
}
if ($pjob.State -eq 'Failed') {
Write-Output "Failure occurred, see above. Extra info:"
Receive-Job $pjob
throw "wsl task failed on us!"
}
Remove-Job $ljob
Remove-Job $pjob

View file

@ -1,19 +0,0 @@
#!/usr/bin/env powershell
. $PSScriptRoot\win-lib.ps1
if ($Env:CI -eq "true") {
Push-Location "$ENV:CIRRUS_WORKING_DIR\repo"
} else {
Push-Location $PSScriptRoot\..\..
}
Run-Command ".\winmake.ps1 localunit"
Run-Command ".\winmake.ps1 ginkgo-run" # non-machine e2e integration
# test. Currently it's only
# checking the hyperv-prep
# command and it doesn't deserve
# a specific task.
Pop-Location