From 00c025df8e51b5c010e88b1e15eb875051db940c Mon Sep 17 00:00:00 2001 From: Michel Peterson Date: Sun, 4 Jan 2026 08:53:55 +0000 Subject: [PATCH] update devcontainer image, enhance contributing guide, and implement mutex for PCS commands --- .devcontainer/devcontainer.json | 4 ++- CONTRIBUTING.md | 4 +++ Vagrantfile | 3 ++ src/driver/controller-zfs-generic/index.js | 38 ++++++++++++---------- 4 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 22e0c6b..fd97ce9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,9 @@ { "name": "democratic-csi", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm", + // regarding versioning the first number is the devcontainer image version, + // the second is the Node.js version, and the third is the OS version. + "image": "mcr.microsoft.com/devcontainers/typescript-node:4-20-bookworm", // Features to add to the dev container. More info: https://containers.dev/features. "features": { diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ae44c5..277b4f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,6 +62,10 @@ cd ~/democratic-csi ./hack/run.sh -c ./hack/config.yaml ``` +>![Note] +> For running tests with democratic-csi the authentication needs to be disabled, as +> it always initiates connections to the share without authentication. + ##### Keeping Files in Sync Use these methods to keep your local files synchronized with the Vagrant VM: diff --git a/Vagrantfile b/Vagrantfile index 0d5c5d5..0238103 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,6 +18,9 @@ Vagrant.configure("2") do |config| end config.vm.provision "shell", inline: <<-SHELL + # force version 20.x of nodejs + curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - + sudo apt-get update -y # for building dependecies and executing node diff --git a/src/driver/controller-zfs-generic/index.js b/src/driver/controller-zfs-generic/index.js index b234078..084b440 100644 --- a/src/driver/controller-zfs-generic/index.js +++ b/src/driver/controller-zfs-generic/index.js @@ -20,6 +20,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver { this.targetCliMutex = new Mutex(); this.nvmetCliMutex = new Mutex(); this.spdkCliMutex = new Mutex(); + this.pcsMutex = new Mutex(); } getExecClient() { @@ -1000,24 +1001,27 @@ save_config filename=${this.options.nvmeof.shareStrategySpdkCli.configPath} let options = { pty: true, }; - let response = await execClient.exec( - execClient.buildCommand(command, args), - options - ); - driver.ctx.logger.verbose( - "pcs response: " + JSON.stringify(response) - ); - - // Handle idempotence for create commands - if (response.code == 1 && response.stdout.includes("already exists")) { - driver.ctx.logger.verbose("pcs resource already exists, ignoring error (setting response.code=0)"); - response.code = 0; - } - if (response.code != 0) { - throw response; - } - return response; + return driver.pcsMutex.runExclusive(async () => { + let response = await execClient.exec( + execClient.buildCommand(command, args), + options + ); + driver.ctx.logger.verbose( + "pcs response: " + JSON.stringify(response) + ); + + // Handle idempotence for create commands + if (response.code == 1 && response.stdout.includes("already exists")) { + driver.ctx.logger.verbose("pcs resource already exists, ignoring error (setting response.code=0)"); + response.code = 0; + } + + if (response.code != 0) { + throw response; + } + return response; + }); } async targetCliCommand(data) {