Skip to content

Commit

Permalink
Fix netplan configuration on Debian 12.
Browse files Browse the repository at this point in the history
Drop in netplan files with higher priority rather than deleting the defaults.
  • Loading branch information
a-crate committed Jul 17, 2024
1 parent 79a1124 commit c11491a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions google_guest_agent/network/manager/netplan_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ func (n netplan) Name() string {
// Configure gives the opportunity for the Service implementation to adjust its configuration
// based on the Guest Agent configuration.
func (n netplan) Configure(ctx context.Context, config *cfg.Sections) {
osInfo := osinfoGet()
// Debian's default netplan configuration is priority 90.
if osInfo.OS == "debian" && osInfo.Version.Major == 12 {
n.priority = 91
}
}

// IsManaging checks whether netplan is present in the system.
Expand Down Expand Up @@ -181,15 +186,6 @@ func (n netplan) SetupEthernetInterface(ctx context.Context, config *cfg.Section
return fmt.Errorf("error writing systemd-networkd's drop-in: %v", err)
}

osInfo := osinfoGet()
// Debian 12 has a pretty generic matching netplan configuration for gce, until we have that
// changed we are only removing.
if osInfo.OS == "debian" && osInfo.Version.Major == 12 {
if err := os.Remove("/etc/netplan/90-default.yaml"); err != nil {
logger.Debugf("Failed to remove default netplan config: %s", err)
}
}

// Avoid restarting systemd-networkd.
if err := run.Quiet(ctx, "networkctl", "reload"); err != nil {
return fmt.Errorf("error reloading systemd-networkd network configs: %v", err)
Expand Down

0 comments on commit c11491a

Please sign in to comment.