From 95785564802ccaf3eedd246f1caccd46d258b40b Mon Sep 17 00:00:00 2001 From: Kostiantyn Kalynovskyi Date: Fri, 5 Mar 2021 19:01:14 +0000 Subject: [PATCH] Fix unknown event type message in logs This commit allows to normalize baremetal host events, so they appear in logs corretly. Change-Id: If6fb862d2baef0897a24bf6b3fdfa196f2b1ee8d --- pkg/events/events.go | 8 ++++++++ pkg/phase/executors/baremetal_manager.go | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/events/events.go b/pkg/events/events.go index f96b018f7..f8dde70da 100644 --- a/pkg/events/events.go +++ b/pkg/events/events.go @@ -108,6 +108,11 @@ var genericContainerOperationToString = map[GenericContainerOperation]string{ GenericContainerStop: "GenericContainerStop", } +var baremetalInventoryOperationToString = map[BaremetalManagerStep]string{ + BaremetalManagerStart: "BaremetalOperationStart", + BaremetalManagerComplete: "BaremetalOperationComplete", +} + //Normalize cast Event to GenericEvent type func Normalize(e Event) GenericEvent { var eventType string @@ -131,6 +136,9 @@ func Normalize(e Event) GenericEvent { case GenericContainerType: operation = genericContainerOperationToString[e.GenericContainerEvent.Operation] message = e.GenericContainerEvent.Message + case BaremetalManagerEventType: + operation = baremetalInventoryOperationToString[e.BaremetalManagerEvent.Step] + message = e.BaremetalManagerEvent.Message } return GenericEvent{ diff --git a/pkg/phase/executors/baremetal_manager.go b/pkg/phase/executors/baremetal_manager.go index 395fb0fbe..deca9d8ac 100644 --- a/pkg/phase/executors/baremetal_manager.go +++ b/pkg/phase/executors/baremetal_manager.go @@ -57,8 +57,8 @@ func (e *BaremetalManagerExecutor) Run(evtCh chan events.Event, opts ifc.RunOpti evtCh <- events.NewEvent().WithBaremetalManagerEvent(events.BaremetalManagerEvent{ Step: events.BaremetalManagerStart, HostOperation: string(e.options.Spec.Operation), - Message: fmt.Sprintf("Starting remote operation, selector to be to filter hosts %v", - e.options.Spec.HostSelector), + Message: fmt.Sprintf("Starting remote operation '%s', selector to be to filter hosts %v", + e.options.Spec.Operation, e.options.Spec.HostSelector), }) op, err := e.validate()