|
|
|
|
@ -898,7 +898,7 @@ $assert(count($boundedObserved['hosts'] ?? []) === 257
|
|
|
|
|
'Observed proof persistence still truncates hosts, routes or peers at 256.');
|
|
|
|
|
|
|
|
|
|
// A fully proven historical pair must release both uniqueness keys before a
|
|
|
|
|
// same-VPC attach reserves the original explicit address again. The host stays
|
|
|
|
|
// same-VPC attach automatically reserves the lowest free address again. The host stays
|
|
|
|
|
// active for a real sibling, so absence is proven by exact NIC/route/proxy
|
|
|
|
|
// evidence rather than by treating an active empty bridge as a removal receipt.
|
|
|
|
|
$same = $seedVpc(1, '10.41.0.0/24', '10.41.0.0/29', 10, 'active', 'active', [
|
|
|
|
|
@ -910,8 +910,7 @@ $seedInstance(1002, 10);
|
|
|
|
|
$seedPair(10001, 20001, $same, 1001, 10, '10.41.0.1');
|
|
|
|
|
$seedPair(10002, 20002, $same, 1002, 10, '10.41.0.2', 'active');
|
|
|
|
|
$sameInput = [
|
|
|
|
|
'subnet_key' => $same['subnet_key'], 'instance_id' => 1001,
|
|
|
|
|
'private_ip' => '10.41.0.1', 'request_key' => 'reuse-same-vpc-0001',
|
|
|
|
|
'instance_id' => 1001, 'request_key' => 'reuse-same-vpc-0001',
|
|
|
|
|
];
|
|
|
|
|
CloudVpcService::attachMember($same['vpc_key'], $actor, $sameInput);
|
|
|
|
|
$sameMember = Capsule::table('cloud_vpc_members')->where('instance_id', 1001)->first();
|
|
|
|
|
@ -949,6 +948,66 @@ $assert(Capsule::table('cloud_vpc_members')->where('instance_id', 1001)->count()
|
|
|
|
|
&& (int) Capsule::table('cloud_vpcs')->where('id', 1)->value('desired_revision') === 2,
|
|
|
|
|
'An idempotent attach replay duplicated identities or advanced the VPC revision.');
|
|
|
|
|
|
|
|
|
|
// A pre-policy client could have supplied the selected address explicitly.
|
|
|
|
|
// Its immutable operation remains replayable even if the automatic subnet is
|
|
|
|
|
// now cleaning: replay identity is proven from the old signed desired payload,
|
|
|
|
|
// before mutable subnet/instance preconditions are consulted.
|
|
|
|
|
$legacyExplicitHash = hash('sha256', $canonicalJson([
|
|
|
|
|
'kind' => 'member_attach',
|
|
|
|
|
'input' => [
|
|
|
|
|
'subnet_key' => $same['subnet_key'],
|
|
|
|
|
'instance_id' => 1001,
|
|
|
|
|
'private_ip' => '10.41.0.1',
|
|
|
|
|
],
|
|
|
|
|
]));
|
|
|
|
|
Capsule::table('cloud_vpc_operations')->where('vpc_id', 1)
|
|
|
|
|
->where('idempotency_key', 'reuse-same-vpc-0001')
|
|
|
|
|
->update(['request_hash' => $legacyExplicitHash]);
|
|
|
|
|
Capsule::table('cloud_vpc_subnets')->where('id', $same['subnet_id'])
|
|
|
|
|
->update(['state' => 'deleting']);
|
|
|
|
|
Capsule::table('cloud_instances')->where('id', 1001)->update([
|
|
|
|
|
'status' => 'deleting', 'updated_at' => $now + 3,
|
|
|
|
|
]);
|
|
|
|
|
CloudVpcService::attachMember($same['vpc_key'], $actor, $sameInput);
|
|
|
|
|
CloudVpcService::attachMember($same['vpc_key'], $actor, [
|
|
|
|
|
...$sameInput,
|
|
|
|
|
'subnet_key' => $same['subnet_key'],
|
|
|
|
|
'private_ip' => '10.41.0.1',
|
|
|
|
|
]);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$same['vpc_key'], $actor, [
|
|
|
|
|
...$sameInput,
|
|
|
|
|
'subnet_key' => $same['subnet_key'],
|
|
|
|
|
'private_ip' => '10.41.0.3',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$legacyWhitespaceIp = ' 10.41.0.1 ';
|
|
|
|
|
$legacyWhitespaceHash = hash('sha256', $canonicalJson([
|
|
|
|
|
'kind' => 'member_attach',
|
|
|
|
|
'input' => [
|
|
|
|
|
'subnet_key' => $same['subnet_key'],
|
|
|
|
|
'instance_id' => 1001,
|
|
|
|
|
'private_ip' => $legacyWhitespaceIp,
|
|
|
|
|
],
|
|
|
|
|
]));
|
|
|
|
|
Capsule::table('cloud_vpc_operations')->where('vpc_id', 1)
|
|
|
|
|
->where('idempotency_key', 'reuse-same-vpc-0001')
|
|
|
|
|
->update(['request_hash' => $legacyWhitespaceHash]);
|
|
|
|
|
CloudVpcService::attachMember($same['vpc_key'], $actor, [
|
|
|
|
|
...$sameInput,
|
|
|
|
|
'subnet_key' => $same['subnet_key'],
|
|
|
|
|
'private_ip' => $legacyWhitespaceIp,
|
|
|
|
|
]);
|
|
|
|
|
Capsule::table('cloud_vpc_subnets')->where('id', $same['subnet_id'])
|
|
|
|
|
->update(['state' => 'active']);
|
|
|
|
|
Capsule::table('cloud_instances')->where('id', 1001)->update([
|
|
|
|
|
'status' => 'active', 'updated_at' => $now + 4,
|
|
|
|
|
]);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('instance_id', 1001)->count() === 1
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('instance_id', 1001)->count() === 1
|
|
|
|
|
&& (int) Capsule::table('cloud_vpcs')->where('id', 1)->value('desired_revision') === 2,
|
|
|
|
|
'A legacy explicit-IP attach did not replay exactly before mutable subnet checks.');
|
|
|
|
|
|
|
|
|
|
// Keep the production uniqueness barriers present and executable. The service
|
|
|
|
|
// succeeds above because it physically deleted the old rows, not because the
|
|
|
|
|
// schema or application merely stopped looking at them.
|
|
|
|
|
@ -1004,12 +1063,11 @@ $target = $seedVpc(3, '10.43.0.0/24', '10.43.0.0/29', 20,
|
|
|
|
|
$seedInstance(2001, 20);
|
|
|
|
|
$seedPair(20001, 30001, $source, 2001, 20, '10.42.0.1');
|
|
|
|
|
CloudVpcService::attachMember($target['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $target['subnet_key'], 'instance_id' => 2001,
|
|
|
|
|
'private_ip' => '10.43.0.5', 'request_key' => 'reuse-cross-vpc-0001',
|
|
|
|
|
'instance_id' => 2001, 'request_key' => 'reuse-cross-vpc-0001',
|
|
|
|
|
]);
|
|
|
|
|
$crossMember = Capsule::table('cloud_vpc_members')->where('instance_id', 2001)->first();
|
|
|
|
|
$assert($crossMember !== null && (int) $crossMember->vpc_id === 3
|
|
|
|
|
&& (string) $crossMember->private_ip === '10.43.0.5'
|
|
|
|
|
&& (string) $crossMember->private_ip === '10.43.0.1'
|
|
|
|
|
&& Capsule::table('cloud_vpc_members')->where('id', 20001)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('id', 30001)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpcs')->where('id', 2)->count() === 1
|
|
|
|
|
@ -1027,8 +1085,7 @@ $seedInstance(3001, 30);
|
|
|
|
|
$seedInstance(3003, 30);
|
|
|
|
|
$seedPair(30001, 40001, $automatic, 3001, 30, '10.44.0.1');
|
|
|
|
|
CloudVpcService::attachMember($automatic['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $automatic['subnet_key'], 'instance_id' => 3003,
|
|
|
|
|
'request_key' => 'reuse-auto-lowest-0001',
|
|
|
|
|
'instance_id' => 3003, 'request_key' => 'reuse-auto-lowest-0001',
|
|
|
|
|
]);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 30001)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('id', 40001)->count() === 0
|
|
|
|
|
@ -1050,8 +1107,7 @@ Capsule::table('cloud_vpcs')->where('id', 5)->update([
|
|
|
|
|
'last_operation_id' => $keyFor('newer-operation', 5),
|
|
|
|
|
]);
|
|
|
|
|
CloudVpcService::attachMember($rootAdvanced['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $rootAdvanced['subnet_key'], 'instance_id' => 4001,
|
|
|
|
|
'private_ip' => '10.45.0.1', 'request_key' => 'reuse-monotonic-root-0001',
|
|
|
|
|
'instance_id' => 4001, 'request_key' => 'reuse-monotonic-root-0001',
|
|
|
|
|
]);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 40001)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('id', 50001)->count() === 0
|
|
|
|
|
@ -1073,8 +1129,7 @@ Capsule::table('cloud_vpc_operations')
|
|
|
|
|
]);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$operationIncomplete['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $operationIncomplete['subnet_key'], 'instance_id' => 5001,
|
|
|
|
|
'private_ip' => '10.46.0.1', 'request_key' => 'reuse-operation-block-0001',
|
|
|
|
|
'instance_id' => 5001, 'request_key' => 'reuse-operation-block-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 50001)->count() === 1
|
|
|
|
|
@ -1095,8 +1150,7 @@ $seedPair(60001, 70001, $hostIncomplete, 6001, 60, '10.47.0.1');
|
|
|
|
|
$seedPair(60002, 70002, $hostIncomplete, 6002, 60, '10.47.0.2', 'active');
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$hostIncomplete['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $hostIncomplete['subnet_key'], 'instance_id' => 6001,
|
|
|
|
|
'private_ip' => '10.47.0.1', 'request_key' => 'reuse-host-block-0001',
|
|
|
|
|
'instance_id' => 6001, 'request_key' => 'reuse-host-block-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 60001)->count() === 1
|
|
|
|
|
@ -1120,8 +1174,7 @@ Capsule::table('cloud_vpc_private_ips')->insert([
|
|
|
|
|
]);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$orphanVpc['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $orphanVpc['subnet_key'], 'instance_id' => 7001,
|
|
|
|
|
'private_ip' => '10.48.0.1', 'request_key' => 'reuse-orphan-block-0001',
|
|
|
|
|
'instance_id' => 7001, 'request_key' => 'reuse-orphan-block-0001',
|
|
|
|
|
]
|
|
|
|
|
), 503);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_private_ips')->where('id', 80001)->count() === 1
|
|
|
|
|
@ -1145,8 +1198,7 @@ Capsule::table('cloud_vpc_private_ips')->where('id', 90001)->update([
|
|
|
|
|
]);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$createdLater['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $createdLater['subnet_key'], 'instance_id' => 8001,
|
|
|
|
|
'private_ip' => '10.49.0.1', 'request_key' => 'reuse-created-later-block-0001',
|
|
|
|
|
'instance_id' => 8001, 'request_key' => 'reuse-created-later-block-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 80001)->count() === 1
|
|
|
|
|
@ -1184,9 +1236,7 @@ foreach ([
|
|
|
|
|
)->update(['created_at' => 0]);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$timestampVpc['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $timestampVpc['subnet_key'],
|
|
|
|
|
'instance_id' => (int) $invalidCreatedAt['instance_id'],
|
|
|
|
|
'private_ip' => (string) $invalidCreatedAt['ip'],
|
|
|
|
|
'request_key' => 'reuse-zero-created-' . $invalidCreatedAt['zero'],
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
@ -1211,8 +1261,7 @@ $seedPair(90002, 100002, $nextHopReferenced, 9002, 90, '10.50.0.2', 'active');
|
|
|
|
|
$seedRoute(100001, $nextHopReferenced, 90002, '10.50.0.3/32', '10.50.0.1');
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$nextHopReferenced['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $nextHopReferenced['subnet_key'], 'instance_id' => 9001,
|
|
|
|
|
'private_ip' => '10.50.0.1', 'request_key' => 'reuse-next-hop-block-0001',
|
|
|
|
|
'instance_id' => 9001, 'request_key' => 'reuse-next-hop-block-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 90001)->count() === 1
|
|
|
|
|
@ -1244,8 +1293,7 @@ $seedPair(100002, 110002, $destinationReferenced, 10002, 100, '10.51.0.2', 'acti
|
|
|
|
|
$seedRoute(110001, $destinationReferenced, 100002, '10.51.0.1/32', '10.51.0.2');
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$destinationReferenced['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $destinationReferenced['subnet_key'], 'instance_id' => 10001,
|
|
|
|
|
'private_ip' => '10.51.0.1', 'request_key' => 'reuse-destination-block-0001',
|
|
|
|
|
'instance_id' => 10001, 'request_key' => 'reuse-destination-block-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 100001)->count() === 1
|
|
|
|
|
@ -1256,8 +1304,8 @@ $assert(Capsule::table('cloud_vpc_members')->where('id', 100001)->count() === 1
|
|
|
|
|
'A live destination /32 reference released the retired member/IP pair.');
|
|
|
|
|
|
|
|
|
|
// A custom /32 is part of the same route namespace as implicit member /32s.
|
|
|
|
|
// Explicit attach must reject it, automatic allocation must skip it, and route
|
|
|
|
|
// replacement must not create the inverse conflict against a live member.
|
|
|
|
|
// Automatic allocation must skip it, and route replacement must not create the
|
|
|
|
|
// inverse conflict against a live member.
|
|
|
|
|
$routeReservedMemberKey = $keyFor('member', 190002);
|
|
|
|
|
$routeReservedPayload = [[
|
|
|
|
|
'route_id' => $keyFor('route', 190001),
|
|
|
|
|
@ -1285,15 +1333,8 @@ $expectCloudError(static fn () => CloudVpcService::replaceRoutes(
|
|
|
|
|
'request_key' => 'route-member-conflict-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$routeReserved['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $routeReserved['subnet_key'], 'instance_id' => 19001,
|
|
|
|
|
'private_ip' => '10.59.0.1', 'request_key' => 'route-ip-explicit-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
CloudVpcService::attachMember($routeReserved['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $routeReserved['subnet_key'], 'instance_id' => 19003,
|
|
|
|
|
'request_key' => 'route-ip-auto-0001',
|
|
|
|
|
'instance_id' => 19003, 'request_key' => 'route-ip-auto-0001',
|
|
|
|
|
]);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('instance_id', 19001)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_members')->where('instance_id', 19003)
|
|
|
|
|
@ -1329,8 +1370,7 @@ $installCurrentProof($rejoinedHost, [
|
|
|
|
|
'host_id' => 120, 'private_ip' => '10.52.0.3'],
|
|
|
|
|
], [110, 120]);
|
|
|
|
|
CloudVpcService::attachMember($rejoinedHost['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $rejoinedHost['subnet_key'], 'instance_id' => 12001,
|
|
|
|
|
'private_ip' => '10.52.0.1', 'request_key' => 'reuse-current-host-set-0001',
|
|
|
|
|
'instance_id' => 12001, 'request_key' => 'reuse-current-host-set-0001',
|
|
|
|
|
]);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 120001)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('id', 120101)->count() === 0
|
|
|
|
|
@ -1367,8 +1407,7 @@ $installCurrentProof($missingRejoinedHost, [
|
|
|
|
|
], [130]);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$missingRejoinedHost['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $missingRejoinedHost['subnet_key'], 'instance_id' => 13001,
|
|
|
|
|
'private_ip' => '10.53.0.1', 'request_key' => 'reuse-current-host-missing-0001',
|
|
|
|
|
'instance_id' => 13001, 'request_key' => 'reuse-current-host-missing-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 130001)->count() === 1
|
|
|
|
|
@ -1392,8 +1431,7 @@ $seedInstance(16001, 90);
|
|
|
|
|
$seedPair(160001, 160101, $ownerRemoval, 16001, 90, '10.56.0.1');
|
|
|
|
|
$installRemovalProof($ownerRemoval, 90, true);
|
|
|
|
|
CloudVpcService::attachMember($ownerRemoval['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $ownerRemoval['subnet_key'], 'instance_id' => 16001,
|
|
|
|
|
'private_ip' => '10.56.0.1', 'request_key' => 'reuse-owner-proof-0001',
|
|
|
|
|
'instance_id' => 16001, 'request_key' => 'reuse-owner-proof-0001',
|
|
|
|
|
]);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('id', 160001)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('id', 160101)->count() === 0
|
|
|
|
|
@ -1480,9 +1518,7 @@ foreach ([
|
|
|
|
|
}
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$partialVpc['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $partialVpc['subnet_key'],
|
|
|
|
|
'instance_id' => $retiredInstanceId,
|
|
|
|
|
'private_ip' => '10.' . $secondOctet . '.0.1',
|
|
|
|
|
'request_key' => 'reuse-partial-' . $reason . '-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
@ -1494,9 +1530,7 @@ foreach ([
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
CloudVpcService::attachMember($partialVpc['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $partialVpc['subnet_key'],
|
|
|
|
|
'instance_id' => $retiredInstanceId,
|
|
|
|
|
'private_ip' => '10.' . $secondOctet . '.0.1',
|
|
|
|
|
'request_key' => 'reuse-partial-owner-0001',
|
|
|
|
|
]);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')
|
|
|
|
|
@ -1509,6 +1543,134 @@ foreach ([
|
|
|
|
|
'A later global proof did not combine with the exact partial owner receipt.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tenant membership intent contains only the instance and idempotency key.
|
|
|
|
|
// Subnet selection and private-IP allocation are platform policy, even when a
|
|
|
|
|
// caller guesses the current automatically managed values.
|
|
|
|
|
$strictAttach = $seedVpc(
|
|
|
|
|
22, '10.62.0.0/24', '10.62.0.0/29', 160,
|
|
|
|
|
'active', 'active'
|
|
|
|
|
);
|
|
|
|
|
$seedInstance(22001, 160);
|
|
|
|
|
foreach ([
|
|
|
|
|
'subnet_key' => $strictAttach['subnet_key'],
|
|
|
|
|
'private_ip' => '10.62.0.1',
|
|
|
|
|
] as $field => $value) {
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$strictAttach['vpc_key'], $actor, [
|
|
|
|
|
'instance_id' => 22001,
|
|
|
|
|
'request_key' => 'strict-attach-' . str_replace('_', '-', $field),
|
|
|
|
|
$field => $value,
|
|
|
|
|
]
|
|
|
|
|
), 422);
|
|
|
|
|
}
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('vpc_id', 22)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('vpc_id', 22)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_operations')->where('vpc_id', 22)->count() === 1
|
|
|
|
|
&& (int) Capsule::table('cloud_vpcs')->where('id', 22)
|
|
|
|
|
->value('desired_revision') === 1,
|
|
|
|
|
'Forbidden subnet/private-IP fields changed durable membership state.');
|
|
|
|
|
|
|
|
|
|
// A missing or cleaning automatic subnet is a retryable policy conflict. The
|
|
|
|
|
// service must not fabricate a subnet or allocate an address while its only
|
|
|
|
|
// durable subnet identity is still a tombstone.
|
|
|
|
|
$cleaningSubnet = $seedVpc(
|
|
|
|
|
23, '10.63.0.0/24', '10.63.0.0/29', 170,
|
|
|
|
|
'active', 'active'
|
|
|
|
|
);
|
|
|
|
|
$seedInstance(23001, 170);
|
|
|
|
|
Capsule::table('cloud_vpc_subnets')
|
|
|
|
|
->where('id', $cleaningSubnet['subnet_id'])->update(['state' => 'deleting']);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$cleaningSubnet['vpc_key'], $actor, [
|
|
|
|
|
'instance_id' => 23001, 'request_key' => 'cleaning-subnet-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('vpc_id', 23)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('vpc_id', 23)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_operations')->where('vpc_id', 23)->count() === 1
|
|
|
|
|
&& (int) Capsule::table('cloud_vpcs')->where('id', 23)
|
|
|
|
|
->value('desired_revision') === 1,
|
|
|
|
|
'A cleaning automatic subnet allowed a partial member attachment.');
|
|
|
|
|
|
|
|
|
|
// The same conflict applies if a damaged/historical root has no remaining
|
|
|
|
|
// subnet row at all. Absence is not permission to recreate policy state during
|
|
|
|
|
// an unrelated membership request.
|
|
|
|
|
$missingSubnet = $seedVpc(
|
|
|
|
|
25, '10.65.0.0/24', '10.65.0.0/29', 190,
|
|
|
|
|
'active', 'active'
|
|
|
|
|
);
|
|
|
|
|
$seedInstance(25001, 190);
|
|
|
|
|
Capsule::table('cloud_vpc_subnets')
|
|
|
|
|
->where('id', $missingSubnet['subnet_id'])->delete();
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$missingSubnet['vpc_key'], $actor, [
|
|
|
|
|
'instance_id' => 25001, 'request_key' => 'missing-subnet-0001',
|
|
|
|
|
]
|
|
|
|
|
), 409);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('vpc_id', 25)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('vpc_id', 25)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_operations')->where('vpc_id', 25)->count() === 1
|
|
|
|
|
&& (int) Capsule::table('cloud_vpcs')->where('id', 25)
|
|
|
|
|
->value('desired_revision') === 1,
|
|
|
|
|
'A missing automatic subnet allowed a partial member attachment.');
|
|
|
|
|
|
|
|
|
|
// Corrupted automatic-subnet identity must fail before desired-state signing;
|
|
|
|
|
// otherwise the engine would reject the malformed subnet_id after local rows
|
|
|
|
|
// had already been allocated.
|
|
|
|
|
$invalidSubnetKey = $seedVpc(
|
|
|
|
|
26, '10.66.0.0/24', '10.66.0.0/29', 200,
|
|
|
|
|
'active', 'active'
|
|
|
|
|
);
|
|
|
|
|
$seedInstance(26001, 200);
|
|
|
|
|
Capsule::table('cloud_vpc_subnets')
|
|
|
|
|
->where('id', $invalidSubnetKey['subnet_id'])
|
|
|
|
|
->update(['subnet_key' => 'invalid-subnet-key']);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$invalidSubnetKey['vpc_key'], $actor, [
|
|
|
|
|
'instance_id' => 26001, 'request_key' => 'invalid-subnet-key-0001',
|
|
|
|
|
]
|
|
|
|
|
), 503);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('vpc_id', 26)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('vpc_id', 26)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_operations')->where('vpc_id', 26)->count() === 1
|
|
|
|
|
&& (int) Capsule::table('cloud_vpcs')->where('id', 26)
|
|
|
|
|
->value('desired_revision') === 1,
|
|
|
|
|
'A malformed automatic subnet identity leaked partial member state.');
|
|
|
|
|
|
|
|
|
|
// Historical multi-subnet roots remain readable/deletable, but automatic IPAM
|
|
|
|
|
// cannot choose between two live ranges. Fail closed before allocating any
|
|
|
|
|
// member or operation rather than silently selecting the oldest row.
|
|
|
|
|
$multipleSubnets = $seedVpc(
|
|
|
|
|
24, '10.64.0.0/24', '10.64.0.0/29', 180,
|
|
|
|
|
'active', 'active'
|
|
|
|
|
);
|
|
|
|
|
$seedInstance(24001, 180);
|
|
|
|
|
$secondSubnetNetwork = $ipToInt('10.64.0.8');
|
|
|
|
|
Capsule::table('cloud_vpc_subnets')->insert([
|
|
|
|
|
'id' => 2024, 'subnet_key' => $keyFor('subnet-extra', 24),
|
|
|
|
|
'vpc_id' => 24, 'cidr' => '10.64.0.8/29',
|
|
|
|
|
'network_address' => $secondSubnetNetwork,
|
|
|
|
|
'broadcast_address' => $secondSubnetNetwork + 7,
|
|
|
|
|
'prefix_length' => 29, 'gateway_ip' => null,
|
|
|
|
|
'state' => 'active', 'desired_revision' => 1, 'observed_revision' => 1,
|
|
|
|
|
'desired_digest' => $multipleSubnets['digest'],
|
|
|
|
|
'observed_digest' => $multipleSubnets['digest'],
|
|
|
|
|
'last_error_code' => null, 'created_at' => $now, 'updated_at' => $now,
|
|
|
|
|
]);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$multipleSubnets['vpc_key'], $actor, [
|
|
|
|
|
'instance_id' => 24001, 'request_key' => 'multiple-subnets-0001',
|
|
|
|
|
]
|
|
|
|
|
), 503);
|
|
|
|
|
$assert(Capsule::table('cloud_vpc_members')->where('vpc_id', 24)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_private_ips')->where('vpc_id', 24)->count() === 0
|
|
|
|
|
&& Capsule::table('cloud_vpc_subnets')->where('vpc_id', 24)
|
|
|
|
|
->where('state', 'active')->count() === 2
|
|
|
|
|
&& Capsule::table('cloud_vpc_operations')->where('vpc_id', 24)->count() === 1
|
|
|
|
|
&& (int) Capsule::table('cloud_vpcs')->where('id', 24)
|
|
|
|
|
->value('desired_revision') === 1,
|
|
|
|
|
'A historical multi-subnet root was mutated or silently auto-selected.');
|
|
|
|
|
|
|
|
|
|
// A deleting member still owns its address and possible host-side device.
|
|
|
|
|
// It must consume capacity until exact tombstone convergence removes it.
|
|
|
|
|
$deletingCapacity = $seedVpc(
|
|
|
|
|
@ -1524,7 +1686,6 @@ $seedPair(
|
|
|
|
|
);
|
|
|
|
|
$expectCloudError(static fn () => CloudVpcService::attachMember(
|
|
|
|
|
$deletingCapacity['vpc_key'], $actor, [
|
|
|
|
|
'subnet_key' => $deletingCapacity['subnet_key'],
|
|
|
|
|
'instance_id' => 21002,
|
|
|
|
|
'request_key' => 'deleting-capacity-0001',
|
|
|
|
|
]
|
|
|
|
|
|