Commit e2bebbc6 authored by Sonja Happ's avatar Sonja Happ
Browse files

Do not create ICs with state gone, add some logging info for AMQP-related actions #31 #41

parent fb757b11
......@@ -110,7 +110,11 @@ func createNewICviaAMQP(payload ICUpdate) error {
} else {
newICReq.InfrastructureComponent.State = "unknown"
}
// TODO check if state is "gone" and abort creation of IC in this case
if newICReq.InfrastructureComponent.State == "gone" {
// Check if state is "gone" and abort creation of IC in this case
log.Println("########## AMQP: Aborting creation of IC with state gone")
return nil
}
if payload.Properties.WS_url != nil {
newICReq.InfrastructureComponent.WebsocketURL = *payload.Properties.WS_url
......@@ -151,17 +155,19 @@ func createNewICviaAMQP(payload ICUpdate) error {
}
func (s *InfrastructureComponent) updateICviaAMQP(payload ICUpdate) error {
var updatedICReq UpdateICRequest
if payload.State != nil {
updatedICReq.InfrastructureComponent.State = *payload.State
if *payload.State == "gone" {
// remove IC from DB
log.Println("########## AMQP: Deleting IC with state gone")
err := s.delete(true)
if err != nil {
// if component could not be deleted there are still configurations using it in the DB
// continue with the update to save the new state of the component and get back to the deletion later
log.Println("Could not delete IC because there is a config using it, deletion postponed")
log.Println("########## AMQP: Deletion of IC postponed (config(s) associated to it)")
}
}
......
......@@ -28,6 +28,7 @@ import (
"github.com/jinzhu/gorm/dialects/postgres"
"github.com/nsf/jsondiff"
"gopkg.in/go-playground/validator.v9"
"log"
"time"
)
......@@ -131,6 +132,7 @@ func (r *AddICRequest) createIC(receivedViaAMQP bool) (InfrastructureComponent,
*action.Properties.UUID = r.InfrastructureComponent.UUID
}
log.Println("########## AMQP: Sending request to create new IC")
err = sendActionAMQP(action)
// s remains empty
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment