Skip to content

Conversation

@sandeeplocharla
Copy link
Collaborator

Description

This PR has the following changes:

  1. Create iSCSI type cloudstack volume
  2. Delete iSCSI type cloudstack volume
  3. Enter and Cancel Maintenance when storagepool has CS volumes

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  1. https://netapp.zoom.us/rec/share/r0rh_HhXD_lZNuppLeGGMk4Y4jg8-p9DXwIB_GD2e-uEslEH5geYzchrYcBDY7PJ.WjzaTxXoGt0B8nqe?startTime=1768919430000
    Passcode: n=AE=.C9
  • Create ISCSI type Primary storage pool
  • Create Compute & Disk offering.
  • Create an instance with compute & disk offering to create both ROOT & DATA disks via ontap plugin.
  • Add additional CS Volume with ontap plugin and allocate it to the instance created.
  • Disable, Re-Enable Storage Pool (with CS Volumes)
  • Enter, Cancel Maintenance of Storage Pool (with CS Volumes)
  • Delete Instance + Expunge Volumes
  • Disable, Re-Enable Storage Pool (without CS Volumes)
  • Enter, Cancel Maintenance of Storage Pool (without CS Volumes)
  • Delete Storage Pool
  1. https://netapp.zoom.us/rec/share/Ax74XcCVkQtXglaNwNb9rTcn_1k1TvxplvaLmXTdFxjz7DeQixmiqj-uwX0QXjz0.EwnlsurMGr3jLku3?startTime=1768920957000
    Passcode: $%j3+K4B
  • Create an instance with compute & disk offering to create both ROOT & DATA disks via Default Primary & ontap plugins.
  • Add additional CS Volume with ontap plugin and allocate it to the instance created.
  • Disable, Re-Enable Storage Pool (with CS Volumes)
  • Enter, Cancel Maintenance of Storage Pool (with CS Volumes)
  • Delete Instance + Expunge Volumes
  • Disable, Re-Enable Storage Pool (without CS Volumes)
  • Enter, Cancel Maintenance of Storage Pool (without CS Volumes)
  • Delete Storage Pool

Observations:

Though we have increased retries to wait for discovery of luns, the additional volume attachment still times out, so, it needs a manual retry.
When placed into Maintenance mode, Instance is getting Stopped in the first case while it remains in Running state in the second case. We currently don't have any code attributing to this behaviour in our plugin code. Need to understand why cloudstack is behaving this way.

I've also tested force delete of storage pool when CS volumes were present, but, haven't covered it in these recordings.

