-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add temporary machines support #134
base: master
Are you sure you want to change the base?
Conversation
f4c3acb
to
d32ef00
Compare
@bnjbvr @jankeromnes Not sure who can get to this first, but I'd like to have some feedback on this PR. So this PR allows generating temporary containers (it seems to work in my local testing). I have some questions as well:
|
Will try to have a look today! Thanks a lot for doing this 😄 👍 💯 |
Ok, I'll have a look at your code.
Without having looked at the code yet, this sounds unrelated to temporary containers. Maybe it's better to make a separate pull request that implements tasks? (It's ok to land it while it's unused, and start using it in a follow-up pull request).
I don't understand this question. Why would you spawn containers "from" an existing container? Also, in general you can access VNC, C9, and any other web service running inside a container by using the usual https://hostname/containerId/port/ URLs. I'll look at your code to see if your question makes more sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few quick comments in passing. It's great if it already works locally!
I'll make a more involved review soon.
machines.spawnTemporary(session.id, projectId, (error, machine) => { | ||
if (error) { | ||
response.statusCode = 500; // Internal Server Error | ||
response.json({ error: 'Could not create container' }, null, 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to return after than, in order not to end a response twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, good catch!
} | ||
|
||
machines.spawnTemporary(session.id, projectId, (error, machine) => { | ||
if (error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe log the error to know what's happening? E.g. log('[fail] creating temporary container', error)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already logged inside _spawn
in machines.js
lib/boot.js
Outdated
@@ -345,3 +346,13 @@ exports.registerDockerClient = function (next) { | |||
next(); | |||
}); | |||
}; | |||
|
|||
exports.loadTasks = function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Boot tasks usually take a next
callback function. Might want to accept and call it here, just to stay consistent and avoid surprises.
lib/tasks.js
Outdated
exports.add = function (date, type, data) { | ||
taskCounter++; | ||
|
||
const dateHash = date.getTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This is not a hash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, the var name is a leftover from some older code I wrote.
@@ -0,0 +1,53 @@ | |||
const db = require('./db'); | |||
const log = require('./log'); | |||
let taskCounter = 0; // Used to generate unique task IDs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would really prefer tasks to be a separate pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to #140
Not sure how to explain this. I spawned some containers using the "local" janitor instance I had, but I can't access it using |
d32ef00
to
4c37db7
Compare
4c37db7
to
d049b17
Compare
(removing myself from reviewers since Jan seems to be on it; thanks for doing that!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for working on implementing temporary machines! 👍
I'm not very confident about the current approach though. It feels very hacky to have two "types" of machines (some temporary, tied to a session, and others that live on forever, with separate spawn and delete mechanisms).
Instead, I think it would be cleaner to make all containers temporary. But in order not to cause too much trouble with this change, we can start with a very long lifetime (e.g. 6 months or 1 year), and we can also allow bumping the lifetime, or even disabling the automatic removal of a container.
I volunteer for taking over this pull request, as I know Janitor container internals well, and this could allow you to focus more on the new Containers interface, if you wish.
Thanks again!
No description provided.