Skip to content

Commit

Permalink
fix(moac): mayastor pool state is shown as blank
Browse files Browse the repository at this point in the history
Well known problem with a decent workaround now. After experimenting
with tcp keep-alive that did not bring any relief I decided to brush
the dust of my previous mini-feature with restarting watcher connections
every n minutes. By default, as defined in the yaml file now, it is every
10 minutes. Most of the diff is about updating version of javascript
k8s client. That change will be merged to the upstream eventually.
What it does is that the MOD event is not emitted upon watcher restart
if the resource has not changed. Hence it makes the watcher restarts really
smooth. I have tested the change in Google Cloud.

Resolves: CAS-645 and CAS-630
  • Loading branch information
Jan Kryl committed Feb 25, 2021
1 parent 93156d9 commit c417ad3
Show file tree
Hide file tree
Showing 7 changed files with 140 additions and 117 deletions.
1 change: 1 addition & 0 deletions chart/templates/moac-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ spec:
- "--csi-address=$(CSI_ENDPOINT)"
- "--namespace=$(MY_POD_NAMESPACE)"
- "--port=4000"
- "--watcher-idle-timeout=600000"
- "--message-bus=nats"{{ if .Values.moacDebug }}
- "-vv"{{ end }}
env:
Expand Down
10 changes: 5 additions & 5 deletions csi/moac/node-composition.nix
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# This file has been generated by node2nix 1.8.0. Do not edit!
# This file has been generated by node2nix 1.9.0. Do not edit!

{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs-slim ? pkgs.nodejs-slim-12_x, nodejs ? pkgs."nodejs-12_x"}:
}, system ? builtins.currentSystem, nodejs-slim ? pkgs."nodejs-slim-12_x", nodejs ? pkgs."nodejs-12_x"}:

let
nodeEnv = import ./node-env.nix {
inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
inherit nodejs;
inherit (pkgs) stdenv lib python2 runCommand writeTextFile;
inherit pkgs nodejs;
inherit nodejs-slim;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl fetchgit;
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}
83 changes: 54 additions & 29 deletions csi/moac/node-env.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# This file originates from node2nix

{stdenv, nodejs-slim, nodejs, python2, utillinux, libtool, runCommand, writeTextFile}:
{lib, stdenv, nodejs-slim, nodejs, python2, pkgs, libtool, runCommand, writeTextFile}:

let
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
utillinux = if pkgs ? utillinux then pkgs.utillinux else pkgs.util-linux;

python = if nodejs ? python then nodejs.python else python2;

# Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
Expand Down Expand Up @@ -38,8 +41,8 @@ let
};

