Skip to content

Commit

Permalink
fix(deployment): use Docker Cgroup Version to init volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Dec 9, 2021
1 parent c9c8d81 commit 3fa95e7
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/deployment/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,27 @@ const genericAskDatacenter = ({ inquirer }) => async (

const DOCKER_DATACENTER = 'default';

const makeProviders = ({ env, inquirer, wr, setup, fetch }) => ({
const makeProviders = ({ env, inquirer, wr, setup, fetch, needBacktick }) => ({
docker: {
name: 'Docker instances',
value: 'docker',
askDetails: async (_provider, _myDetails) => {
let vspec = '/sys/fs/cgroup:/sys/fs/cgroup';
let vspec = '';

const dockerInfo = await needBacktick(`docker info`);
const cgroupMatch = dockerInfo.match(/^\s*Cgroup\sVersion:\s*(\d+)/im);
if (!cgroupMatch || Number(cgroupMatch[1]) < 2) {
// Older cgroup version, we need to mount `/sys/fs/cgroup` explicitly
// for our Agoric deployment Docker containers' systemd.
vspec += ',/sys/fs/cgroup:/sys/fs/cgroup';
}
if (env.DOCKER_VOLUMES) {
vspec += `,${env.DOCKER_VOLUMES}`;
}
return {
VOLUMES: vspec
.split(',')
.filter(vol => vol.trim())
.map(vol => vol.split(':'))
// eslint-disable-next-line camelcase
.map(([host_path, container_path]) => ({
Expand Down Expand Up @@ -276,8 +285,15 @@ const doInit = ({
fetch,
parseArgs,
}) => async (progname, args) => {
const { needDoRun, cwd, chdir } = running;
const PROVIDERS = makeProviders({ env, inquirer, wr, setup, fetch });
const { needDoRun, needBacktick, cwd, chdir } = running;
const PROVIDERS = makeProviders({
env,
inquirer,
wr,
setup,
fetch,
needBacktick,
});

const { _: parsedArgs, noninteractive } = parseArgs(args.slice(1), {
boolean: ['noninteractive'],
Expand Down

0 comments on commit 3fa95e7

Please sign in to comment.