Skip to content

Commit

Permalink
TRITON-2160 Need a way to provide node.config for Linux CNs (#73)
Browse files Browse the repository at this point in the history
Make the change effective for existing dhcpd zones.
  • Loading branch information
kusor committed Sep 1, 2020
1 parent 8da24cb commit b161767
Showing 1 changed file with 97 additions and 4 deletions.
101 changes: 97 additions & 4 deletions lib/cli/do_update_other.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Copyright 2020 Joyent, Inc.
*/

/* eslint-disable callback-return */

var util = require('util');
var format = util.format;
var fs = require('fs');
Expand Down Expand Up @@ -187,7 +189,6 @@ function do_update_other(subcmd, opts, args, cb) {
next();
}
});

},

function updateSdcAppSchemas(_, next) {
Expand Down Expand Up @@ -407,7 +408,6 @@ function do_update_other(subcmd, opts, args, cb) {
}, errors.sdcClientErrWrap(nextSvc, 'sapi'));
}
}, next);

},

function ensureDockerPkg_Svc(ctx, next) {
Expand Down Expand Up @@ -753,7 +753,6 @@ function do_update_other(subcmd, opts, args, cb) {
agent.params.image_uuid = data.trim();
_cb();
});

},
function updateAgentImg(_, _cb) {
progress('Updating service for agent \'%s\'',
Expand Down Expand Up @@ -892,8 +891,102 @@ function do_update_other(subcmd, opts, args, cb) {
});
},

steps.sapi.ensureAssetsService
// Need to mount /usbkey/extra to provide access to node.config through
// Booter.
function updateBooterCfg(ctx, next) {
var booterSvc = ctx.svcs.filter(function (svc) {
return svc.name === 'dhcpd';
})[0];

if (!booterSvc || booterSvc.params.filesystems.length > 1) {
next();
return;
}

progress('Mount "/usbkey/extra" for "Dhcpd" service');
updateService(booterSvc.uuid, { params: {
filesystems: booterSvc.params.filesystems.concat({
source: '/usbkey/extra',
target: '/tftpboot/extra',
type: 'lofs',
options: [
'ro',
'nodevices'
]
})
} }, function (booterErr) {
if (booterErr) {
next(new errors.SDCClientError(booterErr, 'sapi'));
return;
}

self.sdcadm.sapi.listInstances({
service_uuid: booterSvc.uuid
}, function (err, insts) {
if (err) {
next(new errors.SDCClientError(err, 'sapi'));
return;
}

if (!insts.length) {
next();
return;
}

vasync.forEachPipeline({
inputs: insts,
func: function mountExtra(inst, nextInst) {
progress(
'Mounting "/usbkey/extra" for instance: %s',
inst.uuid);
vasync.pipeline({funcs: [
function ceateMountPath(_, nextStep) {
var argv = [
'mkdir', '-p',
'/zones/' + inst.uuid +
'/root/tftpboot/extra'
];
common.execFilePlus({
argv: argv,
log: self.sdcadm.log
}, nextStep);
},
function updateZoneCfg(_, nextStep) {
var zonecfg = 'add fs; set type=lofs; ' +
'set dir=/tftpboot/extra; ' +
'set special=/usbkey/extra; ' +
'set options=ro; end';
var argv = [
'/usr/sbin/zonecfg', '-z',
inst.uuid,
zonecfg
];
common.execFilePlus({
argv: argv,
log: self.sdcadm.log
}, nextStep);
},
// This one is to avoid zone reboot
function createLofsMount(_, nextStep) {
var argv = [
'mount', '-F', 'lofs',
'-o nodevices,ro',
'/usbkey/extra',
'/zones/' + inst.uuid +
'/root/tftpboot/extra'
];
common.execFilePlus({
argv: argv,
log: self.sdcadm.log
}, nextStep);
}
]}, nextInst);
}
}, next);
});
});
},
steps.sapi.ensureAssetsService
]}, cb);
}

Expand Down

0 comments on commit b161767

Please sign in to comment.