brentd / nstance Goto Github PK
View Code? Open in Web Editor NEW๐ถ Ruby library for running arbitrary shell commands in Docker containers
License: MIT License
๐ถ Ruby library for running arbitrary shell commands in Docker containers
License: MIT License
Hi @brentd. Thanks for working on this gem. It's great ๐
I've noticed that nstance seems to handle exceeded output limits in unexpected ways. Given a limit of 30KB bytes with container output that's roughly 107KB, I got an error about trying to map
over nil, and the result object's status and error attributes weren't set. Here's an example stack trace with the output santized:
[5] pry(main)> result = instance.run("cool_parser input.csv", output_limit: 30000)
D, [2019-10-30T13:04:14.229620 #32749] DEBUG -- nstance: Command e6564917 scheduled: "cool_parser input.csv"
D, [2019-10-30T13:04:14.230081 #32749] DEBUG -- nstance: Creating container: {:Image=>"amazing-docker-image:latest", :Cmd=>["sh"], :Labels=>{"nstance"=>"6feb191d-9e1b-4a78-b0a8-5a9b474cb4f9"}, :OpenStdin=>true, :StdinOnce=>true, "name"=>"nstance_6feb191d-9e1b-4a78-b0a8-5a9b474cb4f9"}
D, [2019-10-30T13:04:14.271251 #32749] DEBUG -- nstance: Creating container: {:Image=>"amazing-docker-image:latest", :Cmd=>["sh"], :Labels=>{"nstance"=>"a8ada766-fd3c-4772-a914-61783afffb9e"}, :OpenStdin=>true, :StdinOnce=>true}
D, [2019-10-30T13:04:17.004523 #32749] DEBUG -- nstance: Command 9e0631a0 received data: [stdout] "lots of cool data"
D, [2019-10-30T13:04:17.005046 #32749] DEBUG -- nstance: Command 9e0631a0 event:chunk, payload:[:stdout, "even more cool data"]
D, [2019-10-30T13:04:17.006066 #32749] DEBUG -- nstance: Command 9e0631a0 event:line, payload:[:stdout, "wow that's a lot of cool data"]
(Imagine tons of cool data here)
D, [2019-10-30T13:04:18.265945 #32749] DEBUG -- nstance: Command e6564917 event:complete, payload:[---
stdout | "lots of cool data"
stdout | "even more cool data"
stdout | "wow that's a lot of cool data"
(Imagine tons of cool data here)
--- exit status: output_limit_exceeded]
#<Thread:0x00007fef3b87b608@~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:21 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
9: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:21:in `block (2 levels) in run'
8: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:52:in `perform'
7: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:52:in `loop'
6: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:60:in `block in perform'
5: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:65:in `rescue in block in perform'
4: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:103:in `receive_error'
3: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:119:in `complete'
2: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:146:in `emit'
1: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:146:in `inspect'
~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/result.rb:15:in `inspect': undefined method `map' for nil:NilClass (NoMethodError)
D, [2019-10-30T13:04:18.198825 #32749] DEBUG -- nstance: Command 9e0631a0 event:complete, payload:[---
stdout | "lots of cool data"
stdout | "even more cool data"
stdout | "wow that's a lot of cool data"--- exit status: output_limit_exceeded]
=> #<Nstance::Result:0x3ff7a07ccd24>
#<Thread:0x00007fef3ff4b290@~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:21 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
9: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:21:in `block (2 levels) in run'
8: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:52:in `perform'
7: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:52:in `loop'
6: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:60:in `block in perform'
5: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/drivers/docker_api/attach_driver.rb:65:in `rescue in block in perform'
4: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:103:in `receive_error'
3: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:119:in `complete'
2: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:146:in `emit'
1: from ~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/run_emitter.rb:146:in `inspect'
~/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/nstance-0f5ed4d1f1a9/lib/nstance/result.rb:15:in `inspect': undefined method `map' for nil:NilClass (NoMethodError)
[6] pry(main)> result.status
=> nil
[7] pry(main)> result
=> #<Nstance::Result:0x3ff7a07ccd24>
[8] pry(main)> result.error
=> #<NoMethodError: undefined method `<<' for nil:NilClass>
[9] pry(main)> result.lines
=> nil
[10] pry(main)> result.success?
=> false
[11] pry(main)> result.output_limit_exceeded?
=> false
For the time being I've just bumped the allowed output size to resolve the issue in production. Any clue what's happening here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.