diff --git a/common/admin/nfs/export.go b/common/admin/nfs/export.go index 6b981b7..9b29761 100644 --- a/common/admin/nfs/export.go +++ b/common/admin/nfs/export.go @@ -4,6 +4,8 @@ package nfs import ( + "errors" + "github.com/ceph/go-ceph/internal/commands" ) @@ -26,6 +28,10 @@ const ( Unspecifiedquash SquashMode = "" ) +var ( + errNoExportInfo = errors.New("No export info found") +) + // SecType indicates the kind of security/authentication to be used by an export. type SecType string @@ -115,6 +121,11 @@ func parseExportsList(res commands.Response) ([]ExportInfo, error) { func parseExportInfo(res commands.Response) (ExportInfo, error) { i := ExportInfo{} + // different versions of ceph may return nothing or empty json. + // detect these cases and return a specific error + if res.NoStatus().EmptyBody().Ok() { + return i, errNoExportInfo + } if err := res.NoStatus().Unmarshal(&i).End(); err != nil { return i, err }