fix invalid syntax

Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
Travis Glenn Hansen 2022-04-06 12:18:05 -06:00
parent 3ba6bf5c8e
commit ed4a065b6b
7 changed files with 45 additions and 86 deletions

View File

@ -1,59 +0,0 @@
FROM debian:10-slim
ENV DEBIAN_FRONTEND=noninteractive
ARG TARGETPLATFORM
ARG BUILDPLATFORM
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG=en_US.utf8 NODE_VERSION=v12.20.0
RUN echo "I am running on $BUILDPLATFORM, building for $TARGETPLATFORM"
# install node
RUN apt-get update && apt-get install -y wget xz-utils
ADD docker/node-installer.sh /usr/local/sbin
RUN chmod +x /usr/local/sbin/node-installer.sh && node-installer.sh
ENV PATH=/usr/local/lib/nodejs/bin:$PATH
# node service requirements
RUN apt-get update && \
apt-get install -y e2fsprogs xfsprogs fatresize dosfstools nfs-common cifs-utils sudo && \
rm -rf /var/lib/apt/lists/*
# controller requirements
RUN apt-get update && \
apt-get install -y ansible && \
rm -rf /var/lib/apt/lists/*
# npm requirements
# gcc and g++ required by grpc-usd until proper upstream support
RUN apt-get update && \
apt-get install -y python make gcc g++ && \
rm -rf /var/lib/apt/lists/*
# install wrappers
ADD docker/iscsiadm /usr/local/sbin
RUN chmod +x /usr/local/sbin/iscsiadm
ADD docker/multipath /usr/local/sbin
RUN chmod +x /usr/local/sbin/multipath
# Run as a non-root user
RUN useradd --create-home csi \
&& mkdir /home/csi/app \
&& chown -R csi: /home/csi
WORKDIR /home/csi/app
USER csi
COPY package*.json ./
RUN npm install
COPY --chown=csi:csi . .
USER root
EXPOSE 50051
ENTRYPOINT [ "bin/democratic-csi" ]

View File

@ -115,7 +115,7 @@ try {
options
);
} catch (err) {
logger.error(err.toString());
logger.error(`${err.toString()} ${err.stack}`);
process.exit(1);
}

View File

@ -21,7 +21,7 @@ class ControllerZfsGenericDriver extends ControllerZfsBaseDriver {
}
async getZetabyte() {
return registry.get(`${__REGISTRY_NS__}:zb`, () => {
return registry.getAsync(`${__REGISTRY_NS__}:zb`, async () => {
const execClient = this.getExecClient();
const options = {};
options.executor = new ZfsSshProcessManager(execClient);

View File

@ -35,17 +35,17 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver {
return new LocalCliExecClient({
logger: this.ctx.logger,
});
})
});
}
async getZetabyte() {
return registry.get(`${__REGISTRY_NS__}:zb`, () => {
return registry.getAsync(`${__REGISTRY_NS__}:zb`, async () => {
const execClient = this.getExecClient();
const options = {};
options.executor = execClient;
options.idempotent = true;
/*
if (
this.options.zfs.hasOwnProperty("cli") &&
@ -55,7 +55,7 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver {
options.paths = this.options.zfs.cli.paths;
}
*/
// use env based paths to allow for custom wrapper scripts to chroot to the host
options.paths = {
zfs: "zfs",
@ -63,13 +63,13 @@ class ControllerZfsLocalDriver extends ControllerZfsBaseDriver {
sudo: "sudo",
chroot: "chroot",
};
options.sudo = _.get(this.options, "zfs.cli.sudoEnabled", false);
if (typeof this.setZetabyteCustomOptions === "function") {
await this.setZetabyteCustomOptions(options);
}
return new Zetabyte(options);
});
}

View File

@ -1909,7 +1909,7 @@ class FreeNASApiDriver extends CsiBaseDriver {
}
async getTrueNASHttpApiClient() {
return registry.get(`${__REGISTRY_NS__}:api_client`, () => {
return registry.getAsync(`${__REGISTRY_NS__}:api_client`, async () => {
const httpClient = await this.getHttpClient();
return new TrueNASApiClient(httpClient, this.ctx.cache);
});

View File

@ -36,12 +36,12 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
}
async getZetabyte() {
return registry.get(`${__REGISTRY_NS__}:zb`, () => {
return registry.getAsync(`${__REGISTRY_NS__}:zb`, async () => {
const sshClient = this.getExecClient();
const options = {};
options.executor = new ZfsSshProcessManager(sshClient);
options.idempotent = true;
if (
this.options.zfs.hasOwnProperty("cli") &&
this.options.zfs.cli &&
@ -49,13 +49,13 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
) {
options.paths = this.options.zfs.cli.paths;
}
options.sudo = _.get(this.options, "zfs.cli.sudoEnabled", false);
if (typeof this.setZetabyteCustomOptions === "function") {
await this.setZetabyteCustomOptions(options);
}
return new Zetabyte(options);
});
}
@ -95,19 +95,21 @@ class FreeNASSshDriver extends ControllerZfsBaseDriver {
}
async getHttpClient(autoDetectVersion = true) {
const autodetectkey = autoDetectVersion === true ? 1 : 0
return registry.get(`${__REGISTRY_NS__}:http_client:autoDetectVersion_${autodetectkey}`, () => {
const client = new HttpClient(this.options.httpConnection);
client.logger = this.ctx.logger;
if (autoDetectVersion && !!!this.options.httpConnection.apiVersion) {
const apiVersion = await this.getApiVersion();
client.setApiVersion(apiVersion);
const autodetectkey = autoDetectVersion === true ? 1 : 0;
return registry.getAsync(
`${__REGISTRY_NS__}:http_client:autoDetectVersion_${autodetectkey}`,
async () => {
const client = new HttpClient(this.options.httpConnection);
client.logger = this.ctx.logger;
if (autoDetectVersion && !!!this.options.httpConnection.apiVersion) {
const apiVersion = await this.getApiVersion();
client.setApiVersion(apiVersion);
}
return client;
}
return client;
});
);
}
getDriverShareType() {

View File

@ -27,6 +27,22 @@ class Registry {
}
}
async getAsync(key, initialValue = null) {
const val = this.data[key];
if (val) {
return val;
}
if (typeof initialValue == "function") {
initialValue = await initialValue();
}
if (initialValue) {
this.put(key, initialValue);
return this.data[key];
}
}
delete(key) {
delete this.data[key];
}