Fix: Add timeout to handle openstack stack cost
The openstack stack cost command was hanging indefinitely when
retrieving stack costs, causing Jenkins jobs to get stuck at
'INFO: Retrieving stack cost for: <stack-name>'. This led to:
- Jobs stuck waiting for cost retrieval to complete
- Subsequent jobs blocked on checkpoints
- Jenkins capacity issues with queue buildup
- Manual intervention required to cancel stuck jobs
This change adds comprehensive timeout handling to prevent these
hangs:
- Add timeout parameter to cost() function (default: 60 seconds)
- Add timeout to urllib.request.urlopen() network calls
- Wrap network operations in try/except to catch timeouts and errors
- Return 0 cost on timeout instead of hanging (graceful degradation)
- Add --timeout CLI option for user configuration
- Add proper warning/error logging for debugging
The command now completes within the timeout period and allows jobs
to continue even if cost retrieval fails, preventing the recurring
issue of Jenkins job hangs.
Issue: Jobs hanging at stack cost retrieval phase
Affected jobs: daexim-csit, openflowplugin-csit, ovsdb-csit
Change-Id: I645a17f3f2ba430e15b159584984e51ca0454ca8
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>