Skip to content

Commit

Permalink
core: handle missing allocation policy/format when converting
Browse files Browse the repository at this point in the history
If allocation policy or format were not passed to the disk conversion
endpoint it will fail to setup monitoring because of NPE.

This patch uses the existing allocation policy or format when it's
missing to generate the message.

Bug-Url: https://bugzilla.redhat.com/2076042
Signed-off-by: Benny Zlotnik <bzlotnik@redhat.com>
  • Loading branch information
bennyz authored and ahadas committed Apr 18, 2022
1 parent b2384c6 commit 788657d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,18 @@ protected LockProperties applyLockProperties(LockProperties lockProperties) {
@Override
public Map<String, String> getJobMessageProperties() {
if (jobProperties == null) {
String allocationPolicy = getParameters().getPreallocation() != null ?
getParameters().getPreallocation().toString() :
getDiskImage().getVolumeType().toString();

String diskFormat = getParameters().getVolumeFormat() != null ?
getParameters().getVolumeFormat().toString() :
getDiskImage().getVolumeFormat().toString();

jobProperties = super.getJobMessageProperties();
jobProperties.put("diskname", getDiskImage().getName());
jobProperties.put("allocationpolicy", getParameters().getPreallocation().toString());
jobProperties.put("diskformat", getParameters().getVolumeFormat().toString());
jobProperties.put("allocationpolicy", allocationPolicy);
jobProperties.put("diskformat", diskFormat);
}

return super.getJobMessageProperties();
Expand Down

0 comments on commit 788657d

Please sign in to comment.