-
Notifications
You must be signed in to change notification settings - Fork 95
Handle errors on Get() call from server. #699
Conversation
@@ -352,22 +352,32 @@ func (d *vmdkDriver) Mount(r volume.MountRequest) volume.Response { | |||
|
|||
// This is the first time we are asked to mount the volume, so comply | |||
status, err := d.ops.Get(r.Name) | |||
|
|||
fstype := "ext4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a constant for the default fstype fs.FstypeDefault
msg := fmt.Sprintf("Got invalid filesystem type for %s, assuming type as ext2.", r.Name) | ||
log.WithFields(log.Fields{"name": r.Name, "error": msg}).Error("") | ||
// Fail back to a default version that we can try with. | ||
value = "ext4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
If we cannot rely in the metadata in those cases, maybe we could have a fallback method for mounting with exec.Command and mount -t auto instead of passing the default fstype that may not be the user specified FS ? |
Yes, that sounds good but may be a separate change from this one. On Fri, Nov 4, 2016 at 6:00 PM, Bruno Moura notifications@github.com
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good , a few comments inline (the main one is that we need to print offending strings, and use warning instead of debug() is we fail to parse json.
@@ -105,7 +105,7 @@ func (v VmdkOps) Get(name string) (map[string]interface{}, error) { | |||
|
|||
err = json.Unmarshal(str, &statusMap) | |||
if err != nil { | |||
return nil, err | |||
log.Debugf("vmdkOps.Get failed decoding volume status for name=%s", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be warning , not debug. Admin cant do much about it but at least needs to know about it since it is why default would be applied.
@@ -421,7 +421,7 @@ def getVMDK(vmdk_path, vol_name, datastore): | |||
except Exception as ex: | |||
msg = "Failed to get disk details for %s (%s)" % (vmdk_path, ex) | |||
logging.error(msg) | |||
result = err(msg) | |||
result = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after this fix msg
is not needed and the code could be simply be as follows:
except Exception as ex:
logging.error("Failed to get disk details for %s (%s)" % (vmdk_path, ex))
return None
if !exists { | ||
msg := fmt.Sprintf("Got invalid access type for %s, assuming read-write access.", r.Name) | ||
log.WithFields(log.Fields{"name": r.Name, "error": msg}).Error("") | ||
isReadOnly = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice to actually print the offending string
// Check access type. | ||
value, exists := status["access"].(string) | ||
if !exists { | ||
msg := fmt.Sprintf("Got invalid access type for %s, assuming read-write access.", r.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Got" is not needed, the msg can simply say "Invalid access type..."
// Check file system type. | ||
value, exists = status["fstype"].(string) | ||
if !exists { | ||
msg := fmt.Sprintf("Got invalid filesystem type for %s, assuming type as ext2.", r.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Got" is not needed, the msg can simply say "Invalid access type..."
value, exists = status["fstype"].(string) | ||
if !exists { | ||
msg := fmt.Sprintf("Got invalid filesystem type for %s, assuming type as ext2.", r.Name) | ||
log.WithFields(log.Fields{"name": r.Name, "error": msg}).Error("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to print the offending string as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that sounds good but may be a separate change from this one.
if you agree with the suggestions but want to put it in a different change, please open an issue and refer to it
LGTM when CI passes |
e1a2251
to
44e16fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed as well rebased to merge but never clicked merge. Please merge away.
Fixes #662 |
The Get() returns volume status thats optional in the docker plugin API. So, don't treat errors on status fetch as fatal. This test below had to artifically create an empty KV file because thats the only way it can be made empty or corrupted.
Tests:
<trash the KV file - empty it>