Repository navigation
Conversation
…airs listDetailsKeyPairs(resourceId, keys) and listDetailsKeyPairsWithVisibility collected the rows with Collectors.toMap without a merge function, so a resource with two rows of the same name made the call throw IllegalStateException. listDetailsKeyPairs(resourceId) already keeps the last value in that case; do the same here. Fixes apache#14709
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #14709
createConsoleEndpointfails withDuplicate key kvm.vnc.address (attempted merging values 10.x.x.x and 10.x.x.x)for a VM that has twokvm.vnc.addressrows invm_instance_details.ConsoleAccessManagerImpl.getConsoleConnectionDetailsreads the VM's keyboard and VNC details withvmInstanceDetailsDao.listDetailsKeyPairs(vmId, keys), andResourceDetailsDaoBasebuilds that map withCollectors.toMapwithout a merge function throwsIllegalStateExceptionon the first duplicate name, which is exactly the message in the report. The siblinglistDetailsKeyPairs(long resourceId)fills aHashMapwithput, so for the same rows it keeps the last value and does not fail.This change gives both
toMapcalls inResourceDetailsDaoBase(the one above and the one inlistDetailsKeyPairsWithVisibility) a merge function that keeps the last value, so all three key-pair methods behave the same. That is the "console endpoint creation should tolerate duplicate detail keys" half of the expected behaviour in the issue.How the second row got there is not addressed here, and I haven't confirmed it. One way it can happen:
ResourceDetailsDaoBase.addDetail(R)doesfindDetail,remove,persistwith no transaction around it and there is no unique key on(vm_id, name), so two overlapping writes of the same detail can each insert a row. Making that write atomic touches every details table, so I've kept it out of this fix; happy to look at it separately if wanted.Types of changes
Feature/Enhancement Scale or Bug Severity
Bug Severity
How Has This Been Tested?
Added three tests to
ResourceDetailsDaoBaseTest:listDetailsKeyPairs(resourceId, keys)withkvm.vnc.addressstored twice with the same value, as in the report, pluskvm.vnc.portlistDetailsKeyPairsWithVisibilitywith a name stored twiceWith the two merge functions removed, all three new tests fail, the first one with the message from the report:
I don't have a KVM host to repeat the failed-maintenance sequence on, so this is tested at the DAO level only.