-
Notifications
You must be signed in to change notification settings - Fork 24
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
initial work on sdc-cloudapi for PUBAPI-1420 #28
Conversation
e9194e8
to
8150066
Compare
51d91b6
to
3940d71
Compare
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.
Most of my comments are minor or nits, and I wouldn't mind merging this as is, as long as tickets for future work are filed.
lib/machines.js
Outdated
|
||
function validVolumeName(volumeName) { | ||
var VALID_VOLUME_NAME_REGEXP = /^[a-zA-Z0-9][a-zA-Z0-9_\.\-]+$/; | ||
if (volumeName === undefined || volumeName === null || |
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.
Thinking out loud: should we check that the value volumeName
is of type 'string'
instead with typeof (volumeName) !== 'string'
? I'm not sure it makes a big difference.
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.
Sure, this makes sense.
lib/machines.js
Outdated
|
||
// stops at first error | ||
function validateVolume(volume) { | ||
var VALID_VOLUME_MODES = ['ro', 'rw']; |
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.
Should we assert.object(volume, 'volume');
?
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.
yep!
lib/machines.js
Outdated
var VALID_VOLUME_MODES = ['ro', 'rw']; | ||
|
||
if (volume.type !== undefined && volume.type !== 'tritonnfs') { | ||
return (new InvalidArgumentError('unknown volume type "' + volume.type |
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.
If we return on the first error, then we lose the opportunity to report all relevant errors for a given request. Should we instead return an array of errors?
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.
Sure, I'll change to do that.
lib/machines.js
Outdated
for (idx = 0; idx < volumes.length; idx++) { | ||
validationErr = validateVolume(volumes[idx]); | ||
if (validationErr) { | ||
break; |
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.
Same here: we early out on the first validation error, should we instead validate all input and report all relevant errors?
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.
Yep.
test/volumes-automount.test.js
Outdated
var CONFIG = mod_config.configure(); | ||
var IMGAPI_SOURCE = 'https://images.joyent.com'; | ||
var KEY_FILENAME = '/tmp/cloudapi-test-key'; | ||
var TEST_IMAGE_LX = '7b5981c4-1889-11e7-b4c5-3f3bdfc9b88b'; // ubuntu-16.04 |
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.
Is it safe to hardcode it?
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.
I think so for now, but I'll create a ticket to revisit this in the future.
test/volumes-automount.test.js
Outdated
var KEY_FILENAME = '/tmp/cloudapi-test-key'; | ||
var TEST_IMAGE_LX = '7b5981c4-1889-11e7-b4c5-3f3bdfc9b88b'; // ubuntu-16.04 | ||
var TEST_IMAGE_SMARTOS = | ||
'ede31770-e19c-11e5-bb6e-3b7de3cca9ce'; // minimal-multiarch-lts (15.4.1) |
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.
Same regarding hardcoding of the image UUID.
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.
I created https://devhub.joyent.com/jira/browse/PUBAPI-1436 for this.
test/volumes-automount.test.js
Outdated
'ede31770-e19c-11e5-bb6e-3b7de3cca9ce'; // minimal-multiarch-lts (15.4.1) | ||
var UFDS_ADMIN_UUID = CONFIG.ufds_admin_uuid; | ||
|
||
// XXX |
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.
What does this // XXX
mean? I'd suggest replacing that with a clearer comment.
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.
This was actually left in by mistake. I'll remove it.
test/volumes-automount.test.js
Outdated
}); | ||
}); | ||
|
||
// need a package we can use to provision our containers |
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.
Should that comment be about networks instead of packages?
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.
Indeed it should!
name: 'cloudapi-volume-lx-' + libuuid.create().split('-')[0], | ||
firewall_enabled: false, | ||
networks: [ | ||
{ipv4_uuid: networkUuidSsh, primary: true}, |
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.
Nice!
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! :)
if (req.params && req.params.volumes && req.params.volumes.length > 0) { | ||
if (opts.brand === 'kvm') { | ||
// At this time we do not support NFS volumes with KVM | ||
return next(new InvalidArgumentError('volumes not yet supported ' + |
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.
Should we add a test that checks that the relevant error is returned when trying to provision a KVM VM with volumes? That can be done in a subsequent PR, but we'd need to track that with a separate ticket.
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.
I'll add a test that does this. Sure.
@joshwilsdon Latest updates look good to me! |
…_nfs_shared_volumes is set in SAPI
The "experimental_cloudapi_automount" flag stuff was pointed out to me by @misterdjules in 1:1 chat. At this point I'm considering this complete and just waiting on a final go-ahead. |
integrated via c70cbc5 |
initial work