diff --git a/agent/hypervisor/feature_helpers_test.go b/agent/hypervisor/feature_helpers_test.go
index f8c727f6..e2ccf10b 100644
--- a/agent/hypervisor/feature_helpers_test.go
+++ b/agent/hypervisor/feature_helpers_test.go
@@ -189,6 +189,42 @@ func TestSanitizeSeedForDiskAuthoritativeRecoveryKeepsOnlyNetworkIntent(t *testi
}
}
+func TestDiskAuthoritativeRecoveryPreservesCurrentVPCNetworkIntent(t *testing.T) {
+ port := validVPCPortMetadata()
+ attached, err := mutateSeedVPCPort(
+ managedSeedForTest(t), port, "operation-vpc-before-recovery", true,
+ )
+ if err != nil {
+ t.Fatal(err)
+ }
+ recovered, err := sanitizeSeedForDiskAuthoritativeRecovery(
+ attached, "operation-recover-vpc-backup",
+ )
+ if err != nil {
+ t.Fatal(err)
+ }
+ private, err := seedVPCPort(recovered)
+ if err != nil {
+ t.Fatal(err)
+ }
+ want := seedVPCNetwork{
+ MAC: port.MAC, PrivateIP: port.PrivateIP,
+ CIDR: port.CIDR, Gateway: port.Gateway,
+ }
+ if private == nil || *private != want {
+ t.Fatalf("recovered VPC network = %#v, want %#v", private, want)
+ }
+ publicMAC, publicCIDR, gateway, dns, err := seedNetwork(recovered)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if publicMAC != "52:54:00:12:34:56" || publicCIDR != "8.8.8.10/24" ||
+ gateway != "8.8.8.1" || strings.Join(dns, ",") != "1.1.1.1" {
+ t.Fatalf("recovery changed public network: %q %q %q %v",
+ publicMAC, publicCIDR, gateway, dns)
+ }
+}
+
func TestDiskAuthoritativeRecoverySeedAllowsExplicitFutureSettings(t *testing.T) {
sanitized, err := sanitizeSeedForDiskAuthoritativeRecovery(
managedSeedForTest(t), "operation-recover-backup",
diff --git a/agent/hypervisor/libvirt_safety_test.go b/agent/hypervisor/libvirt_safety_test.go
index 53a8dd04..f175ebfc 100644
--- a/agent/hypervisor/libvirt_safety_test.go
+++ b/agent/hypervisor/libvirt_safety_test.go
@@ -1568,7 +1568,7 @@ func TestNetworkAndFirewallReadOnlyEvidenceMatchers(t *testing.T) {
func TestNetworkInterfaceLinkDocumentsBuildAllUpdatesBeforeMutation(t *testing.T) {
document := `` +
`` +
- `` +
+ `` +
``
for _, enabled := range []bool{false, true} {
documents, err := networkInterfaceLinkDocuments(document, enabled)
@@ -1591,6 +1591,11 @@ func TestNetworkInterfaceLinkDocumentsBuildAllUpdatesBeforeMutation(t *testing.T
!managedInterfaceFilterIPMatches(&iface, "virt-test", "203.0.113.10/24") {
t.Fatalf("network state update dropped managed IP binding: %s", update)
}
+ if iface.MAC != nil && iface.MAC.Address == "02:00:00:00:00:02" &&
+ (iface.Source == nil || iface.Source.Bridge == nil ||
+ iface.Source.Bridge.Bridge != "vpc-a1b2c3d4e5") {
+ t.Fatalf("network state update changed the VPC bridge: %s", update)
+ }
}
}
if documents, err := networkInterfaceLinkDocuments(``, false); err == nil || len(documents) != 0 {