Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nt1m
Copy link
Member

@nt1m nt1m commented Aug 4, 2017

No description provided.

@nt1m nt1m force-pushed the temporary-containers branch 2 times, most recently from f4c3acb to d32ef00 Compare August 7, 2017 15:11
@nt1m nt1m requested review from jankeromnes and bnjbvr August 7, 2017 15:12
@nt1m
Copy link
Member Author

nt1m commented Aug 7, 2017

@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).
There's no elaborate UI atm, it just uses the Projects page, no way to get a link to your container or anything atm. I plan to add this later.

I have some questions as well:

  • What should happen if a task failed ? Atm, the PR just removes the task, which doesn't seem like a great idea, because then we'd have some containers hanging around.
  • How do you access VNC/C9 for containers spawned from a Janitor container ? I tried the usual host/containerId/port, with the host being the one I set on the admin page, but it didn't work.

@jankeromnes
Copy link
Member

Will try to have a look today! Thanks a lot for doing this 😄 👍 💯

@jankeromnes
Copy link
Member

Ok, I'll have a look at your code.

What should happen if a task failed ? Atm, the PR just removes the task, which doesn't seem like a great idea, because then we'd have some containers hanging around.

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).

How do you access VNC/C9 for containers spawned from a Janitor container ?

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.

Copy link
Member

@jankeromnes jankeromnes left a 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);
Copy link
Member

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.

Copy link
Member Author

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) {
Copy link
Member

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).

Copy link
Member Author

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 () {
Copy link
Member

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();
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to #140

@nt1m
Copy link
Member Author

nt1m commented Aug 8, 2017

I don't understand this question. Why would you spawn containers "from" an existing container?

Not sure how to explain this. I spawned some containers using the "local" janitor instance I had, but I can't access it using https://hostname/containerId/port/ even though the log logged succesfully when spawning the containers. The host of the project was set to janitor.technology.

@bnjbvr bnjbvr removed their request for review August 8, 2017 12:03
@bnjbvr
Copy link
Contributor

bnjbvr commented Aug 8, 2017

(removing myself from reviewers since Jan seems to be on it; thanks for doing that!)

Copy link
Member

@jankeromnes jankeromnes left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants