forked from kubeflow/pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a cron job to regularly garbage collect test resources. (kubef…
…low#300) * Create a cron job to regularly garbage collect test resources. * Add to cleanup_ci.py an "all" subcommand to delete all resources." * Add a batch job for one off runs. Related to: kubeflow#87 Cron job to garbage collect test resources kubeflow#249 cron job to collect Kubeflow deployments launched by E2E tests * * Add a cron job to run the cleanup every two hours. * In cleanup_ci.py; don't load the imports of the manifests We encountered an error where the manifest didn't exist. I think that may have been a collision because we had a separate script running to do the deletes. * Fix some bugs. * Deal with config being none. * Maybe activate service account.
- Loading branch information
1 parent
da8a4dc
commit 83f488d
Showing
5 changed files
with
196 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Oneoff job to cleanup the ci system. | ||
// | ||
local params = std.extVar("__ksonnet/params").components["cleanup-ci-cron"]; | ||
local env = std.extVar("__ksonnet/environments"); | ||
|
||
local k = import "k.libsonnet"; | ||
local cleanup = import "cleanup-ci.libsonnet"; | ||
|
||
local job = { | ||
"apiVersion": "batch/v1beta1", | ||
"kind": "CronJob", | ||
"metadata": { | ||
name: params.name, | ||
namespace: env.namespace, | ||
labels: { | ||
app: "cleanup-ci" | ||
}, | ||
}, | ||
spec: { | ||
// Every two hours | ||
schedule: "0 */2 * * *" , | ||
concurrencyPolicy: "Forbid", | ||
jobTemplate: { | ||
metadata: { | ||
labels: { | ||
app: "cleanup-ci", | ||
}, | ||
}, | ||
spec: cleanup.jobSpec, | ||
}, | ||
}, | ||
}; | ||
|
||
std.prune(k.core.v1.list.new([ | ||
job, | ||
])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Oneoff job to cleanup the ci system. | ||
// | ||
local params = std.extVar("__ksonnet/params").components["cleanup-ci"]; | ||
local env = std.extVar("__ksonnet/environments"); | ||
|
||
local k = import "k.libsonnet"; | ||
local cleanup = import "cleanup-ci.libsonnet"; | ||
|
||
local job = { | ||
"apiVersion": "batch/v1", | ||
"kind": "Job", | ||
"metadata": { | ||
name: params.name, | ||
namespace: env.namespace, | ||
labels: { | ||
app: "cleanup-ci" | ||
}, | ||
}, | ||
"spec": cleanup.jobSpec, | ||
}; | ||
|
||
std.prune(k.core.v1.list.new([ | ||
job, | ||
])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
|
||
// Build a multi-line container command. | ||
// Input is a list of lists. Where each list describes a command to be run. | ||
// e.g | ||
// [ ["echo", "command-one"], ["echo", "command-two"]] | ||
// Output is a list containing a shell command to run them | ||
// e.g. | ||
// ["/bin/sh", "-xc", "echo command-one; echo command-two"] | ||
buildCommand:: function(items) | ||
["/bin/sh", "-xc"] + | ||
[std.join("; ", | ||
std.map( | ||
function(c) std.join(" ", c), | ||
items, | ||
) | ||
)], | ||
|
||
jobSpec:: { | ||
"template": { | ||
"spec": { | ||
"containers": [ | ||
{ | ||
command: $.buildCommand([[ | ||
"/usr/local/bin/checkout.sh", | ||
"/src", | ||
], | ||
[ | ||
"python", | ||
"-m", | ||
"kubeflow.testing.cleanup_ci", | ||
"all", | ||
"--delete_script=/src/kubeflow/kubeflow/scripts/gke/delete_deployment.sh", | ||
], | ||
]), | ||
"image": "gcr.io/kubeflow-ci/test-worker/test-worker:v20190116-b7abb8d-e3b0c4", | ||
"name": "label-sync", | ||
env: [ | ||
{ | ||
name: "REPO_OWNER", | ||
value: "kubeflow", | ||
}, | ||
{ | ||
name: "REPO_NAME", | ||
value: "testing", | ||
}, | ||
{ | ||
// TODO(jlewi): Stop setting PULL_NUMBER once the PR is merged. | ||
// We had to set the PR number because when we initially created the | ||
// job we had some changes to cleanup_ci.py that were part of the PR | ||
// committing the job. | ||
name: "PULL_NUMBER", | ||
value: "300", | ||
}, | ||
{ | ||
name: "PYTHONPATH", | ||
value: "/src/kubeflow/testing/py", | ||
}, | ||
{ | ||
name: "EXTRA_REPOS", | ||
value: "kubeflow/kubeflow@HEAD", | ||
}, | ||
{ | ||
name: "GOOGLE_APPLICATION_CREDENTIALS", | ||
value: "/secret/gcp-credentials/key.json", | ||
}, | ||
], | ||
"volumeMounts": [ | ||
{ | ||
name: "gcp-credentials", | ||
mountPath: "/secret/gcp-credentials", | ||
readOnly: true | ||
}, | ||
] | ||
} | ||
], | ||
"restartPolicy": "Never", | ||
"volumes": [ | ||
{ | ||
name: "gcp-credentials", | ||
secret: { | ||
secretName: "kubeflow-testing-credentials", | ||
}, | ||
}, | ||
] | ||
} | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters