aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorChris Evich <cevich@redhat.com>2019-07-09 12:03:04 -0400
committerChris Evich <cevich@redhat.com>2019-08-01 14:07:55 -0400
commit0a05af1dd6ed8b6e58270b7a5de25291b24362f0 (patch)
treed24284c4521f9e3fa9b767b3bac16525f2a8b940 /contrib
parentafb493ae9b1cc98db1f6d9a211b561bb245692de (diff)
downloadpodman-0a05af1dd6ed8b6e58270b7a5de25291b24362f0.tar.gz
podman-0a05af1dd6ed8b6e58270b7a5de25291b24362f0.tar.bz2
podman-0a05af1dd6ed8b6e58270b7a5de25291b24362f0.zip
Cirrus: Add Second partition for storage testing
This is mainly/initially to support use of Cirrus-CI in https://github.com/containers/buildah since that setup re-uses the VM images from this project. However, it also opens doors here, if libpod ever needs/wants to do things with a dedicated storage device and/or storage-drivers. Signed-off-by: Chris Evich <cevich@redhat.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/cirrus/add_second_partition.sh62
-rwxr-xr-xcontrib/cirrus/build_vm_images.sh2
-rwxr-xr-xcontrib/cirrus/check_image.sh2
-rw-r--r--contrib/cirrus/lib.sh23
-rw-r--r--contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/40_enable_root.cfg1
-rw-r--r--contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/50_custom_disk_setup.cfg4
l---------contrib/cirrus/packer/cloud-init/ubuntu/cloud.cfg.d/40_enable_root.cfg1
-rw-r--r--contrib/cirrus/packer/libpod_images.yml2
-rwxr-xr-xcontrib/cirrus/setup_environment.sh7
9 files changed, 91 insertions, 13 deletions
diff --git a/contrib/cirrus/add_second_partition.sh b/contrib/cirrus/add_second_partition.sh
new file mode 100644
index 000000000..73db192c5
--- /dev/null
+++ b/contrib/cirrus/add_second_partition.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# N/B: This script could mega f*!@up your disks if run by mistake.
+# it is left without the execute-bit on purpose!
+
+# $SLASH_DEVICE is the disk device to be f*xtuP
+SLASH_DEVICE="/dev/sda" # Always the case on GCP
+
+# The unallocated space results from the difference in disk-size between VM Image
+# and runtime request. The check_image.sh test includes a minimum-space check,
+# with the Image size set initially lower by contrib/cirrus/packer/libpod_images.yml
+NEW_PART_START="50%"
+NEW_PART_END="100%"
+
+set -eo pipefail
+
+source $(dirname $0)/lib.sh
+
+if [[ ! -r "/root" ]] || [[ -r "/root/second_partition_ready" ]]
+then
+ echo "Warning: Ignoring attempted execution of $(basename $0)"
+ exit 0
+fi
+
+[[ -n "type -P parted" ]] || \
+ die 2 "The parted command is required."
+
+[[ ! -b ${SLASH_DEVICE}2 ]] || \
+ die 5 "Found unexpected block device ${SLASH_DEVICE}2"
+
+PPRINTCMD="parted --script ${SLASH_DEVICE} print"
+FINDMNTCMD="findmnt --source=${SLASH_DEVICE}1 --mountpoint=/ --canonicalize --evaluate --first-only --noheadings"
+TMPF=$(mktemp -p '' $(basename $0)_XXXX)
+trap "rm -f $TMPF" EXIT
+
+if $FINDMNTCMD | tee $TMPF | egrep -q "^/\s+${SLASH_DEVICE}1"
+then
+ echo "Repartitioning original partition table:"
+ $PPRINTCMD
+else
+ die 6 "Unexpected output from '$FINDMNTCMD': $(<$TMPF)"
+fi
+
+echo "Adding partition offset within unpartitioned space."
+parted --script --align optimal /dev/sda unit % mkpart primary "" "" "$NEW_PART_START" "$NEW_PART_END"
+
+echo "New partition table:"
+$PPRINTCMD
+
+echo "Growing ${SLASH_DEVICE}1 meet start of ${SLASH_DEVICE}2"
+growpart ${SLASH_DEVICE} 1
+
+FSTYPE=$(findmnt --first-only --noheadings --output FSTYPE ${SLASH_DEVICE}1)
+echo "Expanding $FSTYPE filesystem on ${SLASH_DEVICE}1"
+case $FSTYPE in
+ ext*) resize2fs ${SLASH_DEVICE}1 ;;
+ *) die 11 "Script $(basename $0) doesn't know how to resize a $FSTYPE filesystem." ;;
+esac
+
+# Must happen last - signals completion to other tooling
+echo "Recording newly available disk partition device into /root/second_partition_ready"
+echo "${SLASH_DEVICE}2" > /root/second_partition_ready
diff --git a/contrib/cirrus/build_vm_images.sh b/contrib/cirrus/build_vm_images.sh
index dd5182c37..6230610cb 100755
--- a/contrib/cirrus/build_vm_images.sh
+++ b/contrib/cirrus/build_vm_images.sh
@@ -62,6 +62,6 @@ URI="gs://packer-import${POST_MERGE_BUCKET_SUFFIX}/manifest${BUILT_IMAGE_SUFFIX}
gsutil cp packer-manifest.json "$URI"
# Ensure any background 'gcloud compute images update' processes finish
-wait # CentOS has no -n option :(
+wait # No -n option in CentOS, this is the best that can be done :(
echo "Finished. A JSON manifest of produced images is available at $URI"
diff --git a/contrib/cirrus/check_image.sh b/contrib/cirrus/check_image.sh
index 22ed1ddc4..8a9fbae1d 100755
--- a/contrib/cirrus/check_image.sh
+++ b/contrib/cirrus/check_image.sh
@@ -7,7 +7,7 @@ source $(dirname $0)/lib.sh
NFAILS=0
echo "Validating VM image"
-MIN_SLASH_GIGS=50
+MIN_SLASH_GIGS=30
read SLASH_DEVICE SLASH_FSTYPE SLASH_SIZE JUNK <<<$(findmnt --df --first-only --noheadings / | cut -d '.' -f 1)
SLASH_SIZE_GIGS=$(echo "$SLASH_SIZE" | sed -r -e 's/G|g//')
item_test "Minimum available disk space" $SLASH_SIZE_GIGS -gt $MIN_SLASH_GIGS || let "NFAILS+=1"
diff --git a/contrib/cirrus/lib.sh b/contrib/cirrus/lib.sh
index 737ca3c01..ffb7cd45b 100644
--- a/contrib/cirrus/lib.sh
+++ b/contrib/cirrus/lib.sh
@@ -100,6 +100,9 @@ OS_RELEASE_VER="$(source /etc/os-release; echo $VERSION_ID | cut -d '.' -f 1)"
# Combined to ease soe usage
OS_REL_VER="${OS_RELEASE_ID}-${OS_RELEASE_VER}"
+# Installed into cache-images, supports overrides
+# by user-data in case of breakage or for debugging.
+CUSTOM_CLOUD_CONFIG_DEFAULTS="$GOSRC/$PACKER_BASE/cloud-init/$OS_RELEASE_ID/cloud.cfg.d"
# Pass in a list of one or more envariable names; exit non-zero with
# helpful error message if any value is empty
req_env_var() {
@@ -354,7 +357,7 @@ remove_packaged_podman_files(){
}
systemd_banish(){
- echo "Disabling periodic services that could destabilize testing:"
+ echo "Disabling periodic services that could destabilize testing (ignoring errors):"
set +e # Not all of these exist on every platform
for unit in $EVIL_UNITS
do
@@ -372,11 +375,20 @@ systemd_banish(){
_finalize(){
set +e # Don't fail at the very end
- set +e # make errors non-fatal
- echo "Removing leftover giblets from cloud-init"
+ if [[ -d "$CUSTOM_CLOUD_CONFIG_DEFAULTS" ]]
+ then
+ echo "Installing custom cloud-init defaults"
+ sudo cp -v "$CUSTOM_CLOUD_CONFIG_DEFAULTS"/* /etc/cloud/cloud.cfg.d/
+ else
+ echo "Could not find any files in $CUSTOM_CLOUD_CONFIG_DEFAULTS"
+ fi
+ echo "Re-initializing so next boot does 'first-boot' setup again."
+ sudo history -c
cd /
sudo rm -rf /var/lib/cloud/instanc*
sudo rm -rf /root/.ssh/*
+ sudo rm -rf /etc/ssh/*key*
+ sudo rm -rf /etc/ssh/moduli
sudo rm -rf /home/*
sudo rm -rf /tmp/*
sudo rm -rf /tmp/.??*
@@ -386,11 +398,6 @@ _finalize(){
rh_finalize(){
set +e # Don't fail at the very end
- # Allow root ssh-logins
- if [[ -r /etc/cloud/cloud.cfg ]]
- then
- sudo sed -re 's/^disable_root:.*/disable_root: 0/g' -i /etc/cloud/cloud.cfg
- fi
echo "Resetting to fresh-state for usage as cloud-image."
PKG=$(type -P dnf || type -P yum || echo "")
sudo $PKG clean all
diff --git a/contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/40_enable_root.cfg b/contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/40_enable_root.cfg
new file mode 100644
index 000000000..672d1907b
--- /dev/null
+++ b/contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/40_enable_root.cfg
@@ -0,0 +1 @@
+disable_root: 0
diff --git a/contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/50_custom_disk_setup.cfg b/contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/50_custom_disk_setup.cfg
new file mode 100644
index 000000000..c0fdf0e23
--- /dev/null
+++ b/contrib/cirrus/packer/cloud-init/fedora/cloud.cfg.d/50_custom_disk_setup.cfg
@@ -0,0 +1,4 @@
+#cloud-config
+growpart:
+ mode: false
+resize_rootfs: false
diff --git a/contrib/cirrus/packer/cloud-init/ubuntu/cloud.cfg.d/40_enable_root.cfg b/contrib/cirrus/packer/cloud-init/ubuntu/cloud.cfg.d/40_enable_root.cfg
new file mode 120000
index 000000000..98a0e3918
--- /dev/null
+++ b/contrib/cirrus/packer/cloud-init/ubuntu/cloud.cfg.d/40_enable_root.cfg
@@ -0,0 +1 @@
+../../fedora/cloud.cfg.d/40_enable_root.cfg \ No newline at end of file
diff --git a/contrib/cirrus/packer/libpod_images.yml b/contrib/cirrus/packer/libpod_images.yml
index 91ed3b474..2e2b21426 100644
--- a/contrib/cirrus/packer/libpod_images.yml
+++ b/contrib/cirrus/packer/libpod_images.yml
@@ -33,7 +33,7 @@ builders:
image_name: '{{build_name}}{{user `BUILT_IMAGE_SUFFIX`}}'
image_family: '{{build_name}}-libpod'
source_image: '{{user `UBUNTU_BASE_IMAGE`}}'
- disk_size: 20
+ disk_size: 20 # REQUIRED: Runtime allocation > this value
project_id: '{{user `GCP_PROJECT_ID`}}'
service_account_email: '{{user `SERVICE_ACCOUNT`}}'
communicator: 'ssh'
diff --git a/contrib/cirrus/setup_environment.sh b/contrib/cirrus/setup_environment.sh
index 2230684ac..5d350263e 100755
--- a/contrib/cirrus/setup_environment.sh
+++ b/contrib/cirrus/setup_environment.sh
@@ -42,8 +42,11 @@ case "${OS_REL_VER}" in
ln -f "$CRIO_RUNC_PATH" "/usr/bin/runc"
fi
;;
- fedora-30) ;;
- fedora-29) ;;
+ fedora-30) ;& # continue to next item
+ fedora-29)
+ if [[ "$ADD_SECOND_PARTITION" == "true" ]]; then
+ bash "$SCRIPT_BASE/add_second_partition.sh"; fi
+ ;;
centos-7) # Current VM is an image-builder-image no local podman/testing
echo "No further setup required for VM image building"
exit 0