mirror of
https://github.com/democratic-csi/democratic-csi.git
synced 2026-10-18 09:24:29 +02:00
csi-test conformance, relax iscsi name length
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const { CsiBaseDriver } = require("../index");
|
||||
const { GrpcError, grpc } = require("../../utils/grpc");
|
||||
const cp = require("child_process");
|
||||
const fs = require("fs");
|
||||
const semver = require("semver");
|
||||
|
||||
/**
|
||||
@@ -329,6 +330,10 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
|
||||
]);
|
||||
}
|
||||
|
||||
async directoryExists(path) {
|
||||
return fs.existsSync(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a volume doing in essence the following:
|
||||
* 1. create directory
|
||||
@@ -353,11 +358,28 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
|
||||
);
|
||||
}
|
||||
|
||||
if (call.request.volume_capabilities) {
|
||||
if (
|
||||
call.request.volume_capabilities &&
|
||||
call.request.volume_capabilities.length > 0
|
||||
) {
|
||||
const result = this.assertCapabilities(call.request.volume_capabilities);
|
||||
if (result.valid !== true) {
|
||||
throw new GrpcError(grpc.status.INVALID_ARGUMENT, result.message);
|
||||
}
|
||||
} else {
|
||||
throw new GrpcError(
|
||||
grpc.status.INVALID_ARGUMENT,
|
||||
"missing volume_capabilities"
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!call.request.capacity_range ||
|
||||
Object.keys(call.request.capacity_range).length === 0
|
||||
) {
|
||||
call.request.capacity_range = {
|
||||
required_bytes: 1073741824, // meaningless
|
||||
};
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -431,6 +453,13 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(await driver.directoryExists(source_path))) {
|
||||
throw new GrpcError(
|
||||
grpc.status.NOT_FOUND,
|
||||
`invalid volume_content_source path: ${source_path}`
|
||||
);
|
||||
}
|
||||
|
||||
driver.ctx.logger.debug("controller source path: %s", source_path);
|
||||
response = await driver.cloneDir(source_path, volume_path);
|
||||
}
|
||||
@@ -630,7 +659,10 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
|
||||
const volume_path = driver.getControllerVolumePath(source_volume_id);
|
||||
const snapshot_path = driver.getControllerSnapshotPath(snapshot_id);
|
||||
|
||||
await driver.cloneDir(volume_path, snapshot_path);
|
||||
// do NOT overwrite existing snapshot
|
||||
if (!(await driver.directoryExists(snapshot_path))) {
|
||||
await driver.cloneDir(volume_path, snapshot_path);
|
||||
}
|
||||
|
||||
return {
|
||||
snapshot: {
|
||||
@@ -681,6 +713,25 @@ class ControllerClientCommonDriver extends CsiBaseDriver {
|
||||
*/
|
||||
async ValidateVolumeCapabilities(call) {
|
||||
const driver = this;
|
||||
|
||||
const volume_id = call.request.volume_id;
|
||||
if (!volume_id) {
|
||||
throw new GrpcError(grpc.status.INVALID_ARGUMENT, `missing volume_id`);
|
||||
}
|
||||
|
||||
const capabilities = call.request.volume_capabilities;
|
||||
if (!capabilities || capabilities.length === 0) {
|
||||
throw new GrpcError(grpc.status.INVALID_ARGUMENT, `missing capabilities`);
|
||||
}
|
||||
|
||||
const volume_path = driver.getControllerVolumePath(volume_id);
|
||||
if (!(await driver.directoryExists(volume_path))) {
|
||||
throw new GrpcError(
|
||||
grpc.status.NOT_FOUND,
|
||||
`invalid volume_id: ${volume_id}`
|
||||
);
|
||||
}
|
||||
|
||||
const result = this.assertCapabilities(call.request.volume_capabilities);
|
||||
|
||||
if (result.valid !== true) {
|
||||
|
||||
Reference in New Issue
Block a user