From ea8fc84fa6c44dbcc8730c9f42fb0a11f874645c Mon Sep 17 00:00:00 2001 From: Travis Glenn Hansen Date: Tue, 22 Feb 2022 22:35:49 -0700 Subject: [PATCH] properly return topologies for local-hostpath Signed-off-by: Travis Glenn Hansen --- src/driver/controller-client-common/index.js | 6 ++++++ src/driver/controller-local-hostpath/index.js | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/driver/controller-client-common/index.js b/src/driver/controller-client-common/index.js index 955fffb..7ab1709 100644 --- a/src/driver/controller-client-common/index.js +++ b/src/driver/controller-client-common/index.js @@ -515,6 +515,11 @@ class ControllerClientCommonDriver extends CsiBaseDriver { driver.options.instance_id; } + let accessible_topology; + if (typeof this.getAccessibleTopology === "function") { + accessible_topology = await this.getAccessibleTopology(); + } + const res = { volume: { volume_id: name, @@ -522,6 +527,7 @@ class ControllerClientCommonDriver extends CsiBaseDriver { capacity_bytes: 0, content_source: volume_content_source, volume_context, + accessible_topology, }, }; diff --git a/src/driver/controller-local-hostpath/index.js b/src/driver/controller-local-hostpath/index.js index 9c22d02..e27734f 100644 --- a/src/driver/controller-local-hostpath/index.js +++ b/src/driver/controller-local-hostpath/index.js @@ -57,6 +57,22 @@ class ControllerLocalHostpathDriver extends ControllerClientCommonDriver { return []; } + /** + * List of topologies associated with the *volume* + * + * @returns array + */ + async getAccessibleTopology() { + const response = await super.NodeGetInfo(...arguments); + return [ + { + segments: { + [NODE_TOPOLOGY_KEY_NAME]: response.node_id, + }, + }, + ]; + } + /** * Add node topologies *