Browse Source

Add support for Clear Container Runtime

This patch installs Clear Container[1] as one of the runtime
for docker.

[1] https://clearlinux.org/features/intel%C2%AE-clear-containers

Change-Id: Ibacebf84ce1ff68a779589c7c9e17916503cafab
changes/34/499534/27
Madhuri Kumari 1 year ago
parent
commit
f4b1a02959
4 changed files with 54 additions and 10 deletions
  1. 6
    6
      README.rst
  2. 3
    3
      contrib/post_test_hook.sh
  3. 44
    1
      devstack/lib/docker
  4. 1
    0
      devstack/settings

+ 6
- 6
README.rst View File

@@ -1,13 +1,13 @@
1
-=================
2
- Container Plugin
3
-=================
1
+================
2
+Container Plugin
3
+================
4 4
 
5 5
 This plugin enables installation of container engine on Devstack. The default
6 6
 container engine is Docker (currently this plugin supports only Docker!).
7 7
 
8
-======================
9
- Enabling in Devstack
10
-======================
8
+====================
9
+Enabling in Devstack
10
+====================
11 11
 
12 12
 1. Download DevStack
13 13
 --------------------

+ 3
- 3
contrib/post_test_hook.sh View File

@@ -38,11 +38,11 @@ echo_summary "Devstack-plugin-container's post_test_hook.sh was called..."
38 38
 # Verify that Docker is installed correctly by running the hello-world image
39 39
 sudo -H -u stack docker run hello-world
40 40
 
41
+EXIT_CODE=$?
42
+
41 43
 # Copy over docker systemd unit journals.
42 44
 mkdir -p $WORKSPACE/logs
43 45
 sudo journalctl -o short-precise --unit docker | sudo tee $WORKSPACE/logs/docker.txt > /dev/null
44 46
 
45
-EXIT_CODE=$?
46
-
47 47
 $XTRACE
48
-exit $EXIT_CODE
48
+exit $EXIT_CODE

+ 44
- 1
devstack/lib/docker View File

@@ -26,7 +26,7 @@ DOCKER_ENGINE_PORT=${DOCKER_ENGINE_PORT:-2375}
26 26
 DOCKER_CLUSTER_STORE=${DOCKER_CLUSTER_STORE:-}
27 27
 DOCKER_GROUP=${DOCKER_GROUP:-$STACK_USER}
28 28
 DOCKER_CGROUP_DRIVER=${DOCKER_CGROUP_DRIVER:-}
29
-
29
+ENABLE_CLEAR_CONTAINER=$(trueorfalse False ENABLE_CLEAR_CONTAINER)
30 30
 
31 31
 # Functions
32 32
 # ---------
@@ -73,6 +73,19 @@ function install_docker {
73 73
         fi
74 74
         yum_install docker-ce
75 75
     fi
76
+    if [[ "$ENABLE_CLEAR_CONTAINER" == "True" ]]; then
77
+        # Clear Container can't run inside VM, so check whether virtualization
78
+        # is enabled or not
79
+        if sudo grep -E 'svm|vmx' /proc/cpuinfo &> /dev/null; then
80
+            if is_ubuntu; then
81
+                install_clear_container_ubuntu
82
+            elif is_fedora; then
83
+                install_clear_container_fedora
84
+            fi
85
+        else
86
+            (>&2 echo "WARNING: Clear Container needs the CPU extensions svm or vmx which is not enabled. Skipping Clear Container installation.")
87
+        fi
88
+    fi
76 89
 }
77 90
 
78 91
 function configure_docker {
@@ -83,6 +96,16 @@ function configure_docker {
83 96
     if [[ -n "$DOCKER_CLUSTER_STORE" ]]; then
84 97
         cluster_store_opts+="\"cluster-store\": \"$DOCKER_CLUSTER_STORE\","
85 98
     fi
99
+    local runtime_opts=""
100
+    if [[ "$ENABLE_CLEAR_CONTAINER" == "True" ]]; then
101
+        if sudo grep -E 'svm|vmx' /proc/cpuinfo &> /dev/null; then
102
+            runtime_opts+="\"runtimes\": {
103
+                \"cor\": {
104
+                    \"path\": \"/usr/bin/cc-oci-runtime\"
105
+                }
106
+            },"
107
+        fi
108
+    fi
86 109
     local docker_config_file=/etc/docker/daemon.json
87 110
     local debug
88 111
     if [[ "$ENABLE_DEBUG_LOG_LEVEL" == "True" ]]; then
@@ -94,6 +117,7 @@ function configure_docker {
94 117
     cat <<EOF | sudo tee $docker_config_file >/dev/null
95 118
 {
96 119
     $cluster_store_opts
120
+    $runtime_opts
97 121
     "debug": ${debug},
98 122
     "group": "$DOCKER_GROUP",
99 123
 EOF
@@ -111,6 +135,7 @@ EOF
111 135
     ]
112 136
 }
113 137
 EOF
138
+
114 139
     # NOTE(hongbin): We override ExecStart to workaround issue 22339.
115 140
     # https://github.com/docker/docker/issues/22339
116 141
     local docker_drop_in_file=/etc/systemd/system/docker.service.d/docker.conf
@@ -129,5 +154,23 @@ function stop_docker {
129 154
     sudo systemctl stop docker.service || true
130 155
 }
131 156
 
157
+function install_clear_container_ubuntu {
158
+    sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/clearlinux:/preview:/clear-containers-2.1/xUbuntu_$(lsb_release -rs)/ /' >> /etc/apt/sources.list.d/cc-oci-runtime.list"
159
+    curl -fsSL http://download.opensuse.org/repositories/home:/clearlinux:/preview:/clear-containers-2.1/xUbuntu_$(lsb_release -rs)/Release.key | sudo apt-key add -
160
+    REPOS_UPDATED=False apt_get_update
161
+    apt_get install cc-oci-runtime
162
+}
163
+
164
+function install_clear_container_fedora {
165
+    source /etc/os-release
166
+    local lsb_dist=${os_VENDOR,,}
167
+    if [[ "$lsb_dist" = "fedora" ]]; then
168
+        sudo -E dnf config-manager \
169
+            --add-repo \
170
+            http://download.opensuse.org/repositories/home:clearlinux:preview:clear-containers-2.1/Fedora\_$VERSION_ID/home:clearlinux:preview:clear-containers-2.1.repo
171
+    fi
172
+    yum_install cc-oci-runtime linux-container
173
+}
174
+
132 175
 # Restore xtrace
133 176
 $_XTRACE_DOCKER

+ 1
- 0
devstack/settings View File

@@ -1,6 +1,7 @@
1 1
 # Devstack settings
2 2
 
3 3
 CONTAINER_ENGINE=${CONTAINER_ENGINE:-docker}
4
+ENABLE_CLEAR_CONTAINER=${ENABLE_CLEAR_CONTAINER:-true}
4 5
 
5 6
 # Enable container services
6 7
 enable_service container

Loading…
Cancel
Save