Skip to content

Commit

Permalink
wait to release device lock if one or more devices failed configurati…
Browse files Browse the repository at this point in the history
…on with commit confirmed mode 1
  • Loading branch information
indy-independence committed Sep 11, 2023
1 parent 769276b commit 6343563
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cnaas_nms/devicehandler/sync_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,12 @@ def sync_devices(
dev.last_seen = datetime.datetime.utcnow()
if not dry_run and get_confirm_mode(confirm_mode_override) != 2:
logger.info("Releasing lock for devices from syncto job: {}".format(job_id))
if failed_hosts:
logger.error(
"One or more devices failed to commit configuration, they will roll back configuration"
" in {}s: {}".format(api_settings.COMMIT_CONFIRMED_TIMEOUT, ", ".join(failed_hosts))
)
time.sleep(api_settings.COMMIT_CONFIRMED_TIMEOUT)
Joblock.release_lock(session, job_id=job_id)

if len(device_list) == 0:
Expand Down Expand Up @@ -983,7 +989,7 @@ def sync_devices(
f"{total_change_score} is higher than auto-push limit {AUTOPUSH_MAX_SCORE}"
)
elif get_confirm_mode(confirm_mode_override) == 2 and not dry_run:
if len(failed_hosts) > 0:
if failed_hosts:
logger.error(
"No confirm job scheduled since one or more devices failed in commitmode 2"
", all devices will rollback in {}s".format(api_settings.COMMIT_CONFIRMED_TIMEOUT)
Expand Down

0 comments on commit 6343563

Please sign in to comment.