-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Enhance heuristics to delete preview-environments #9225
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
Conversation
bc7ad30
to
bd08b69
Compare
@wulfthimm I started reviewing this but won't finish until tomorrow I'm afraid |
@mads-hartmann No problem. I could also walk you trough and maybe learn something on the way as I am no TS developer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I left a few comments around changes I'd like to see
@mads-hartmann Thanks for the comments. I really appreciate the insights. I will address them once I finished my current work. I expect to have them fixed over the next day. |
6a8283a
to
b7dc0ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Wulf! I have another round of small change requests and then I think we're done
@mads-hartmann Thanks for your comments. I will make the changes on monday. |
da1e34c
to
0729a1c
Compare
@mads-hartmann I made the requested changes and I hope it is correct now. |
werft.log("deleting preview", preview) | ||
promises.push(wipePreviewEnvironmentAndNamespace(helmInstallName, preview, CORE_DEV_KUBECONFIG_PATH, { slice: `Deleting preview ${preview}` })) | ||
}) | ||
await Promise.all(promises) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change the mapping as the compiler throw an arrow that .map
is not supported on this set.
@@ -6,6 +6,10 @@ import { exec } from './util/shell'; | |||
import { previewNameFromBranchName } from './util/preview'; | |||
import { CORE_DEV_KUBECONFIG_PATH } from './jobs/build/const'; | |||
|
|||
// for testing purposes | |||
// if set to 'true' it shows only previews that would be deleted | |||
const DRY_RUN = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep the hold
label and change it to false
once this PR is approved.
aac45ed
to
9367df4
Compare
@wulfthimm I just used this job to clean up 94 preview environments 🎉 The Werft build is failing though. Perhaps trigger a new build, maybe after rebasing on main just to be on the safe side |
23b529b
to
181daed
Compare
181daed
to
66c3336
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks! 🛹 Remove the hold label and merge whenever you're comfortable
Description
This improves the detection of outdated preview-environments. The database of each instance is tested if the last access is more than 24h ago based on the data provided by
d_b_workspace_instance.creationTime
,d_b_user.creationDate
,d_b_user._lastModified
andd_b_workspace_instance_user.lastSeen
. It also checks if the last commit of a branch is less than 5 days ago and deletes the preview-environment if there has been no change.Related Issue(s)
Fixes https://github.com/gitpod-io/ops/issues/1623
How to test
Open a new workspace with this PR and run
werft run github -j .werft/platform-delete-preview-environments-cron.yaml -f
. Preview environments are not deleted as the necessary function needs to be uncommented.Release Notes
Documentation