Skip to content

Commit

Permalink
fix(backend): don't fail on stderr (#184)
Browse files Browse the repository at this point in the history
* update: bump sysdig to 0.36.1
* fix(server): don't always fail on stderr

sysdig-CLA-1.0-signed-off-by: Roberto Scolaro <roberto.scolaro@sysdig.com>

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
  • Loading branch information
therealbobo authored Apr 22, 2024
1 parent 8c2dba3 commit 6425802
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sysdig/sysdig:0.27.1
FROM sysdig/sysdig:0.36.1



Expand Down
4 changes: 2 additions & 2 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

SYSDIG_VERSION="0.35.4"
SYSDIG_VERSION_MAC="0.35.4"
SYSDIG_VERSION="0.36.1"
SYSDIG_VERSION_MAC="0.36.1"

# Env parameters
# - CLEANUP (default: true)
Expand Down
37 changes: 18 additions & 19 deletions ember-electron/backend/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ class Controller {
//
let execState = 'STARTED';

let stderrPresent = false;
let errorMessage;

return new Promise((resolve, reject) => {

prc.stdout.on('data', (data) => {
if (execState !== 'FAILED') {
if (response) {
Expand All @@ -85,22 +89,8 @@ class Controller {

prc.stderr.on('data', (data) => {
console.error(`${this.sysdigPath}/${exe}`, args, 'error read from STDERR', data);

if (execState !== 'FAILED') {
const message = { reason: data };

if (response) {
response.status(500);

if (execState === 'STARTED') {
response.send(JSON.stringify(message));
}
}

execState = 'FAILED';

reject(message);
}
stderrPresent = true;
errorMessage = {reason: data};
});

prc.on('error', (err) => {
Expand Down Expand Up @@ -135,16 +125,25 @@ class Controller {
response.end();
} else if (execState === 'STARTED') {
// Send 'no content' if nothing happened
response.status(204).send();
if(stderrPresent) {
response.status(500);
response.send(JSON.stringify(errorMessage));
} else {
response.status(204).send();
}
}
}

if (execState !== 'FAILED') {
if (code === 0) {
resolve({code});
} else {
const message = { reason: 'Unexpected exit', details: code };
reject(message);
if(stderrPresent) {
reject(errorMessage);
} else {
const message = { reason: 'Unexpected exit', details: code };
reject(message);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sysdig-inspect",
"version": "0.10.1",
"version": "0.10.2",
"description": "Sysdig Inspect",
"repository": {
"type": "git",
Expand Down

0 comments on commit 6425802

Please sign in to comment.