if (volumeVO != null) {
volumeVO.setPath(null);
if (cloudStackVolume.getLun().getUuid() != null) {
volumeVO.setFolder(cloudStackVolume.getLun().getUuid());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment on the need for this

if (mapResp != null && mapResp.containsKey(Constants.LOGICAL_UNIT_NUMBER)) {
String lunNumber = mapResp.get(Constants.LOGICAL_UNIT_NUMBER);
s_logger.info("ensureLunMapped: Existing LunMap found for LUN [{}] in igroup [{}] with LUN number [{}]", lunName, accessGroupName, lunNumber);
return lunNumber;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a TODO comment to keep an eye on possibility of duplicate LUN for luns

VolumeVO volumeVO = volumeDao.findById(volInfo.getId());
if (volumeVO != null) {
String iscsiPath = Constants.SLASH + storagePool.getPath() + Constants.SLASH + lunNumber;
volumeVO.set_iScsiName(iscsiPath);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove any redundant code

return false;
}
// Set the aggregates which are according to the storage requirements
for (Aggregate aggr : aggrs) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for rebase issue here

Map<String, Object> queryParams = Map.of("allow_delete_while_mapped", "true");
try {
sanFeignClient.deleteLun(authHeader, cloudstackVolume.getLun().getUuid(), queryParams);
} catch (Exception ex) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if feignException should be added

String authHeader = Utility.generateAuthHeader(storage.getUsername(), storage.getPassword());
sanFeignClient.deleteLunMap(authHeader, lunUUID, igroupUUID);
s_logger.info("disableLogicalAccess: LunMap deleted successfully.");
} catch (Exception e) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use feignException

return null;
}

/**

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its would be better to skip these comments on func as some of the information are related to our plugin internal design.

VolumeInfo volInfo = (VolumeInfo) dataObject;

// Create the backend storage object (LUN for iSCSI, no-op for NFS)
CloudStackVolume created = createCloudStackVolume(dataStore, volInfo, details);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a better name would be more meaningful.

}

// Determine scope ID based on storage pool scope (cluster or zone level igroup)
long scopeId = (storagePool.getScope() == ScopeType.CLUSTER)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajiv-jain-netapp Can we discuss on including scope id and scope both for igroup name. It would be better to have only storage pool name reference in igroup name . Having scope or any other entity creates a dependency of their lifecycle on igroup.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piyush5netapp lets discuss in tomorrow scrum

return 0L;
}
} catch (Exception ignore) {
// If FS check fails for any reason, fall back to blockdev call

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets add a logger here

}

// Determine scope ID based on storage pool scope (cluster or zone level igroup)
long scopeId = (storagePool.getScope() == ScopeType.CLUSTER)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piyush5netapp lets discuss in tomorrow scrum

volumeVO.setPath(iscsiPath);
s_logger.info("createAsync: Volume [{}] iSCSI path set to {}", volumeVO.getId(), iscsiPath);

} else if (ProtocolType.NFS3.name().equalsIgnoreCase(details.get(Constants.PROTOCOL))) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not seeing anything significant for NFS block. I would recommend to not have if-else for protocol atleast for this situation, we should handle it via strategy concrete implementation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciated the method-level comments that reference the algorithms used in each method. However, since this is open-source code, I recommend moving these details to the design specification instead of keeping them in the code. You can add a separate section in the spec to capture this information.
In the code, we can retain comments only for complex conditions or specific use cases for future reference.

// ManagedNFS qcow2 backing file deletion handled by KVM host/libvirt; nothing to do via ONTAP REST.
s_logger.info("deleteAsync: ManagedNFS volume {} no-op ONTAP deletion", data.getId());
// NFS file deletion is handled by the hypervisor; no ONTAP REST call needed
s_logger.info("deleteAsync: ManagedNFS volume {} - file deletion handled by hypervisor", data.getId());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here as well

VirtualMachine.State.Destroyed,
VirtualMachine.State.Expunging,
VirtualMachine.State.Error).contains(vm.getState())) {
s_logger.debug("revokeAccess: Volume [{}] is still attached to VM [{}] in state [{}], skipping revokeAccess",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, this logger can be made error instead debug, to highlight in the logs


@JsonProperty("protocol")
private ProtocolEnum protocol = ProtocolEnum.mixed;
private ProtocolEnum protocol = null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is good catch, since we have 1-1 mapping between igroup and storage-pool, we should not keep protocol type as mixed, lets keep as per the storage-pool protocol.


@JsonInclude(JsonInclude.Include.NON_NULL)
public static class Links { }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no code change in this file. Can you exclude this file?

CloudStackVolume getCloudStackVolume(CloudStackVolume cloudstackVolume) {
//TODO
return null;
public void copyCloudStackVolume(CloudStackVolume cloudstackVolume) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is added for which workflow?

if (callback == null) {
throw new InvalidParameterValueException("createAsync: callback should not be null");
}

Copy link

@suryag1201 suryag1201 Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add dataObject null condition check, also add error logger

VolumeInfo volInfo = (VolumeInfo) dataObject;

// Create the backend storage object (LUN for iSCSI, no-op for NFS)
CloudStackVolume created = createCloudStackVolume(dataStore, volInfo, details);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can also come for snapshot ?

public String getName() {
s_logger.trace("OntapPrimaryDatastoreProvider: getName: Called");
return "ONTAP Primary Datastore Provider";
return "ONTAP";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add this string to some constant and use it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants