Open mason-stewart opened 4 years ago
Thx for the report @masondesu !
I fiddled with this and couldn't reproduce your error. I tried the following:
>> Nstance.log.level = :debug
=> :debug
>> instance = Nstance.create(image: "ruby")
=> #<Nstance::Instance:0x00007ffc1ba18e88 @driver=#<Nstance::Drivers::DockerAPI::AttachDriver:0x00007ffc1ba192c0 @uuid="f900bbd6-ce44-4118-a386-15b940edc773", @image="ruby", @manager=#<Nstance::Drivers::DockerAPI::ContainerManager:0x00007ffc1ba18f78 @image="ruby", @container_opts={:Image=>"ruby", :Cmd=>["sh"], :Labels=>{"nstance"=>"f900bbd6-ce44-4118-a386-15b940edc773"}, :OpenStdin=>true, :StdinOnce=>true, "name"=>"nstance_f900bbd6-ce44-4118-a386-15b940edc773"}, @lock=#<Thread::Mutex:0x00007ffc1ba18f50>>, @parser=#<Nstance::Drivers::DockerAPI::AttachLogParser:0x00007ffc1ba18f28 @buffer="">, @lock=#<Thread::Mutex:0x00007ffc1ba18ed8>, @queue=[]>>
>> instance.run("ruby -e 'puts \"a\" * 300'", output_limit: 100)
D, [2019-10-31T20:47:55.309297 #28722] DEBUG -- nstance: Command 4b6933e9 scheduled: "ruby -e 'puts \"a\" * 300'"
D, [2019-10-31T20:47:55.309569 #28722] DEBUG -- nstance: Creating container: {:Image=>"ruby", :Cmd=>["sh"], :Labels=>{"nstance"=>"f900bbd6-ce44-4118-a386-15b940edc773"}, :OpenStdin=>true, :StdinOnce=>true, "name"=>"nstance_f900bbd6-ce44-4118-a386-15b940edc773"}
D, [2019-10-31T20:47:55.977992 #28722] DEBUG -- nstance: Command 4b6933e9 received data: [stdout] "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
D, [2019-10-31T20:47:55.978079 #28722] DEBUG -- nstance: Command 4b6933e9 event:chunk, payload:[:stdout, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"]
D, [2019-10-31T20:47:55.978114 #28722] DEBUG -- nstance: Command 4b6933e9 event:line, payload:[:stdout, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"]
D, [2019-10-31T20:47:55.978141 #28722] DEBUG -- nstance: Command 4b6933e9 event:complete, payload:[---
stdout | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
--- exit status: output_limit_exceeded]
D, [2019-10-31T20:47:55.978176 #28722] DEBUG -- nstance: Removing container: {:Image=>"ruby", :Cmd=>["sh"], :Labels=>{"nstance"=>"f900bbd6-ce44-4118-a386-15b940edc773"}, :OpenStdin=>true, :StdinOnce=>true}
=> ---
stdout | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
--- exit status: output_limit_exceeded
>> result = _
=> ---
stdout | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
--- exit status: output_limit_exceeded
>> result.status
=> :output_limit_exceeded
>> result.lines
=> [[:stdout, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"]]
However based on your stack trace it seems like the problem occurs in Result#inspect
when lines
is nil for some reason, so I pushed 6818722.
Give that sha a try please and let me know if this is fixed. It would be great to have a reproducing test case in the spec suite (that now passes if my commit works) if you have time and you're able to reproduce this consistently.
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:For the time being I've just bumped the allowed output size to resolve the issue in production. Any clue what's happening here?