From 4a15bd8ff8af0bca5ed5705a423b4174f8c7783e Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Wed, 2 Mar 2022 00:06:47 +0100 Subject: [PATCH] Return info for DiskInfo when the disk is unformatted (#14427) In a distributed setup, a DiskInfo REST call to an unformatted disk returns an error with no disk information, such as the disk endpoint URL, which is unexpected. --- cmd/storage-rest-server.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/storage-rest-server.go b/cmd/storage-rest-server.go index 58c19f408..99a293a7d 100644 --- a/cmd/storage-rest-server.go +++ b/cmd/storage-rest-server.go @@ -109,7 +109,7 @@ func storageServerRequestValidate(r *http.Request) error { } // IsValid - To authenticate and verify the time difference. -func (s *storageRESTServer) IsValid(w http.ResponseWriter, r *http.Request) bool { +func (s *storageRESTServer) IsAuthValid(w http.ResponseWriter, r *http.Request) bool { if s.storage == nil { s.writeErrorResponse(w, errDiskNotFound) return false @@ -120,6 +120,15 @@ func (s *storageRESTServer) IsValid(w http.ResponseWriter, r *http.Request) bool return false } + return true +} + +// IsValid - To authenticate and check if the disk-id in the request corresponds to the underlying disk. +func (s *storageRESTServer) IsValid(w http.ResponseWriter, r *http.Request) bool { + if !s.IsAuthValid(w, r) { + return false + } + if err := r.ParseForm(); err != nil { s.writeErrorResponse(w, err) return false @@ -155,7 +164,7 @@ func (s *storageRESTServer) HealthHandler(w http.ResponseWriter, r *http.Request // DiskInfoHandler - returns disk info. func (s *storageRESTServer) DiskInfoHandler(w http.ResponseWriter, r *http.Request) { - if !s.IsValid(w, r) { + if !s.IsAuthValid(w, r) { return } info, err := s.storage.DiskInfo(r.Context())