From 2de8ede663d2d7836c6770feb8e38db80ca1b8bb Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 31 Oct 2017 14:33:05 -0400 Subject: [PATCH] Default to the storage defaults Change the config to use github.com/containers/storage by default. Allow users to override in the config, but if the admin does not override the config. Signed-off-by: Daniel J Walsh --- cmd/crio/config.go | 16 +++++++++++----- libkpod/config.go | 13 +++++++------ test/helpers.bash | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cmd/crio/config.go b/cmd/crio/config.go index 76e3361d..941476aa 100644 --- a/cmd/crio/config.go +++ b/cmd/crio/config.go @@ -12,21 +12,27 @@ var commentedConfigTemplate = template.Must(template.New("config").Parse(` # The "crio" table contains all of the server options. [crio] +# CRI-O reads its storage defaults from the containers/storage configuration +# file, /etc/containers/storage.conf. Modify storage.conf if you want to +# change default storage for all tools that use containers/storage. If you +# want to modify just crio, you can change the storage configuration in this +# file. + # root is a path to the "root directory". CRIO stores all of its data, # including container images, in this directory. -root = "{{ .Root }}" +#root = "{{ .Root }}" # run is a path to the "run directory". CRIO stores all of its state # in this directory. -runroot = "{{ .RunRoot }}" +#runroot = "{{ .RunRoot }}" # storage_driver select which storage driver is used to manage storage # of images and containers. -storage_driver = "{{ .Storage }}" +#storage_driver = "{{ .Storage }}" # storage_option is used to pass an option to the storage driver. -storage_option = [ -{{ range $opt := .StorageOptions }}{{ printf "\t%q,\n" $opt }}{{ end }}] +#storage_option = [ {{ range $opt := .StorageOptions }}{{ printf "\t\n#%q," $opt }}{{ end }} +#] # The "crio.api" table contains settings for the kubelet/gRPC # interface (which is also used by crioctl). diff --git a/libkpod/config.go b/libkpod/config.go index 687b4b38..304bf0c9 100644 --- a/libkpod/config.go +++ b/libkpod/config.go @@ -5,14 +5,13 @@ import ( "io/ioutil" "github.com/BurntSushi/toml" + "github.com/containers/storage" "github.com/kubernetes-incubator/cri-o/oci" "github.com/opencontainers/selinux/go-selinux" ) // Default paths if none are specified const ( - crioRoot = "/var/lib/containers/storage" - crioRunRoot = "/var/run/containers/storage" conmonPath = "/usr/local/libexec/crio/conmon" pauseImage = "kubernetes/pause" pauseCommand = "/pause" @@ -270,10 +269,12 @@ func (c *Config) ToFile(path string) error { func DefaultConfig() *Config { return &Config{ RootConfig: RootConfig{ - Root: crioRoot, - RunRoot: crioRunRoot, - LogDir: "/var/log/crio/pods", - FileLocking: true, + Root: storage.DefaultStoreOptions.GraphRoot, + RunRoot: storage.DefaultStoreOptions.RunRoot, + Storage: storage.DefaultStoreOptions.GraphDriverName, + StorageOptions: storage.DefaultStoreOptions.GraphDriverOptions, + LogDir: "/var/log/crio/pods", + FileLocking: true, }, RuntimeConfig: RuntimeConfig{ Runtime: "/usr/bin/runc", diff --git a/test/helpers.bash b/test/helpers.bash index 22955d33..4dd6db2d 100644 --- a/test/helpers.bash +++ b/test/helpers.bash @@ -245,6 +245,7 @@ function start_crio() { "$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name=docker.io/library/busybox:latest --import-from=dir:"$ARTIFACTS_PATH"/busybox-image --signature-policy="$INTEGRATION_ROOT"/policy.json "$COPYIMG_BINARY" --root "$TESTDIR/crio" $STORAGE_OPTIONS --runroot "$TESTDIR/crio-run" --image-name=docker.io/library/runcom/stderr-test:latest --import-from=dir:"$ARTIFACTS_PATH"/stderr-test --signature-policy="$INTEGRATION_ROOT"/policy.json "$CRIO_BINARY" ${DEFAULT_MOUNTS_OPTS} ${HOOKS_OPTS} --conmon "$CONMON_BINARY" --listen "$CRIO_SOCKET" --cgroup-manager "$CGROUP_MANAGER" --registry "docker.io" --runtime "$RUNTIME_BINARY" --root "$TESTDIR/crio" --runroot "$TESTDIR/crio-run" $STORAGE_OPTIONS --seccomp-profile "$seccomp" --apparmor-profile "$apparmor" --cni-config-dir "$CRIO_CNI_CONFIG" --cni-plugin-dir "$CRIO_CNI_PLUGIN" --signature-policy "$INTEGRATION_ROOT"/policy.json --image-volumes "$IMAGE_VOLUMES" --pids-limit "$PIDS_LIMIT" --log-size-max "$LOG_SIZE_MAX_LIMIT" --config /dev/null config >$CRIO_CONFIG + sed -i -r -e 's/^(#)?root =/root =/g' -e 's/^(#)?runroot =/runroot =/g' -e 's/^(#)?storage_driver =/storage_driver =/g' -e '/^(#)?storage_option = (\[)?[ \t]*$/,/^#?$/s/^(#)?//g' $CRIO_CONFIG # Prepare the CNI configuration files, we're running with non host networking by default if [[ -n "$4" ]]; then