includeDependencies = {dependencies}:
stdenv.lib.optionalString (dependencies != [])
(stdenv.lib.concatMapStrings (dependency:
lib.optionalString (dependencies != [])
(lib.concatMapStrings (dependency:
''
# Bundle the dependencies of the package
mkdir -p node_modules
Expand Down Expand Up @@ -100,7 +103,7 @@ let
cd "$DIR/${packageName}"
${includeDependencies { inherit dependencies; }}
cd ..
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
'';

pinpointDependencies = {dependencies, production}:
Expand Down Expand Up @@ -161,12 +164,12 @@ let
''
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
${stdenv.lib.optionalString (dependencies != [])
${lib.optionalString (dependencies != [])
''
if [ -d node_modules ]
then
cd node_modules
${stdenv.lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
${lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
cd ..
fi
''}
Expand All @@ -183,7 +186,7 @@ let
cd "${packageName}"
${pinpointDependencies { inherit dependencies production; }}
cd ..
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
fi
'';

Expand Down Expand Up @@ -242,8 +245,8 @@ let
if(fs.existsSync("./package-lock.json")) {
var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
if(packageLock.lockfileVersion !== 1) {
process.stderr.write("Sorry, I only understand lock file version 1!\n");
if(![1, 2].includes(packageLock.lockfileVersion)) {
process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n");
process.exit(1);
}
Expand Down Expand Up @@ -344,8 +347,8 @@ let
cd "${packageName}"
runHook preRebuild
${stdenv.lib.optionalString bypassCache ''
${stdenv.lib.optionalString reconstructLock ''
${lib.optionalString bypassCache ''
${lib.optionalString reconstructLock ''
if [ -f package-lock.json ]
then
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
Expand All @@ -361,14 +364,14 @@ let
node ${addIntegrityFieldsScript}
''}
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
if [ "''${dontNpmInstall-}" != "1" ]
then
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
rm -f npm-shrinkwrap.json
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} install
fi
'';

Expand Down Expand Up @@ -396,8 +399,8 @@ let
stdenv.mkDerivation ({
name = "node_${name}-${version}";
buildInputs = [ tarWrapper python nodejs-slim nodejs ]
++ stdenv.lib.optional (stdenv.isLinux) utillinux
++ stdenv.lib.optional (stdenv.isDarwin) libtool
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;

inherit nodejs;
Expand Down Expand Up @@ -445,8 +448,8 @@ let
'';
} // extraArgs);

# Builds a development shell
buildNodeShell =
# Builds a node environment (a node_modules folder and a set of binaries)
buildNodeDependencies =
{ name
, packageName
, version
Expand All @@ -465,13 +468,13 @@ let

let
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];

nodeDependencies = stdenv.mkDerivation ({
in
stdenv.mkDerivation ({
name = "node-dependencies-${name}-${version}";

buildInputs = [ tarWrapper python nodejs ]
++ stdenv.lib.optional (stdenv.isLinux) utillinux
++ stdenv.lib.optional (stdenv.isDarwin) libtool
++ lib.optional (stdenv.isLinux) utillinux
++ lib.optional (stdenv.isDarwin) libtool
++ buildInputs;

inherit dontStrip; # Stripping may fail a build for some package deployments
Expand All @@ -491,7 +494,7 @@ let
# Create fake package.json to make the npm commands work properly
cp ${src}/package.json .
chmod 644 package.json
${stdenv.lib.optionalString bypassCache ''
${lib.optionalString bypassCache ''
if [ -f ${src}/package-lock.json ]
then
cp ${src}/package-lock.json .
Expand All @@ -500,23 +503,44 @@ let
# Go to the parent folder to make sure that all packages are pinpointed
cd ..
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
# Expose the executables that were installed
cd ..
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
mv ${packageName} lib
ln -s $out/lib/node_modules/.bin $out/bin
'';
} // extraArgs);

# Builds a development shell
buildNodeShell =
{ name
, packageName
, version
, src
, dependencies ? []
, buildInputs ? []
, production ? true
, npmFlags ? ""
, dontNpmInstall ? false
, bypassCache ? false
, reconstructLock ? false
, dontStrip ? true
, unpackPhase ? "true"
, buildPhase ? "true"
, ... }@args:

let
nodeDependencies = buildNodeDependencies args;
in
stdenv.mkDerivation {
name = "node-shell-${name}-${version}";

buildInputs = [ python nodejs ] ++ stdenv.lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
buildCommand = ''
mkdir -p $out/bin
cat > $out/bin/shell <<EOF
Expand All @@ -529,14 +553,15 @@ let

# Provide the dependencies in a development shell through the NODE_PATH environment variable
inherit nodeDependencies;
shellHook = stdenv.lib.optionalString (dependencies != []) ''
shellHook = lib.optionalString (dependencies != []) ''
export NODE_PATH=${nodeDependencies}/lib/node_modules
export PATH="${nodeDependencies}/bin:$PATH"
'';
};
in
{
buildNodeSourceDist = stdenv.lib.makeOverridable buildNodeSourceDist;
buildNodePackage = stdenv.lib.makeOverridable buildNodePackage;
buildNodeShell = stdenv.lib.makeOverridable buildNodeShell;
buildNodeSourceDist = lib.makeOverridable buildNodeSourceDist;
buildNodePackage = lib.makeOverridable buildNodePackage;
buildNodeDependencies = lib.makeOverridable buildNodeDependencies;
buildNodeShell = lib.makeOverridable buildNodeShell;
}
Loading

0 comments on commit c417ad3

Please sign in to comment.