[ARVADOS] created: 34f675d7e46d8446a11488d9970e589f988456bd
git at public.curoverse.com
git at public.curoverse.com
Fri Aug 8 15:13:39 EDT 2014
at 34f675d7e46d8446a11488d9970e589f988456bd (commit)
commit 34f675d7e46d8446a11488d9970e589f988456bd
Author: Tom Clegg <tom at curoverse.com>
Date: Fri Aug 8 15:13:24 2014 -0400
2769: Add -never-delete command line flag.
diff --git a/services/keep/src/keep/handler_test.go b/services/keep/src/keep/handler_test.go
index df8a0ba..64a417f 100644
--- a/services/keep/src/keep/handler_test.go
+++ b/services/keep/src/keep/handler_test.go
@@ -508,6 +508,15 @@ func TestDeleteHandler(t *testing.T) {
http.StatusNotFound,
response)
+ // Authenticated admin request for existing block while never_delete is set.
+ never_delete = true
+ response = IssueRequest(rest, superuser_existing_block_req)
+ ExpectStatusCode(t,
+ "authenticated request, existing block, method disabled",
+ MethodDisabledError.HTTPCode,
+ response)
+ never_delete = false
+
// Authenticated admin request for existing block.
response = IssueRequest(rest, superuser_existing_block_req)
ExpectStatusCode(t,
diff --git a/services/keep/src/keep/handlers.go b/services/keep/src/keep/handlers.go
index dc0f517..9838694 100644
--- a/services/keep/src/keep/handlers.go
+++ b/services/keep/src/keep/handlers.go
@@ -354,6 +354,11 @@ func DeleteHandler(resp http.ResponseWriter, req *http.Request) {
return
}
+ if never_delete {
+ http.Error(resp, MethodDisabledError.Error(), MethodDisabledError.HTTPCode)
+ return
+ }
+
// Delete copies of this block from all available volumes. Report
// how many blocks were successfully and unsuccessfully
// deleted.
diff --git a/services/keep/src/keep/keep.go b/services/keep/src/keep/keep.go
index c34c268..9556185 100644
--- a/services/keep/src/keep/keep.go
+++ b/services/keep/src/keep/keep.go
@@ -53,6 +53,10 @@ var permission_ttl time.Duration
// Initialized by the --data-manager-token-file flag.
var data_manager_token string
+// never_delete can be used to prevent the DELETE handler from
+// actually deleting anything.
+var never_delete = false
+
// ==========
// Error types.
//
@@ -62,16 +66,17 @@ type KeepError struct {
}
var (
- BadRequestError = &KeepError{400, "Bad Request"}
- CollisionError = &KeepError{500, "Collision"}
- RequestHashError = &KeepError{422, "Hash mismatch in request"}
- PermissionError = &KeepError{403, "Forbidden"}
- DiskHashError = &KeepError{500, "Hash mismatch in stored data"}
- ExpiredError = &KeepError{401, "Expired permission signature"}
- NotFoundError = &KeepError{404, "Not Found"}
- GenericError = &KeepError{500, "Fail"}
- FullError = &KeepError{503, "Full"}
- TooLongError = &KeepError{504, "Timeout"}
+ BadRequestError = &KeepError{400, "Bad Request"}
+ CollisionError = &KeepError{500, "Collision"}
+ RequestHashError = &KeepError{422, "Hash mismatch in request"}
+ PermissionError = &KeepError{403, "Forbidden"}
+ DiskHashError = &KeepError{500, "Hash mismatch in stored data"}
+ ExpiredError = &KeepError{401, "Expired permission signature"}
+ NotFoundError = &KeepError{404, "Not Found"}
+ GenericError = &KeepError{500, "Fail"}
+ FullError = &KeepError{503, "Full"}
+ TooLongError = &KeepError{504, "Timeout"}
+ MethodDisabledError = &KeepError{405, "Method disabled"}
)
func (e *KeepError) Error() string {
@@ -132,6 +137,12 @@ func main() {
"Interface on which to listen for requests, in the format "+
"ipaddr:port. e.g. -listen=10.0.1.24:8000. Use -listen=:port "+
"to listen on all network interfaces.")
+ flag.BoolVar(
+ &never_delete,
+ "never-delete",
+ false,
+ "If set, nothing will be deleted. HTTP 405 will be returned "+
+ "for valid DELETE requests.")
flag.StringVar(
&permission_key_file,
"permission-key-file",
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list