improve error handling
This commit is contained in:
@@ -67,12 +67,16 @@ func (c *CronTask) RunVcenterPoll(ctx context.Context, logger *slog.Logger) erro
|
||||
c.Logger.Debug("Need to add VM to inventory table", "MoRef", vm.Reference())
|
||||
vmObj, err := vc.ConvertObjToMoVM(vm)
|
||||
if err != nil {
|
||||
c.Logger.Error("Received error", "error", err)
|
||||
c.Logger.Error("Received error getting vm maangedobject", "error", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// retrieve VM properties and insert into inventory
|
||||
c.AddVmToInventory(vmObj, vc, ctx)
|
||||
err = c.AddVmToInventory(vmObj, vc, ctx)
|
||||
if err != nil {
|
||||
c.Logger.Error("Received error with VM add", "error", err)
|
||||
continue
|
||||
}
|
||||
|
||||
// add sleep to slow down mass VM additions
|
||||
utils.SleepWithContext(ctx, (10 * time.Millisecond))
|
||||
|
Reference in New Issue
Block a user