warn if docker-machine has less than 8GB of memory

test plan:

- shutdown dinghy if already running:

    $ dingy down

- backup ~/.dinghy:

    $ cp -r ~/.dinghy ~/.dinghy.bak

- delete existing config:

    $ rm -rf ~/.dinghy

- setup a different machine name in preferences.yml:

    $ cat ~/.dinghy/preferences.yml
    ---
    :preferences:
      :create:
        # 'virtualbox' if you are not using docker-machine-driver-xhyve
        provider: xhyve
      :machine_name: dinghy-memory-test

- create the dinghy vm (outside of the docker_dev_setup.sh script):

    $ dinghy create

- set temporary shell variables:

    $ eval $(dinghy env)

- verify ram is less than 8GB

    $ docker-machine inspect dinghy-memory-test | ruby -r json -e 'puts JSON.parse(ARGF.read).fetch("Driver").fetch("Memory")'
    2048

- verify the script exits before setting up canvas and clarifies that 8GB of
  memory is required:

    $ ./script/docker_dev_setup.sh

    <snip>

    Canvas requires at least 8GB of memory dedicated to the VM. Please recreate
    your VM with a memory value of at least 8192. For Example:

        $ dinghy create --memory 8192

- remove the tempory dinghy vm:

    $ dinghy destroy

- restore dinghy configuration files

    $ rm -rf ~/.dinghy
    $ mv ~/.dinghy.bak ~/.dinghy

- open a new shell to restore previously set shell environment variables

Change-Id: I63fbd486b276b653bbcec017cfabb354b746bbe2
Reviewed-on: https://gerrit.instructure.com/213110
Reviewed-by: Charley Kline <ckline@instructure.com>
QA-Review: Charley Kline <ckline@instructure.com>
Product-Review: Charley Kline <ckline@instructure.com>
Tested-by: Jenkins
This commit is contained in:
Derek Bender 2019-10-14 15:29:17 -05:00
parent 5e6d3fc1a0
commit e44e95d1df
1 changed files with 12 additions and 2 deletions

View File

@ -90,8 +90,18 @@ function install_dependencies {
function create_dinghy_vm {
if ! dinghy status | grep -q 'not created'; then
message "I found an existing dinghy VM. We'll use that."
return 0
existing_memory="$(docker-machine inspect --format "{{.Driver.Memory}}" "${DOCKER_MACHINE_NAME}")"
if [[ "$existing_memory" -lt "$DINGHY_MEMORY" ]]; then
echo "
Canvas requires at least 8GB of memory dedicated to the VM. Please recreate
your VM with a memory value of at least ${DINGHY_MEMORY}. For Example:
$ dinghy create --memory ${DINGHY_MEMORY}"
exit 1
else
message "Using existing dinghy VM..."
return 0
fi
fi
prompt 'OK to create a dinghy VM? [y/n]' confirm