improve handling of disk change modify events
This commit is contained in:
@@ -131,7 +131,6 @@ func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var diskChangeFound = false
|
||||
|
||||
// TODO - query current disk size from Inventory table and only create an update if the size is now changed
|
||||
if testConfig.DeviceChange != nil {
|
||||
for i := range testConfig.DeviceChange {
|
||||
if testConfig.DeviceChange[i].Device.Backing != nil {
|
||||
@@ -195,6 +194,18 @@ func (h *Handler) VmModifyEvent(w http.ResponseWriter, r *http.Request) {
|
||||
params.InventoryId = sql.NullInt64{Int64: invResult.Iid, Valid: invResult.Iid > 0}
|
||||
}
|
||||
|
||||
// Check current disk size from Inventory table and don't create an update if the size is still the same
|
||||
if params.UpdateType == "diskChange" && invResult.ProvisionedDisk.Float64 == params.NewProvisionedDisk.Float64 {
|
||||
h.Logger.Info("VM update type was for disk size but current size of VM matches inventory record, no need for update record",
|
||||
"vm_name", invResult.Name, "db_value", invResult.ProvisionedDisk.Float64, "new_value", params.NewProvisionedDisk.Float64)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"status": "OK",
|
||||
"message": fmt.Sprintf("Successfully processed vm modify event"),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// Parse the datetime string to a time.Time object
|
||||
eventTime, err := time.Parse(time.RFC3339, event.CloudEvent.Data.CreatedTime)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user