Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: command that returns if the multidev environment limit has been reached #2440

Open
justafish opened this issue Mar 1, 2023 · 3 comments

Comments

@justafish
Copy link

This would help fail automated deploy processes faster i.e. not have to go through the entire build and preparation to push to a multidev before finding out that none are available.

@greg-1-anderson
Copy link
Member

You can currently do this in two requests; the site:info command will give you your multidev limit, and multidev:list will let you count them. This feature request is a reasonable way to determine the same thing faster; however, if you are often hitting your multidev limit, try submitting a support request and ask about getting it bumped up. The main reason the limit exists is so that customers will delete their unused multidevs. If you can demonstrate that your multidevs are actually in use (e.g. "for our team size, we need a buffer of five unused for our pull request workflow"), your request is likely to be granted.

@pwtyler
Copy link
Member

pwtyler commented Mar 1, 2023

While there's not currently a single endpoint that would provide this as a boolean yes/no, this can be done by comparing the "Max Multidevs" field (terminus site:info "${SITE_NAME}" --field="Max Multidevs") against a count of env:list

I think something like this would work for you (I'm sure there are cleaner/better bashisms than what I've suggested as well):

#!/bin/bash

MAX_ALLOWED=$(terminus  site:info "${SITE_NAME}" --field="Max Multidevs")

# Count current environments
COUNT=$(terminus env:list "${SITE_NAME}" --format=list | wc -l)

# Subtract 3 to account for dev/test/live
# (and remove whitespace from the output of the previous command to make the arithmetic work)
MULTIDEV_COUNT=$(expr ${COUNT//[[:blank:]]/} - 3)

if [[ "${MULTIDEV_COUNT}" -ge "${MAX_ALLOWED}" ]]; then
  echo "Not enough multidevs"
  exit 1
fi

@pwtyler
Copy link
Member

pwtyler commented May 23, 2023

@justafish, I ended up implementing a script to clean up old builds for CI on our pantheon_advanced_page_cache repo, it got a little more complicated to cover the edge cases a little better, but you can check it out here and adapt to your needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants