-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix PowerFlex 4.x issues with take & revert instance snapshots #12880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6a274ad
347d1be
2e0c5e3
38b9ec4
6dc796d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,6 +94,9 @@ public class ScaleIOGatewayClientImpl implements ScaleIOGatewayClient { | |
| private String password; | ||
| private String sessionKey; | ||
|
|
||
| private String gatewayVersion = null; | ||
| private int[] parsedVersion = null; | ||
|
|
||
| // The session token is valid for 8 hours from the time it was created, unless there has been no activity for 10 minutes | ||
| // Reference: https://cpsdocs.dellemc.com/bundle/PF_REST_API_RG/page/GUID-92430F19-9F44-42B6-B898-87D5307AE59B.html | ||
| private static final long MAX_VALID_SESSION_TIME_IN_HRS = 8; | ||
|
|
@@ -621,15 +624,27 @@ public boolean revertSnapshot(final String sourceSnapshotVolumeId, final String | |
| throw new CloudRuntimeException("Unable to revert, source snapshot volume and destination volume doesn't belong to same volume tree"); | ||
| } | ||
|
|
||
| String requestBody = buildOverwriteVolumeContentRequest(sourceSnapshotVolumeId); | ||
|
|
||
| Boolean overwriteVolumeContentStatus = post( | ||
| "/instances/Volume::" + destVolumeId + "/action/overwriteVolumeContent", | ||
| String.format("{\"srcVolumeId\":\"%s\",\"allowOnExtManagedVol\":\"TRUE\"}", sourceSnapshotVolumeId), Boolean.class); | ||
| requestBody, Boolean.class); | ||
| if (overwriteVolumeContentStatus != null) { | ||
| return overwriteVolumeContentStatus; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| private String buildOverwriteVolumeContentRequest(final String srcVolumeId) { | ||
| if (isVersionAtLeast(4, 0)) { | ||
| logger.debug("Using PowerFlex 4.0+ overwriteVolumeContent request body"); | ||
| return String.format("{\"srcVolumeId\":\"%s\"}", srcVolumeId); | ||
| } | ||
| else { | ||
|
owsferraro marked this conversation as resolved.
Outdated
|
||
| logger.debug("Using pre-4.0 overwriteVolumeContent request body"); | ||
| return String.format("{\"srcVolumeId\":\"%s\",\"allowOnExtManagedVol\":\"TRUE\"}", srcVolumeId); } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is allowOnExtManagedVol parameter removed from 4.5 onwards?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. based on public Dell Rest API documentation, the parameter was removed starting on version 4.0, the previous version 3.6 contains the parameter.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @owsferraro is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this parameter isn't required, but only have only tested on Powerflex 4.6 |
||
| } | ||
|
|
||
| @Override | ||
| public boolean mapVolumeToSdc(final String volumeId, final String sdcId) { | ||
| Preconditions.checkArgument(StringUtils.isNotEmpty(volumeId), "Volume id cannot be null"); | ||
|
|
@@ -1168,4 +1183,49 @@ private String getConnectionManagerStats() { | |
| sb.append("\n"); | ||
| return sb.toString(); | ||
| } | ||
|
|
||
| private String fetchGatewayVersion() { | ||
| try { | ||
| JsonNode node = get("/version", JsonNode.class); | ||
| if (node != null && node.isTextual()) { | ||
| return node.asText(); | ||
| } | ||
| if (node != null && node.has("version")) { | ||
| return node.get("version").asText(); | ||
| } | ||
| } catch (Exception e) { | ||
| logger.warn("Could not fetch PowerFlex gateway version: " + e.getMessage()); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| private int[] parseVersion(String version) { | ||
| if (StringUtils.isEmpty(version)) return new int[]{0, 0, 0}; | ||
| String[] parts = version.replaceAll("\"", "").split("\\."); | ||
| int[] parsed = new int[3]; | ||
| for (int i = 0; i < Math.min(parts.length, 3); i++) { | ||
| try { | ||
| parsed[i] = Integer.parseInt(parts[i].trim()); | ||
| } catch (NumberFormatException e) { | ||
| parsed[i] = 0; | ||
| } | ||
| } | ||
| return parsed; | ||
| } | ||
|
|
||
| private synchronized int[] getGatewayVersion() { | ||
| if (parsedVersion == null) { | ||
| gatewayVersion = fetchGatewayVersion(); | ||
| parsedVersion = parseVersion(gatewayVersion); | ||
| logger.info("PowerFlex Gateway version detected: " + gatewayVersion | ||
| + " => parsed: " + Arrays.toString(parsedVersion)); | ||
| } | ||
| return parsedVersion; | ||
| } | ||
|
|
||
| private boolean isVersionAtLeast(int major, int minor) { | ||
| int[] v = getGatewayVersion(); | ||
| if (v[0] != major) return v[0] > major; | ||
| return v[1] >= minor; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.