Skip to content

Commit

Permalink
Merge pull request #1933 from adrianreber/master
Browse files Browse the repository at this point in the history
Add CRIU configuration file support
  • Loading branch information
crosbymichael authored Jan 15, 2019
2 parents 12f6a99 + 403986c commit 4e9d52d
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 114 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ RUN cd /tmp \
&& rm -rf /tmp/bats

# install criu
# For CRIU 3.11 one patch is needed for the test 'checkpoint and restore with container specific CRIU config'
# This should be no longer necessary with CRIU 3.12
# See https://github.com/opencontainers/runc/pull/1933
ENV CRIU_VERSION v3.11
RUN mkdir -p /usr/src/criu \
&& curl -sSL https://github.com/checkpoint-restore/criu/archive/${CRIU_VERSION}.tar.gz | tar -v -C /usr/src/criu/ -xz --strip-components=1 \
&& cd /usr/src/criu \
&& curl https://github.com/checkpoint-restore/criu/commit/bb0b2f2635d71e549851b7c626a1464e42a3b5c7.patch | patch -p1 \
&& make install-criu \
&& rm -rf /usr/src/criu

Expand Down
30 changes: 30 additions & 0 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,32 @@ func waitForCriuLazyServer(r *os.File, status string) error {
return nil
}

func (c *linuxContainer) handleCriuConfigurationFile(rpcOpts *criurpc.CriuOpts) {
// CRIU will evaluate a configuration starting with release 3.11.
// Settings in the configuration file will overwrite RPC settings.
// Look for annotations. The annotation 'org.criu.config'
// specifies if CRIU should use a different, container specific
// configuration file.
_, annotations := utils.Annotations(c.config.Labels)
configFile, exists := annotations["org.criu.config"]
if exists {
// If the annotation 'org.criu.config' exists and is set
// to a non-empty string, tell CRIU to use that as a
// configuration file. If the file does not exist, CRIU
// will just ignore it.
if configFile != "" {
rpcOpts.ConfigFile = proto.String(configFile)
}
// If 'org.criu.config' exists and is set to an empty
// string, a runc specific CRIU configuration file will
// be not set at all.
} else {
// If the mentioned annotation has not been found, specify
// a default CRIU configuration file.
rpcOpts.ConfigFile = proto.String("/etc/criu/runc.conf")
}
}

func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error {
c.m.Lock()
defer c.m.Unlock()
Expand Down Expand Up @@ -940,6 +966,8 @@ func (c *linuxContainer) Checkpoint(criuOpts *CriuOpts) error {
LazyPages: proto.Bool(criuOpts.LazyPages),
}

c.handleCriuConfigurationFile(&rpcOpts)

// If the container is running in a network namespace and has
// a path to the network namespace configured, we will dump
// that network namespace as an external namespace and we
Expand Down Expand Up @@ -1190,6 +1218,8 @@ func (c *linuxContainer) Restore(process *Process, criuOpts *CriuOpts) error {
},
}

c.handleCriuConfigurationFile(req.Opts)

// Same as during checkpointing. If the container has a specific network namespace
// assigned to it, this now expects that the checkpoint will be restored in a
// already created network namespace.
Expand Down
Loading

0 comments on commit 4e9d52d

Please sign in to comment.