in cmd/core_plugin/network/netplan/netplan_linux.go [310:347]
func (sn *serviceNetplan) Rollback(ctx context.Context, opts *service.Options) error {
galog.Infof("Rolling back changes for netplan.")
// Rollback the backend's drop-in files.
for _, backend := range backends {
if err := backend.RollbackDropins(opts.NICConfigs, backendDropinPrefix); err != nil {
return err
}
}
// Remove the netplan drop-in file.
if file.Exists(sn.ethernetDropinFile(), file.TypeFile) {
if err := os.Remove(sn.ethernetDropinFile()); err != nil {
return fmt.Errorf("error removing netplan dropin: %w", err)
}
}
// Remove the netplan vlan drop-in file.
vlanDropin := sn.vlanDropinFile()
if file.Exists(vlanDropin, file.TypeFile) {
if err := os.Remove(vlanDropin); err != nil {
return fmt.Errorf("error removing netplan vlan dropin: %w", err)
}
}
// Remove the routes managed by us using the "native" implementation if the
// running system's netplan doesn't support local routes.
if !sn.dropinRoutes {
// Remove the routes managed by us.
for _, nic := range opts.NICConfigs {
if err := route.RemoveRoutes(ctx, nic.Interface.Name()); err != nil {
return fmt.Errorf("failed to remove native routes managed by netplan manager: %w", err)
}
}
}
return nil
}