Open thegaryroberts opened 2 years ago
Seems reasonable. What about a "automatically disable preview deployments after x number of days" option?
Do you want projects to be "deleted" or just "disabled"? The difference is that one is unrecoverable, while the latter is reversible (it just disables routability to the deployment).
An option to "automatically disable preview deployments after x number of days" would be ideal for my purposes yes! Would save any manual maintenance steps. Another alternative instead of basing it on time elapsed, would be deployment count. e.g. "automatically disable nth preview deployment".
In addition to the above it would still be useful to have an emergency: "delete this specific deployment" button.
For my considerations I would be wanting a full delete, so that the code/data did not exist on servers anywhere (except for the original source control). That is preferred over disable with possible restore as it is reasonably* straight forward to recreate a deployment with a push to the branch. But I could see value in both as options more generally.
*excluding the challenges around environment variable restoration/rollback.
I'd also like some way to clean up iterative PR work from months ago :) Having the extra deployments stored long term isn't benefiting anyone and it's possible that accidentally using one of those deployments later on can cause problems from reviving half-ready features.
Another automation proposal: A two-stage lifecycle such as deactivate after x days, and then delete y days after deactivation date, would be pretty careful without leaving all the cruft attached from 6 months ago. 30 days followed by 7 days would be safe for most workflows I think. I personally would be happy with 7 days / 7 days, but if configurability is on the table then this provides a pretty flexible cleanup system.
An option to "automatically disable preview deployments after x number of days" would be ideal for my purposes yes! Would save any manual maintenance steps. Another alternative instead of basing it on time elapsed, would be deployment count. e.g. "automatically disable nth preview deployment".
In addition to the above it would still be useful to have an emergency: "delete this specific deployment" button.
For my considerations I would be wanting a full delete, so that the code/data did not exist on servers anywhere (except for the original source control). That is preferred over disable with possible restore as it is reasonably* straight forward to recreate a deployment with a push to the branch. But I could see value in both as options more generally.
*excluding the challenges around environment variable restoration/rollback.
A delete icon next to every preview deploy would solve the issue for now but in the long term in large scale project which have tons of deploys everyday this won't scale enough.
But a delete option is always nice to have to quickly kill code that might have vulnerabilities or other issues, right now they would live on and bad actors have free hands if they know the version specific URL.
I'd like to see these options:
It's not really an issue for me but I just want to delete preview deployments to save Deno Deploy server resources, if that makes sense I commit to my repo like 10 times per day and seeing about 50 preview deployments that I dont really care makes me feel sorry for wasting Deno Deploy server resources Looking forward to be able to delete preview deployments and even better, disable automatic preview deployments!
Is there any update on this?
This would be a very helpful feature addition imo.
I was experiencing a similar issue, so I made the below script to handle things. Hopefully somebody finds it useful?
In the below script, update projectId
and token
with appropriate values. Then, on a local machine, do a dry-run (i.e.: const destructive = false
). This will show you what the scripted heuristic believes is the current production deployment. Verify this is accurate, otherwise the script will misbehave!.
Immediately below this, you'll find listed also the deployments which would be deleted during a destructive run. If this list is to your satisfaction, update the script with const destructive = true
and rerun it to go through with the process.
const destructive = false // Set to true after doing a dry run and verifying the result
const api = 'https://api.deno.com/v1'
const projectId = '[FIND THIS ON THE PROJECT DASHBOARD]'
const token = '[GENERATE THIS VIA YOUR ACCOUNT ACCESS TOKEN PAGE]'
const denoApi = (url, method = 'GET') => fetch(url, {
method,
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
})
const getDeployments = async (projectId) => {
const pages = []
while (true) {
const next = await denoApi(`${api}/projects/${projectId}/deployments?page=${pages.length + 1}`)
const deployments = await next.json()
if (deployments.length === 0)
break;
pages.push(deployments)
}
return pages.flat()
}
const deleteDeployment = async (deploymentId) => denoApi(
`${api}/deployments/${deploymentId}`,
'DELETE',
)
const deployments = await getDeployments(projectId)
const probablyProd = deployments.find(deployment => deployment.domains?.length > 1)
console.log(`Production deployment looks like: ${JSON.stringify(probablyProd, null, 2)}`)
const probablyPreviews = deployments.filter(deployment => deployment.databases.default !== probablyProd.databases.default)
console.log(`Will delete the following (probably) preview deployments: ${JSON.stringify(probablyPreviews, null, 2)}`)
if (destructive) {
console.log('destructive flag is enabled, proceeding to delete the aforementioned preview deployments!')
for (const deployment of probablyPreviews) {
console.log(`Deleting ${deployment.id}...`)
const deletion = await deleteDeployment(deployment.id)
}
}
As far as I can tell all preview deployments remain active indefinitely. The ability to delete earlier preview deployments would be helpful for a number of reasons: Reducing resource waste, minimise potential impact of security issues, data protection issues and for general peace of mind.
It would be particularly useful if these could be deleted in bulk!