Respect follow option on logs endpoint (default false) - #437
Conversation
| path: '/tasks/' + this.id + '/logs?', | ||
| method: 'GET', | ||
| isStream: args.opts.follow || false, | ||
| isStream: (typeof(args.opts.follow) != 'undefined') ? args.opts.follow : false, |
There was a problem hiding this comment.
How is this an improvement or different from the original? This won't coalesce to false if something false-y like null is provided here.
| path: '/services/' + this.id + '/logs?', | ||
| method: 'GET', | ||
| isStream: true, | ||
| isStream: (typeof(args.opts.follow) != 'undefined') ? args.opts.follow : false, |
There was a problem hiding this comment.
This could also use the original logic from lib/task.js that you replaced.
Hey. Could you review the last commit? I changed the three endpoints that can have logs: container, service, and task. Thanks |
Seikho
commented
Feb 26, 2018
Looks good to me! |
apocas
commented
Feb 26, 2018
Completely agree on following the Docker's default behavior. Since we are changing dockerode's default behavior, can't publish this in a minor. |
jysperm
commented
Apr 18, 2018
I think this PR introduced a breaking change and published as a patch version (2.5.5).
|
aguegu
commented
Oct 10, 2018
aguegu
commented
Oct 10, 2018
I understand this merge make dockerode behave more With the raw binary output from docker api when But this header/body section way does not always bring the right output because the exact body length may not always equal to body size specified in the header later 4 bytes, The body may be cut due to actions like stop or restart, etc. Once that happened, it would require a lot of code to seek back the next header. This can be verified by sample code like constresult=awaitcontainer.logs({follow: false,stdout: true,stderr: true,});constbuffer=Buffer.from(result);letp=0;logger.debug(buffer.length);while(p<buffer.length){constheader=buffer.slice(p,p+8);constlen=header.readInt32BE(4);// logger.debug({ p, header, len });p+=8;constcontent=buffer.toString('utf8',p,p+len);console.log(content);p+=len;}On the other hand, by setting |
By default the follow option in the container and service endpoint is false. This fix follows this definition and sets the isStream variable accordingly.
Best