4343
4444import javax .naming .ConfigurationException ;
4545
46- import com .ceph .rbd .jna .RbdImageInfo ;
4746import com .fasterxml .jackson .core .JsonProcessingException ;
4847import com .fasterxml .jackson .databind .JsonNode ;
4948import com .fasterxml .jackson .databind .ObjectMapper ;
@@ -1839,7 +1838,7 @@ public Answer createSnapshot(final CreateObjectCommand cmd) {
18391838 logger .debug ("Attempting to create RBD snapshot " + disk .getName () + "@" + snapshotName );
18401839 image .snapCreate (snapshotName );
18411840
1842- long rbdSnapshotSize = getRdbSnapshotSize (primaryPool .getSourceDir (), disk .getName (), snapshotName , primaryPool .getSourceHost (), primaryPool .getAuthUserName (), primaryPool .getAuthSecret ());
1841+ long rbdSnapshotSize = getRbdSnapshotSize (primaryPool .getSourceDir (), disk .getName (), snapshotName , primaryPool .getSourceHost (), primaryPool .getAuthUserName (), primaryPool .getAuthSecret ());
18431842 if (rbdSnapshotSize > 0 ) {
18441843 snapshotSize = rbdSnapshotSize ;
18451844 }
@@ -1882,7 +1881,7 @@ public Answer createSnapshot(final CreateObjectCommand cmd) {
18821881 }
18831882 }
18841883
1885- private long getRdbSnapshotSize (String poolPath , String diskName , String snapshotName , String rbdMonitor , String authUser , String authSecret ) {
1884+ private long getRbdSnapshotSize (String poolPath , String diskName , String snapshotName , String rbdMonitor , String authUser , String authSecret ) {
18861885 logger .debug ("Get RBD snapshot size for {}/{}@{}" , poolPath , diskName , snapshotName );
18871886 //cmd: rbd du <pool>/<disk-name>@<snapshot-name> --format json --mon-host <monitor-host> --id <user> --key <key> 2>/dev/null
18881887 String snapshotDetailsInJson = Script .runSimpleBashScript (String .format ("rbd du %s/%s@%s --format json --mon-host %s --id %s --key %s 2>/dev/null" , poolPath , diskName , snapshotName , rbdMonitor , authUser , authSecret ));
@@ -1893,15 +1892,15 @@ private long getRdbSnapshotSize(String poolPath, String diskName, String snapsho
18931892 for (JsonNode image : root .path ("images" )) {
18941893 if (snapshotName .equals (image .path ("snapshot" ).asText ())) {
18951894 long usedSizeInBytes = image .path ("used_size" ).asLong ();
1896- if (usedSizeInBytes > 0 ) {
1897- logger .debug ("RBD snapshot {}/{}@{} used size in bytes: {}" , poolPath , diskName , snapshotName , usedSizeInBytes );
1898- return usedSizeInBytes ;
1899- }
1895+ logger .debug ("RBD snapshot {}/{}@{} used size in bytes: {}" , poolPath , diskName , snapshotName , usedSizeInBytes );
1896+ return usedSizeInBytes ;
19001897 }
19011898 }
19021899 } catch (JsonProcessingException e ) {
1903- logger .error ("Unable to get the RBD snapshot size" , e );
1900+ logger .error ("Unable to get the RBD snapshot size, RBD snapshot cmd output: {}" , snapshotDetailsInJson , e );
19041901 }
1902+ } else {
1903+ logger .warn ("Failed to get RBD snapshot size for {}/{}@{} - no output for RBD snapshot cmd" , poolPath , diskName , snapshotName );
19051904 }
19061905
19071906 return 0 ;
0 commit comments