Graceful deletion of resources

This commit adds support to core resources to enable deferred deletion
of resources.  Clients may optionally specify a time period after which
resources must be deleted via an object sent with their DELETE. That
object may define an optional grace period in seconds, or allow the
default "preferred" value for a resource to be used. Once the object
is marked as pending deletion, the deletionTimestamp field will be set
and an etcd TTL will be in place.

Clients should assume resources that have deletionTimestamp set will
be deleted at some point in the future.  Other changes will come later
to enable graceful deletion on a per resource basis.
This commit is contained in:
Clayton Coleman
2015-03-04 22:34:31 -05:00
parent 6f6485909e
commit 428d2263e5
39 changed files with 581 additions and 94 deletions

View File

@@ -169,6 +169,14 @@ var aEndpoints string = `
}
`
var deleteNow string = `
{
"kind": "DeleteOptions",
"apiVersion": "v1beta1",
"gracePeriod": 0%s
}
`
// To ensure that a POST completes before a dependent GET, set a timeout.
var timeoutFlag = "?timeout=60s"
@@ -203,7 +211,7 @@ func getTestRequests() []struct {
{"GET", "/api/v1beta1/pods", "", code200},
{"GET", "/api/v1beta1/pods/a", "", code200},
{"PATCH", "/api/v1beta1/pods/a", "{%v}", code200},
{"DELETE", "/api/v1beta1/pods/a" + timeoutFlag, "", code200},
{"DELETE", "/api/v1beta1/pods/a" + timeoutFlag, deleteNow, code200},
// Non-standard methods (not expected to work,
// but expected to pass/fail authorization prior to

View File

@@ -55,6 +55,7 @@ func TestClient(t *testing.T) {
EnableLogsSupport: false,
EnableProfiling: true,
EnableUISupport: false,
EnableV1Beta3: true,
APIPrefix: "/api",
Authorizer: apiserver.NewAlwaysAllowAuthorizer(),
AdmissionControl: admit.NewAlwaysAdmit(),
@@ -63,6 +64,7 @@ func TestClient(t *testing.T) {
testCases := []string{
"v1beta1",
"v1beta2",
"v1beta3",
}
for _, apiVersion := range testCases {
ns := api.NamespaceDefault