minor targetCli fix to work-around Ubuntu 18:04 bug

Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
Travis Glenn Hansen 2021-11-29 00:56:19 -07:00
parent d9bf3d7d2e
commit 3ab4023678
2 changed files with 27 additions and 10 deletions

View File

@ -353,7 +353,21 @@ delete ${iscsiName}
driver.ctx.logger.verbose("TargetCLI command: " + logCommand);
let response = await sshClient.exec(sshClient.buildCommand(command, args));
// https://github.com/democratic-csi/democratic-csi/issues/127
// https://bugs.launchpad.net/ubuntu/+source/python-configshell-fb/+bug/1776761
// can apply the linked patch with some modifications to overcome the
// KeyErrors or we can simply start a fake tty which does not seem to have
// a detrimental effect, only affects Ubuntu 18.04 and older
let options = {
pty: true,
};
let response = await sshClient.exec(
sshClient.buildCommand(command, args),
options
);
if (response.code != 0) {
throw new Error(response.stderr);
}
driver.ctx.logger.verbose(
"TargetCLI response: " + JSON.stringify(response)
);

View File

@ -33,25 +33,28 @@ class SshClient {
var conn = new Client();
if (client.options.connection.debug == true) {
client.options.connection.debug = function(msg) {
client.options.connection.debug = function (msg) {
client.debug(msg);
};
}
conn
.on("error", function(err) {
.on("error", function (err) {
client.debug("Client :: error");
reject(err);
})
.on("ready", function() {
.on("ready", function () {
client.debug("Client :: ready");
conn.exec(command, options, function(err, stream) {
//options.pty = true;
//options.env = {
// TERM: "",
//};
conn.exec(command, options, function (err, stream) {
if (err) reject(err);
let stderr;
let stdout;
stream
.on("close", function(code, signal) {
.on("close", function (code, signal) {
client.debug(
"Stream :: close :: code: " + code + ", signal: " + signal
);
@ -61,7 +64,7 @@ class SshClient {
resolve({ stderr, stdout, code, signal });
conn.end();
})
.on("data", function(data) {
.on("data", function (data) {
client.debug("STDOUT: " + data);
if (stream_proxy) {
stream_proxy.stdout.emit("data", ...arguments);
@ -71,7 +74,7 @@ class SshClient {
}
stdout = stdout.concat(data);
})
.stderr.on("data", function(data) {
.stderr.on("data", function (data) {
client.debug("STDERR: " + data);
if (stream_proxy) {
stream_proxy.stderr.emit("data", ...arguments);
@ -86,7 +89,7 @@ class SshClient {
.connect(client.options.connection);
if (stream_proxy) {
stream_proxy.on("kill", signal => {
stream_proxy.on("kill", (signal) => {
conn.end();
});
}