[lxc-devel] [lxd/master] Fix event handling

stgraber on Github lxc-bot at linuxcontainers.org
Tue Oct 1 15:41:37 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 301 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20191001/851dc5a2/attachment.bin>
-------------- next part --------------
From 9b04ff0d1a63c325f907618fc5e1fd5acc40ef24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 1 Oct 2019 11:40:35 -0400
Subject: [PATCH 1/2] lxd/daemon: Fix logging events
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/daemon.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lxd/daemon.go b/lxd/daemon.go
index 319a0a8839..ba9852273c 100644
--- a/lxd/daemon.go
+++ b/lxd/daemon.go
@@ -534,6 +534,9 @@ func (d *Daemon) Init() error {
 }
 
 func (d *Daemon) init() error {
+	// Setup logger
+	events.LoggingServer = d.events
+
 	// Lets check if there's an existing LXD running
 	err := endpoints.CheckAlreadyRunning(d.UnixSocket())
 	if err != nil {

From 7983f0ab72c77461a4cd263aa0054c90d1a2db39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgraber at ubuntu.com>
Date: Tue, 1 Oct 2019 11:40:47 -0400
Subject: [PATCH 2/2] lxd/operations: Fix operation events
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 lxd/operations/operations.go | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lxd/operations/operations.go b/lxd/operations/operations.go
index 56fc45565f..e9fba58d30 100644
--- a/lxd/operations/operations.go
+++ b/lxd/operations/operations.go
@@ -167,7 +167,7 @@ func OperationCreate(state *state.State, project string, opClass operationClass,
 
 	logger.Debugf("New %s Operation: %s", op.class.String(), op.id)
 	_, md, _ := op.Render()
-	op.state.Events.Send(op.project, "Operation", md)
+	op.state.Events.Send(op.project, "operation", md)
 
 	return &op, nil
 }
@@ -286,7 +286,7 @@ func (op *Operation) Cancel() (chan error, error) {
 
 				logger.Debugf("Failed to cancel %s Operation: %s: %s", op.class.String(), op.id, err)
 				_, md, _ := op.Render()
-				op.state.Events.Send(op.project, "Operation", md)
+				op.state.Events.Send(op.project, "operation", md)
 				return
 			}
 
@@ -298,13 +298,13 @@ func (op *Operation) Cancel() (chan error, error) {
 
 			logger.Debugf("Cancelled %s Operation: %s", op.class.String(), op.id)
 			_, md, _ := op.Render()
-			op.state.Events.Send(op.project, "Operation", md)
+			op.state.Events.Send(op.project, "operation", md)
 		}(op, oldStatus, chanCancel)
 	}
 
 	logger.Debugf("Cancelling %s Operation: %s", op.class.String(), op.id)
 	_, md, _ := op.Render()
-	op.state.Events.Send(op.project, "Operation", md)
+	op.state.Events.Send(op.project, "operation", md)
 
 	if op.canceler != nil {
 		err := op.canceler.Cancel()
@@ -323,7 +323,7 @@ func (op *Operation) Cancel() (chan error, error) {
 
 	logger.Debugf("Cancelled %s Operation: %s", op.class.String(), op.id)
 	_, md, _ = op.Render()
-	op.state.Events.Send(op.project, "Operation", md)
+	op.state.Events.Send(op.project, "operation", md)
 
 	return chanCancel, nil
 }
@@ -469,7 +469,7 @@ func (op *Operation) UpdateResources(opResources map[string][]string) error {
 
 	logger.Debugf("Updated resources for %s Operation: %s", op.class.String(), op.id)
 	_, md, _ := op.Render()
-	op.state.Events.Send(op.project, "Operation", md)
+	op.state.Events.Send(op.project, "operation", md)
 
 	return nil
 }
@@ -497,7 +497,7 @@ func (op *Operation) UpdateMetadata(opMetadata interface{}) error {
 
 	logger.Debugf("Updated metadata for %s Operation: %s", op.class.String(), op.id)
 	_, md, _ := op.Render()
-	op.state.Events.Send(op.project, "Operation", md)
+	op.state.Events.Send(op.project, "operation", md)
 
 	return nil
 }


More information about the lxc-devel mailing list