Cedana
Cedana Daemon
Cedana
Cedana Daemon
  • Cedana Daemon
  • Get started
    • Installation
    • Authentication
    • Configuration
    • Health checks
    • Plugins
    • Feature matrix
  • Guides
    • Managed process/container
    • Checkpoint/restore basics
    • Checkpoint/restore with GPUs
    • Checkpoint/restore runc
    • Checkpoint/restore containerd
    • Checkpoint/restore streamer
    • Checkpoint/restore kata
      • how-to-create-custom-busybox-image
      • how-to-install-criu-in-guest
      • how-to-install-on-aws
      • how-to-make-kernel-criu-compatible
      • how-to-make-rootfs-criu-compatible
      • Checkpoint/Restore kata containers
  • Developer guides
    • Architecture
    • Profiling
    • Testing
    • Writing plugins
  • References
    • CLI
      • cedana
      • cedana attach
      • cedana checkpoint
      • cedana checkpoints
      • cedana completion
      • cedana completion bash
      • cedana completion fish
      • cedana completion powershell
      • cedana completion zsh
      • cedana daemon
      • cedana daemon check
      • cedana daemon start
      • cedana delete
      • cedana dump
      • cedana dump containerd
      • cedana dump job
      • cedana dump process
      • cedana dump runc
      • cedana exec
      • cedana features
      • cedana inspect
      • cedana job
      • cedana job attach
      • cedana job checkpoint
      • cedana job checkpoint inspect
      • cedana job checkpoint list
      • cedana job checkpoints
      • cedana job delete
      • cedana job inspect
      • cedana job kill
      • cedana job list
      • cedana jobs
      • cedana k8s-helper
      • cedana k8s-helper destroy
      • cedana kill
      • cedana manage
      • cedana manage containerd
      • cedana manage process
      • cedana manage runc
      • cedana plugin
      • cedana plugin features
      • cedana plugin install
      • cedana plugin list
      • cedana plugin remove
      • cedana plugins
      • cedana ps
      • cedana query
      • cedana query k8s
      • cedana query runc
      • cedana restore
      • cedana restore job
      • cedana restore process
      • cedana restore runc
      • cedana run
      • cedana run containerd
      • cedana run process
      • cedana run runc
    • API
    • GitHub
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Developer guides

Architecture

PreviousCheckpoint/Restore kata containersNextProfiling

Last updated 2 months ago

Was this helpful?

The design mostly follows what's illustrated below. Below is a simplified runtime view of invoking cedana dump runc ...:

image
  1. The subcommand cedana dump runc ... is only available if the runc plugin is exporting the DumpCmd symbol (check plugins/runc/main.go). The runc plugin only sets the specific flags it needs (such as --id, --root), while the parent cmd handles all the common flags, and sending the request to the daemon.

  2. The daemon receives the request, and runs it through a list of adapters, before finally sending it to CRIU. If the request's type is runc, it will use the DumpMiddleware exported by the runc plugin and plug it in the adapter chain. See internal/server/dump.go:

// The order below is the order followed before executing 
 // the final handler (criu.Dump). 
  
 middleware := types.Middleware[types.Dump]{ 
 	defaults.FillMissingDumpDefaults, 
 	validation.ValidateDumpRequest, 
 	filesystem.PrepareDumpDir(config.Global.Checkpoints.Compression), 
  
 	pluginDumpMiddleware, // middleware from plugins 
  
 	// Process state-dependent adapters 
 	process.FillProcessStateForDump, 
 	process.DetectShellJobForDump, 
 	process.DetectIOUringForDump, 
 	process.CloseCommonFilesForDump, 
 	process.AddExternalFilesForDump, 
 	network.DetectNetworkOptionsForDump, 
  
 	criu.CheckOptsForDump, 
 } 
  
 dump := criu.Dump.With(middleware...)
  1. This way, the runc plugin only implements the specifics of the runc runtime, while the daemon handles the common logic, and invoking CRIU.

  2. The same pattern is followed for dump, restore, run, and manage.

Features

Symbols that can be exported by a plugin are well-typed and are defined in pkg/features/supported.go. A feature implements a convenient method called IfAvailable(do func(), filter ...string), which is the only method you will ever need to access a feature exported by a plugin. An example usage:

 err = features.DumpMiddleware.IfAvailable(func( 
 	name string, 
 	pluginMiddleware types.Middleware[types.Dump], 
 ) error { 
 	middleware = append(middleware, pluginMiddleware...) 
 	return nil 
 }, t) 
 if err != nil { 
 	return nil, status.Error(codes.Unimplemented, err.Error()) 
 } 

A useful helper command is cedana features (alias of cedana plugin features), which lists all the features supported by all the plugins. This is useful for debugging, when implementing a new feature, or when you want to know what a plugin supports. Use the --errors flag to also output all errors encountered while loading the plugins.

See for more info.

image
feature matrix