From a67ebb54298fa3ac473edabbcae695574c7ec0b0 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 6 Mar 2021 13:35:22 +0100 Subject: [PATCH] amqp: fix broken validation of AMQP status updates --- routes/infrastructure-component/ic_amqpclient.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/infrastructure-component/ic_amqpclient.go b/routes/infrastructure-component/ic_amqpclient.go index f9ca3fc..be936b8 100644 --- a/routes/infrastructure-component/ic_amqpclient.go +++ b/routes/infrastructure-component/ic_amqpclient.go @@ -59,6 +59,7 @@ type ICStatus struct { } type ICProperties struct { + UUID string `json:"uuid"` Name string `json:"name"` Description string `json:"description"` Location string `json:"location"` @@ -234,8 +235,7 @@ func processMessage(message amqp.Delivery) error { return fmt.Errorf("AMQP: Could not unmarshal message to JSON: %v err: %v", string(message.Body), err) } - headers := amqp.Table(message.Headers) - ICUUID := fmt.Sprintf("%v", headers["uuid"]) + ICUUID := payload.Properties.UUID _, err = uuid.Parse(ICUUID) if err != nil { return fmt.Errorf("AMQP: UUID not valid: %v, message ignored: %v \n", ICUUID, string(message.Body)) @@ -283,6 +283,8 @@ func createExternalIC(payload ICUpdate, ICUUID string, body []byte) error { log.Println("AMQP: Aborting creation of IC with state gone") return nil } + + newICReq.InfrastructureComponent.UUID = payload.Properties.UUID newICReq.InfrastructureComponent.Uptime = payload.Status.Uptime newICReq.InfrastructureComponent.WebsocketURL = payload.Properties.WS_url newICReq.InfrastructureComponent.APIURL = payload.Properties.API_url @@ -338,6 +340,8 @@ func (s *InfrastructureComponent) updateExternalIC(payload ICUpdate, body []byte } else { updatedICReq.InfrastructureComponent.State = "unknown" } + + updatedICReq.InfrastructureComponent.UUID = payload.Properties.UUID updatedICReq.InfrastructureComponent.Uptime = payload.Status.Uptime updatedICReq.InfrastructureComponent.Type = payload.Properties.Type updatedICReq.InfrastructureComponent.Category = payload.Properties.Category