[lxc-devel] [lxd/master] Reset the images auto-update loop when configuration changes

freeekanayaka on Github lxc-bot at linuxcontainers.org
Mon Sep 4 12:23:09 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 607 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170904/22cbe2ce/attachment.bin>
-------------- next part --------------
From d9a463628cc226bcdec5c482951574bb248588a1 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Mon, 4 Sep 2017 12:18:41 +0000
Subject: [PATCH] Reset the images auto-update loop when configuration changes

This fixes a bug where changing the auto-update images interval with
the API would not take effect unless the daemon is restarted.

See also the comments to:

https://github.com/stgraber/lxd/commit/28e7d344175097877af7747fd5f2926e9965b17

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/daemon_config.go | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lxd/daemon_config.go b/lxd/daemon_config.go
index b41f6a405..c74214e50 100644
--- a/lxd/daemon_config.go
+++ b/lxd/daemon_config.go
@@ -186,7 +186,7 @@ func daemonConfigInit(db *sql.DB) error {
 		"core.trust_password":            {valueType: "string", hiddenValue: true, setter: daemonConfigSetPassword},
 
 		"images.auto_update_cached":    {valueType: "bool", defaultValue: "true"},
-		"images.auto_update_interval":  {valueType: "int", defaultValue: "6"},
+		"images.auto_update_interval":  {valueType: "int", defaultValue: "6", trigger: daemonConfigTriggerAutoUpdateInterval},
 		"images.compression_algorithm": {valueType: "string", validator: daemonConfigValidateCompression, defaultValue: "gzip"},
 		"images.remote_cache_expiry":   {valueType: "int", defaultValue: "10", trigger: daemonConfigTriggerExpiry},
 
@@ -306,6 +306,11 @@ func daemonConfigTriggerExpiry(d *Daemon, key string, value string) {
 	d.pruneChan <- true
 }
 
+func daemonConfigTriggerAutoUpdateInterval(d *Daemon, key string, value string) {
+	// Reset the auto-update interval loop
+	d.resetAutoUpdateChan <- true
+}
+
 func daemonConfigValidateCompression(d *Daemon, key string, value string) error {
 	if value == "none" {
 		return nil


More information about the lxc-devel mailing list