Don't allow adding of existing host to another zone, pod or cluster#13182
Don't allow adding of existing host to another zone, pod or cluster#13182vishesh92 wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 4.20 #13182 +/- ##
============================================
+ Coverage 16.27% 17.12% +0.85%
- Complexity 13440 13443 +3
============================================
Files 5665 5261 -404
Lines 500555 467622 -32933
Branches 60789 54902 -5887
============================================
- Hits 81445 80070 -1375
+ Misses 410004 378616 -31388
+ Partials 9106 8936 -170
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
2f64bcd to
6bf5881
Compare
|
@blueorangutan package |
|
@vishesh92 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 17895 |
Fixes apache#13080 Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
|
@blueorangutan package |
|
@vishesh92 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. |
| try { | ||
| hostIpOrName = new URI(UriUtils.encodeURIComponent(url)).getHost(); | ||
| InetAddress ip = InetAddress.getByName(hostIpOrName); | ||
| ipAddress = ip.getHostAddress(); | ||
| } catch (final URISyntaxException | UnknownHostException ignore) { | ||
| // unparseable URL or unknown host - discoverer will reject it shortly anyway | ||
| } | ||
| if (StringUtils.isBlank(hostIpOrName)) { | ||
| return; | ||
| } | ||
| final HostVO existingByIp = _hostDao.findByIp(ipAddress); |
| InetAddress ip = InetAddress.getByName(hostIpOrName); | ||
| ipAddress = ip.getHostAddress(); | ||
| } catch (final URISyntaxException | UnknownHostException ignore) { | ||
| // unparseable URL or unknown host - discoverer will reject it shortly anyway | ||
| } | ||
| if (StringUtils.isBlank(hostIpOrName)) { | ||
| return; | ||
| } | ||
| final HostVO existingByIp = _hostDao.findByIp(ipAddress); | ||
| if (existingByIp != null) { | ||
| throw new InvalidParameterValueException(String.format( | ||
| "A host with IP address / hostname '%s' (%s) already exists (id: %s). Remove it before adding again.", | ||
| hostIpOrName, ipAddress, existingByIp.getUuid())); | ||
| } |
|
|
||
| protected void validateExistingHostLocationImmutable(final HostVO host, final boolean newHost, | ||
| final long dcId, final Long podId, final Long clusterId, final StartupCommand startup) { | ||
| if (newHost || host == null || host.getType() != Host.Type.Routing) { |
| final String identity = host.getUuid() != null ? host.getUuid() : host.getGuid(); | ||
| final String ip = startup != null ? startup.getPrivateIpAddress() : "unknown"; | ||
| throw new InvalidParameterValueException(String.format( | ||
| "Host %s (ip: %s) is already registered in [zone: %d, pod: %d, cluster: %d] and cannot be re-added or reconnected with [zone: %d, pod: %s, cluster: %s]. Zone, pod and cluster of an existing host are immutable.", |
| verify(hostDao, times(1)).findByIp("10.0.0.30"); | ||
| } | ||
|
|
||
| @Test |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17901 |
Description
This PR fixes #13080
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?