more conformant behavior regarding volume/snapshot sizes
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
parent
09d55a9653
commit
f0ea73fce6
|
|
@ -347,6 +347,7 @@ Install `democratic-csi` as usual with `volumeSnapshotClasses` defined as approp
|
||||||
|
|
||||||
- https://kubernetes.io/docs/concepts/storage/volume-snapshots/
|
- https://kubernetes.io/docs/concepts/storage/volume-snapshots/
|
||||||
- https://github.com/kubernetes-csi/external-snapshotter#usage
|
- https://github.com/kubernetes-csi/external-snapshotter#usage
|
||||||
|
- https://github.com/democratic-csi/democratic-csi/issues/129#issuecomment-961489810
|
||||||
|
|
||||||
# Migrating from freenas-provisioner and freenas-iscsi-provisioner
|
# Migrating from freenas-provisioner and freenas-iscsi-provisioner
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,10 @@ capability {
|
||||||
access_mode = "single-node-writer"
|
access_mode = "single-node-writer"
|
||||||
attachment_mode = "file-system"
|
attachment_mode = "file-system"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mount_options {
|
||||||
|
# ext4|xfs
|
||||||
|
# default is ext4 when left unset
|
||||||
|
#fs_type = "ext4"
|
||||||
|
#mount_flags = ["noatime"]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,7 @@ capability {
|
||||||
access_mode = "multi-node-multi-writer"
|
access_mode = "multi-node-multi-writer"
|
||||||
attachment_mode = "file-system"
|
attachment_mode = "file-system"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mount_options {
|
||||||
|
mount_flags = ["noatime", "nfsvers=3"]
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -571,6 +571,7 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no capacity_range specified set a required_bytes at least
|
||||||
if (
|
if (
|
||||||
!call.request.capacity_range ||
|
!call.request.capacity_range ||
|
||||||
Object.keys(call.request.capacity_range).length === 0
|
Object.keys(call.request.capacity_range).length === 0
|
||||||
|
|
@ -592,16 +593,19 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: avoid the urge to templatize this given the name length limits for zvols
|
|
||||||
* ie: namespace-name may quite easily exceed 58 chars
|
|
||||||
*/
|
|
||||||
const datasetName = datasetParentName + "/" + name;
|
|
||||||
let capacity_bytes =
|
let capacity_bytes =
|
||||||
call.request.capacity_range.required_bytes ||
|
call.request.capacity_range.required_bytes ||
|
||||||
call.request.capacity_range.limit_bytes;
|
call.request.capacity_range.limit_bytes;
|
||||||
|
|
||||||
if (capacity_bytes && driverZfsResourceType == "volume") {
|
if (!capacity_bytes) {
|
||||||
|
//should never happen, value must be set
|
||||||
|
throw new GrpcError(
|
||||||
|
grpc.status.INVALID_ARGUMENT,
|
||||||
|
`volume capacity is required (either required_bytes or limit_bytes)`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (capacity_bytes && driverZfsResourceType == "volume") {
|
||||||
//make sure to align capacity_bytes with zvol blocksize
|
//make sure to align capacity_bytes with zvol blocksize
|
||||||
//volume size must be a multiple of volume block size
|
//volume size must be a multiple of volume block size
|
||||||
capacity_bytes = zb.helpers.generateZvolSize(
|
capacity_bytes = zb.helpers.generateZvolSize(
|
||||||
|
|
@ -609,13 +613,7 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||||
zvolBlocksize
|
zvolBlocksize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!capacity_bytes) {
|
|
||||||
//should never happen, value must be set
|
|
||||||
throw new GrpcError(
|
|
||||||
grpc.status.INVALID_ARGUMENT,
|
|
||||||
`volume capacity is required (either required_bytes or limit_bytes)`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure *actual* capacity is not greater than limit
|
// ensure *actual* capacity is not greater than limit
|
||||||
if (
|
if (
|
||||||
|
|
@ -629,6 +627,12 @@ class ControllerZfsSshBaseDriver extends CsiBaseDriver {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE: avoid the urge to templatize this given the name length limits for zvols
|
||||||
|
* ie: namespace-name may quite easily exceed 58 chars
|
||||||
|
*/
|
||||||
|
const datasetName = datasetParentName + "/" + name;
|
||||||
|
|
||||||
// ensure volumes with the same name being requested a 2nd time but with a different size fails
|
// ensure volumes with the same name being requested a 2nd time but with a different size fails
|
||||||
try {
|
try {
|
||||||
let properties = await zb.zfs.get(datasetName, ["volsize", "refquota"]);
|
let properties = await zb.zfs.get(datasetName, ["volsize", "refquota"]);
|
||||||
|
|
|
||||||
|
|
@ -2044,6 +2044,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no capacity_range specified set a required_bytes at least
|
||||||
if (
|
if (
|
||||||
!call.request.capacity_range ||
|
!call.request.capacity_range ||
|
||||||
Object.keys(call.request.capacity_range).length === 0
|
Object.keys(call.request.capacity_range).length === 0
|
||||||
|
|
@ -2065,23 +2066,10 @@ class FreeNASApiDriver extends CsiBaseDriver {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: avoid the urge to templatize this given the name length limits for zvols
|
|
||||||
* ie: namespace-name may quite easily exceed 58 chars
|
|
||||||
*/
|
|
||||||
const datasetName = datasetParentName + "/" + name;
|
|
||||||
let capacity_bytes =
|
let capacity_bytes =
|
||||||
call.request.capacity_range.required_bytes ||
|
call.request.capacity_range.required_bytes ||
|
||||||
call.request.capacity_range.limit_bytes;
|
call.request.capacity_range.limit_bytes;
|
||||||
|
|
||||||
if (capacity_bytes && driverZfsResourceType == "volume") {
|
|
||||||
//make sure to align capacity_bytes with zvol blocksize
|
|
||||||
//volume size must be a multiple of volume block size
|
|
||||||
capacity_bytes = zb.helpers.generateZvolSize(
|
|
||||||
capacity_bytes,
|
|
||||||
zvolBlocksize
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!capacity_bytes) {
|
if (!capacity_bytes) {
|
||||||
//should never happen, value must be set
|
//should never happen, value must be set
|
||||||
throw new GrpcError(
|
throw new GrpcError(
|
||||||
|
|
@ -2091,10 +2079,24 @@ class FreeNASApiDriver extends CsiBaseDriver {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure *actual* capacity is not too small
|
// ensure *actual* capacity is not too small
|
||||||
if (minimum_volume_size > 0 && capacity_bytes < minimum_volume_size) {
|
if (
|
||||||
throw new GrpcError(
|
capacity_bytes > 0 &&
|
||||||
grpc.status.OUT_OF_RANGE,
|
minimum_volume_size > 0 &&
|
||||||
`volume capacity is smaller than the minimum: ${minimum_volume_size}`
|
capacity_bytes < minimum_volume_size
|
||||||
|
) {
|
||||||
|
//throw new GrpcError(
|
||||||
|
// grpc.status.OUT_OF_RANGE,
|
||||||
|
// `volume capacity is smaller than the minimum: ${minimum_volume_size}`
|
||||||
|
//);
|
||||||
|
capacity_bytes = minimum_volume_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (capacity_bytes && driverZfsResourceType == "volume") {
|
||||||
|
//make sure to align capacity_bytes with zvol blocksize
|
||||||
|
//volume size must be a multiple of volume block size
|
||||||
|
capacity_bytes = zb.helpers.generateZvolSize(
|
||||||
|
capacity_bytes,
|
||||||
|
zvolBlocksize
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2110,6 +2112,12 @@ class FreeNASApiDriver extends CsiBaseDriver {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NOTE: avoid the urge to templatize this given the name length limits for zvols
|
||||||
|
* ie: namespace-name may quite easily exceed 58 chars
|
||||||
|
*/
|
||||||
|
const datasetName = datasetParentName + "/" + name;
|
||||||
|
|
||||||
// ensure volumes with the same name being requested a 2nd time but with a different size fails
|
// ensure volumes with the same name being requested a 2nd time but with a different size fails
|
||||||
try {
|
try {
|
||||||
let properties = await httpApiClient.DatasetGet(datasetName, [
|
let properties = await httpApiClient.DatasetGet(datasetName, [
|
||||||
|
|
@ -3992,6 +4000,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
|
||||||
size_bytes = getLargestNumber(
|
size_bytes = getLargestNumber(
|
||||||
properties.referenced.rawvalue,
|
properties.referenced.rawvalue,
|
||||||
properties.logicalreferenced.rawvalue
|
properties.logicalreferenced.rawvalue
|
||||||
|
// TODO: perhaps include minimum volume size here?
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// get the size of the parent volume
|
// get the size of the parent volume
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue