cephfs admin: ignore deprecation warnings for protect/unprotect

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-09-21 15:49:50 -04:00 committed by John Mulligan
parent 9a97852bf2
commit e7c7752393
2 changed files with 20 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"
)
var (
@ -17,6 +18,10 @@ var (
ErrBodyNotEmpty = errors.New("response body not empty")
)
const (
deprecatedSuffix = "call is deprecated and will be removed in a future release"
)
// response encapsulates the data returned by ceph and supports easy processing
// pipelines.
type response struct {
@ -84,6 +89,19 @@ func (r response) noData() response {
return r.noStatus().noBody()
}
// filterDeprecated removes deprecation warnings from the response status.
// Use it when checking the response from calls that may be deprecated in ceph
// if you want those calls to continue working if the warning is present.
func (r response) filterDeprecated() response {
if !r.Ok() {
return r
}
if strings.HasSuffix(r.status, deprecatedSuffix) {
return response{r.body, "", r.err}
}
return r
}
// unmarshal data from the response body into v.
func (r response) unmarshal(v interface{}) response {
if !r.Ok() {

View File

@ -280,7 +280,7 @@ func (fsa *FSAdmin) ProtectSubVolumeSnapshot(volume, group, subvolume, name stri
if group != NoGroup {
m["group_name"] = group
}
return fsa.marshalMgrCommand(m).noData().End()
return fsa.marshalMgrCommand(m).filterDeprecated().noData().End()
}
// UnprotectSubVolumeSnapshot removes protection from the specified snapshot.
@ -298,5 +298,5 @@ func (fsa *FSAdmin) UnprotectSubVolumeSnapshot(volume, group, subvolume, name st
if group != NoGroup {
m["group_name"] = group
}
return fsa.marshalMgrCommand(m).noData().End()
return fsa.marshalMgrCommand(m).filterDeprecated().noData().End()
}