Add flag validation diskspace and set false(skip) step by default (#909)

* flag validation diskspace

* display Available disk space

* update image.CI

* add image.CI flag

* update env RUN_VALIDATION_FLAG
This commit is contained in:
Aleksandr Chebotov
2020-05-21 09:08:52 +03:00
committed by GitHub
parent e25d793c29
commit 521b0c5e28
4 changed files with 15 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ packer build -var "capture_name_prefix=$ResourcesNamePrefix" `
-var "virtual_network_name=$VirtualNetworkName" ` -var "virtual_network_name=$VirtualNetworkName" `
-var "virtual_network_resource_group_name=$VirtualNetworkRG" ` -var "virtual_network_resource_group_name=$VirtualNetworkRG" `
-var "virtual_network_subnet_name=$VirtualNetworkSubnet" ` -var "virtual_network_subnet_name=$VirtualNetworkSubnet" `
-var "run_validation_diskspace=$env:RUN_VALIDATION_FLAG" `
$TemplatePath ` $TemplatePath `
| Where-Object { | Where-Object {
#Filter sensitive data from Packer logs #Filter sensitive data from Packer logs

View File

@@ -8,6 +8,12 @@ availableSpaceMB=$(df / -hm | sed 1d | awk '{ print $4}')
minimumFreeSpaceMB=17800 minimumFreeSpaceMB=17800
echo "Available disk space: $availableSpaceMB MB" echo "Available disk space: $availableSpaceMB MB"
if [ $RUN_VALIDATION != "true" ]; then
echo "Skipping validation disk space..."
exit 0
fi
if [ $availableSpaceMB -le $minimumFreeSpaceMB ]; then if [ $availableSpaceMB -le $minimumFreeSpaceMB ]; then
echo "Not enough disk space on the image (minimum available space: $minimumFreeSpaceMB MB)" echo "Not enough disk space on the image (minimum available space: $minimumFreeSpaceMB MB)"
exit 1 exit 1

View File

@@ -24,6 +24,7 @@
"image_version": "dev", "image_version": "dev",
"image_os": "ubuntu16", "image_os": "ubuntu16",
"github_feed_token": null, "github_feed_token": null,
"run_validation_diskspace": "false",
"go_default": "1.14", "go_default": "1.14",
"go_versions": "1.11 1.12 1.13 1.14" "go_versions": "1.11 1.12 1.13 1.14"
}, },
@@ -344,6 +345,9 @@
"type": "shell", "type": "shell",
"scripts":[ "scripts":[
"{{template_dir}}/scripts/installers/validate-disk-space.sh" "{{template_dir}}/scripts/installers/validate-disk-space.sh"
],
"environment_vars": [
"RUN_VALIDATION={{user `run_validation_diskspace`}}"
] ]
}, },
{ {

View File

@@ -24,6 +24,7 @@
"image_version": "dev", "image_version": "dev",
"image_os": "ubuntu18", "image_os": "ubuntu18",
"github_feed_token": null, "github_feed_token": null,
"run_validation_diskspace": "false",
"go_default": "1.14", "go_default": "1.14",
"go_versions": "1.11 1.12 1.13 1.14" "go_versions": "1.11 1.12 1.13 1.14"
}, },
@@ -348,6 +349,9 @@
"type": "shell", "type": "shell",
"scripts":[ "scripts":[
"{{template_dir}}/scripts/installers/validate-disk-space.sh" "{{template_dir}}/scripts/installers/validate-disk-space.sh"
],
"environment_vars": [
"RUN_VALIDATION={{user `run_validation_diskspace`}}"
] ]
}, },
{ {