Repository navigation
Do not shut down networks that are being implemented in the orphaned-network cleanup - #14527
andrijapanicsb wants to merge 1 commit into
Conversation
…network cleanup The cleanup added in apache#12409 moves a network in Implementing to Shutdown when it is older than job.expire.minutes and no pending Network job refers to it. A VM start implements the network inside the VM's own job, so a cleanup run during the implementation shut the network down under the implementing thread, and the start failed with "Network is not yet fully implemented". The implementing thread holds the network's lock for the whole time the network is in Implementing. Try that lock once, without waiting, skip the network if it is held, and re-check the state on the row read under the lock before changing it. Merovingian2.acquire never tried the lock for a timeout of 0 (the wait loop did not run) and logged a timeout WARN. A timeout of 0 or less now makes exactly one attempt and returns without waiting; positive timeouts are unchanged. Fixes apache#14522
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #14527 +/- ##
============================================
+ Coverage 16.43% 16.44% +0.01%
- Complexity 13676 13685 +9
============================================
Files 5669 5669
Lines 501631 501651 +20
Branches 60939 60944 +5
============================================
+ Hits 82420 82475 +55
+ Misses 409975 409940 -35
Partials 9236 9236
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@vladimirpetrov @sureshanaparti we may need to consider this for 4.22.2, as the bug which this PR fixes would exist there are it was forward-merged.. |
|
@blueorangutan package |
|
@Pearl1594 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 19836 |
|
This bug comes, if not mistaken, from 4.20 branch , and is also forward-merged to MAIN, just so that you have the info. Thx |
|
@blueorangutan test |
|
@Pearl1594 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
Description
Fixes #14522.
The problem. The orphaned-network cleanup added in #12409 runs every 10 seconds. It moves a network from Implementing to Shutdown when the network is older than
job.expire.minutesand no pending job of typeNetworkrefers to it. But when a VM start implements a network, that work runs inside the VM's own job. So a network that is being implemented right now looks orphaned, and the cleanup shuts it down under the implementing thread. The start then fails with "Network is not yet fully implemented". The start and deploy APIs retry once, which usually hides it. Instance boot group starts (#13907, on main) start only once, so they fail. HA restarts also start only once (not tested here).The fix.
AsyncJobManagerImpl.cleanupOrphanedNetworks(): the thread that implements a network holds the network's lock the whole time. The cleanup now tries that lock once, without waiting. If the lock is held, the network is skipped. If it is free, the network is re-read under the lock and moved to Shutdown only if it is still Implementing (and the existing pending-job check still passes). A network that is really stuck, for example after a management server crash, is still cleaned up as before.Merovingian2.acquire()(framework/db): with a timeout of 0, today's wait loop never runs, so the lock is never tried and a timeout WARN is logged. Now a timeout of 0 makes exactly one attempt and returns at once. Positive timeouts are unchanged. No current caller passes 0; I checked all call sites (only an administrator settingnetwork.lock.timeout,storage.pool.max.waitsecondsorvm.job.lock.timeoutto 0 could, and today that makes every lock attempt fail).No schema change and no new setting.
How to reproduce
The full description, a log trace and the impact are in #14522. The A/B results on an unpatched build are in this comment.
A quick way on a test system:
job.expire.minutes(default one day). On a test database:UPDATE networks SET created = DATE_SUB(NOW(), INTERVAL 2 DAY) WHERE id = <network id>;. Or use any network created more than a day ago.Found orphaned network <id> in Implementing state without async job, and the first start attempt fails with "Network is not yet fully implemented". The API's retry usually passes. A boot group start fails.With this PR, the orphan WARN no longer appears, and the start passes on its first attempt. At DEBUG level the log shows
Network <id> in Implementing state is locked (being implemented) or was removed, skipping cleanup.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Unit tests:
AsyncJobManagerImplTestcovers these cases:Merovingian2AcquireTest: a timeout of 0 makes one attempt; a positive timeout still waits and retries. framework/db excludescom/cloud/utils/db/*Test*from surefire, so run it with-Dtest=Merovingian2AcquireTest.Before and after, on a single-host KVM test environment:
job.expire.minutesAfter the fix, no "Timed out on acquiring lock" line was logged. The only orphan line was the one for the really stuck network.
Thank you @Pearl1594 for #12409. This keeps its cleanup as it is and only narrows what it treats as orphaned.