[lxc-devel] [lxd-pkg-snap/latest-edge] Allow timeout for waitready to be set on LXD snap package dynamically.
dnegreira on Github
lxc-bot at linuxcontainers.org
Tue Jan 2 16:41:13 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 561 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180102/76baa3e2/attachment.bin>
-------------- next part --------------
From 83771d4ab72f46cc0f257d0edcc841f36dfd3d8f Mon Sep 17 00:00:00 2001
From: David Negreira <David at otherreality.net>
Date: Tue, 2 Jan 2018 15:05:19 +0100
Subject: [PATCH 1/2] - Add waitready_timeout variable to be passed to LXD
daemon - Add function to verify that the waitready_timeout value is a
positive integer
Signed-off-by: David Negreira <David at otherreality.net>
---
snapcraft/hooks/configure | 15 +++++++++++++++
snapcraft/wrappers/daemon.start | 2 +-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/snapcraft/hooks/configure b/snapcraft/hooks/configure
index 605f8a0..3fc4071 100755
--- a/snapcraft/hooks/configure
+++ b/snapcraft/hooks/configure
@@ -24,6 +24,19 @@ get_bool() {
return
}
+verify_int () {
+ value=$(echo "${1:-}")
+
+ # Verify if the value is a positive integer
+ if [[ "${value}" =~ ^[0-9]+$ ]]; then
+ echo "${value}"
+ return
+ fi
+
+ # Invalid value (or not set)
+ return
+}
+
# Don't fail if the mount namespace isn't properly setup yet
if [ ! -e /run/snapd-snap.socket ]; then
exit 0
@@ -34,6 +47,7 @@ daemon_debug=$(get_bool "$(snapctl get daemon.debug)")
daemon_group=$(snapctl get daemon.group)
ceph_builtin=$(get_bool "$(snapctl get ceph.builtin)")
openvswitch_builtin=$(get_bool "$(snapctl get openvswitch.builtin)")
+waitready_timeout=$(verify_int "$(snapctl get waitready.timeout)")
# Generate the config
config="${SNAP_COMMON}/config"
@@ -44,6 +58,7 @@ config="${SNAP_COMMON}/config"
echo "daemon_group=${daemon_group:-"lxd"}"
echo "ceph_builtin=${ceph_builtin:-"false"}"
echo "openvswitch_builtin=${openvswitch_builtin:-"false"}"
+ echo "waitready_timeout=${waitready_timeout:-"600"}"
} > "${config}"
exit 0
diff --git a/snapcraft/wrappers/daemon.start b/snapcraft/wrappers/daemon.start
index cff2dbe..7282a87 100755
--- a/snapcraft/wrappers/daemon.start
+++ b/snapcraft/wrappers/daemon.start
@@ -220,7 +220,7 @@ ${CMD} &
## Wait for it to be ready
PID=$!
echo $PID > "${SNAP_COMMON}/lxd.pid"
-"${LXD}" waitready --timeout=600
+"${LXD}" waitready --timeout="${waitready_timeout}"
## Put database in versioned path
if [ ! -L "${SNAP_COMMON}/lxd/lxd.db" ]; then
From b0b3c3e767502815e49917a289491c51b4e4f499 Mon Sep 17 00:00:00 2001
From: David Negreira <David at otherreality.net>
Date: Tue, 2 Jan 2018 17:02:00 +0100
Subject: [PATCH 2/2] - Write POSIX compliant regex check.
Signed-off-by: David Negreira <David at otherreality.net>
---
snapcraft/hooks/configure | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/snapcraft/hooks/configure b/snapcraft/hooks/configure
index 3fc4071..103cf90 100755
--- a/snapcraft/hooks/configure
+++ b/snapcraft/hooks/configure
@@ -28,7 +28,7 @@ verify_int () {
value=$(echo "${1:-}")
# Verify if the value is a positive integer
- if [[ "${value}" =~ ^[0-9]+$ ]]; then
+ if $(echo "${value}" | grep -Eq '^[0-9]+$'); then
echo "${value}"
return
fi
More information about the lxc-devel
mailing list