From 5376ec2e20d60e5492fbe2fe933e67aa8c5a88fc Mon Sep 17 00:00:00 2001 From: Chad Wilson Date: Mon, 9 Dec 2024 16:23:16 +0800 Subject: [PATCH] Support Docker 25 and AL2023 by removing instance store Docker volume initialization 'magic' The plugin previously had some userdata/cloud-init magic to utilise any special NVMe instance stores for Docker storage by creating a new logical volume group and restarting Docker on this volume. This would work "magically" on 'd' instances (e.g c6id). Additionally changes to ECS and cloud-init makes the previous approach to installing various packages not work any longer due to changes within ECS/AL2023, so the volume tools need additional work to get in the right state. This is broken on Docker 25 and thus AL2023 because it relied on the docker device-mapper storage driver which is no longer available, and there was no way to opt out of it. In any case, this no longer seems necessary, as for the purposes of this image it seems regular EBS GP3 style volumes should probably be sufficient for use within the GoCD build agent containers being run. If there is a need to add this back, we'll add this back based on user feedback and assistance, but right now this seems to be doing more harm than good, so will remove the support. --- build.gradle | 2 +- src/main/resources/userdata.template | 64 ------------------- src/test/resources/userdata/full-userdata.sh | 64 ------------------- src/test/resources/userdata/linux-default.sh | 64 ------------------- .../resources/userdata/linux-with-cluster.sh | 64 ------------------- .../userdata/linux-with-docker-registry.sh | 64 ------------------- .../userdata/linux-with-image-cleanup.sh | 64 ------------------- .../userdata/linux-with-init-script.sh | 64 ------------------- .../userdata/linux-with-task-cleanup.sh | 64 ------------------- .../userdata/userdata-from-ec2-config.sh | 64 ------------------- .../userdata/with-custom-attributes.sh | 64 ------------------- .../resources/userdata/with-storage-config.sh | 64 ------------------- 12 files changed, 1 insertion(+), 705 deletions(-) diff --git a/build.gradle b/build.gradle index cfe4bb0..8acf46f 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ group = 'com.thoughtworks.gocd' gocdPlugin { id = 'com.thoughtworks.gocd.elastic-agent.ecs' - pluginVersion = '7.4.1' + pluginVersion = '8.0.0' goCdVersion = '21.4.0' name = 'GoCD Elastic Agent Plugin for Amazon ECS' description = 'GoCD Elastic Agent Plugin for Amazon Elastic Container Service allow for more efficient use of instances' diff --git a/src/main/resources/userdata.template b/src/main/resources/userdata.template index a2fa2ec..71a931b 100644 --- a/src/main/resources/userdata.template +++ b/src/main/resources/userdata.template @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ CUSTOM_USER_DATA_SCRIPT log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS="OVERRIDE_STORAGE_OPTION --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/full-userdata.sh b/src/test/resources/userdata/full-userdata.sh index 837e1da..134f8c7 100644 --- a/src/test/resources/userdata/full-userdata.sh +++ b/src/test/resources/userdata/full-userdata.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -45,62 +40,3 @@ some-script log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS="--storage-opt foo=bsfds --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-default.sh b/src/test/resources/userdata/linux-default.sh index 3f32e9a..cc74891 100644 --- a/src/test/resources/userdata/linux-default.sh +++ b/src/test/resources/userdata/linux-default.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-cluster.sh b/src/test/resources/userdata/linux-with-cluster.sh index 10411f8..41ea999 100644 --- a/src/test/resources/userdata/linux-with-cluster.sh +++ b/src/test/resources/userdata/linux-with-cluster.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-docker-registry.sh b/src/test/resources/userdata/linux-with-docker-registry.sh index 5df4600..0845d72 100644 --- a/src/test/resources/userdata/linux-with-docker-registry.sh +++ b/src/test/resources/userdata/linux-with-docker-registry.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -40,62 +35,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-image-cleanup.sh b/src/test/resources/userdata/linux-with-image-cleanup.sh index f1cb169..151bf95 100644 --- a/src/test/resources/userdata/linux-with-image-cleanup.sh +++ b/src/test/resources/userdata/linux-with-image-cleanup.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-init-script.sh b/src/test/resources/userdata/linux-with-init-script.sh index bc9841f..afd0045 100644 --- a/src/test/resources/userdata/linux-with-init-script.sh +++ b/src/test/resources/userdata/linux-with-init-script.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ echo "this is an example init script." log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/linux-with-task-cleanup.sh b/src/test/resources/userdata/linux-with-task-cleanup.sh index 87d514a..db08770 100644 --- a/src/test/resources/userdata/linux-with-task-cleanup.sh +++ b/src/test/resources/userdata/linux-with-task-cleanup.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/userdata-from-ec2-config.sh b/src/test/resources/userdata/userdata-from-ec2-config.sh index b737817..3133775 100644 --- a/src/test/resources/userdata/userdata-from-ec2-config.sh +++ b/src/test/resources/userdata/userdata-from-ec2-config.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -42,62 +37,3 @@ linux-script log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/with-custom-attributes.sh b/src/test/resources/userdata/with-custom-attributes.sh index 2d62a49..a317a7d 100644 --- a/src/test/resources/userdata/with-custom-attributes.sh +++ b/src/test/resources/userdata/with-custom-attributes.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -39,62 +34,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS=" --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file diff --git a/src/test/resources/userdata/with-storage-config.sh b/src/test/resources/userdata/with-storage-config.sh index b85ce22..cc74891 100644 --- a/src/test/resources/userdata/with-storage-config.sh +++ b/src/test/resources/userdata/with-storage-config.sh @@ -8,11 +8,6 @@ Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cloud-config" #cloud-config -package_update: true -packages: - - lvm2 - - nfs-utils - - nfs-common cloud_final_modules: - [scripts-user, always] @@ -35,62 +30,3 @@ log "Finished executing GoCD's user data script, now executing custom user data log "Finished executing user specified user data script." --// -Content-Type: text/x-shellscript; charset="us-ascii" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Content-Disposition: attachment; filename="initialize_instance_store" - -#!/bin/bash -exec > >(tee /var/log/initialize_instance_store.log | logger -t user-data -s 2>/dev/console) 2>&1 -function log() { - echo "[$(date "+%Y-%m-%d %H:%M:%S")] - $1" >> /var/log/initialize_instance_store.log -} - -function try() { - $@ - return 0 -} - -log "Starting to setup instance store for the docker." -INSTANCE_STORES=$(ls /dev/disk/by-id/*EC2_NVMe_Instance_Storage*-ns-1) - -if [ -z "${INSTANCE_STORES}" ]; then - log "No instance store detected." -fi - -VOLUMES="$INSTANCE_STORES" -if [ -e "/dev/xvdcz" ]; then - log "Instance has /dev/xvdcz EBS volume. Using it for docker logical volume group." - VOLUMES="$VOLUMES /dev/xvdcz" -fi - -if [ -z "${VOLUMES}" ]; then - log "No addition volumes. Using box standard docker setup." -else - log "Available instance stores: ${VOLUMES}." - log "Setting up the docker logical volume group." - - service docker stop - rm -rf /var/lib/docker/* - dmsetup remove_all - - VOLUME_GROUP=docker - LOGICAL_VOLUME=docker-pool - - try vgremove -y "${VOLUME_GROUP}" - try lvremove -y "${LOGICAL_VOLUME}" - - vgcreate -y "${VOLUME_GROUP}" ${VOLUMES} - sleep 2 - lvcreate -y -l 5%VG -n ${LOGICAL_VOLUME}\meta ${VOLUME_GROUP} - lvcreate -y -l 90%VG -n ${LOGICAL_VOLUME} ${VOLUME_GROUP} - sleep 2 - lvconvert -y --zero n --thinpool ${VOLUME_GROUP}/${LOGICAL_VOLUME} --poolmetadata ${VOLUME_GROUP}/${LOGICAL_VOLUME}\meta - echo 'DOCKER_STORAGE_OPTIONS="--storage-opt dm.fs=ext4 --storage-opt dm.basesize=20G --storage-driver devicemapper --storage-opt dm.thinpooldev=/dev/mapper/docker-docker--pool --storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_deletion=true --storage-opt dm.fs=ext4 --storage-opt dm.use_deferred_deletion=true"' > /etc/sysconfig/docker-storage - test -f /bin/systemctl && systemctl reset-failed docker.service - service docker restart - test -f /bin/systemctl && systemctl enable --no-block --now ecs -fi - -log "Setup completed." ---// \ No newline at end of file