Skip to content

Commit 64335c6

Browse files
authored
fix: remove HNS restart
Signed-off-by: Evan Baker <[email protected]>
1 parent 190269a commit 64335c6

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

platform/os_windows.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"go.uber.org/zap"
2222
"golang.org/x/sys/windows"
2323
"golang.org/x/sys/windows/registry"
24-
"golang.org/x/sys/windows/svc"
25-
"golang.org/x/sys/windows/svc/mgr"
2624
)
2725

2826
const (
@@ -251,10 +249,6 @@ func SetSdnRemoteArpMacAddress(ctx context.Context) error {
251249
return err
252250
}
253251
log.Printf("SDNRemoteArpMacAddress regKey set successfully")
254-
if err := restartHNS(ctx); err != nil {
255-
return err
256-
}
257-
log.Printf("HNS service restarted successfully")
258252
return nil
259253
}
260254

@@ -280,49 +274,6 @@ func setSDNRemoteARPRegKey() error {
280274
return nil
281275
}
282276

283-
func restartHNS(ctx context.Context) error {
284-
log.Printf("Restarting HNS service")
285-
// connect to the service manager
286-
m, err := mgr.Connect()
287-
if err != nil {
288-
return errors.Wrap(err, "could not connect to service manager")
289-
}
290-
defer m.Disconnect() //nolint:errcheck // ignore error
291-
// open the HNS service
292-
service, err := m.OpenService("hns")
293-
if err != nil {
294-
return errors.Wrap(err, "could not access service")
295-
}
296-
defer service.Close()
297-
// Stop the service
298-
_, err = service.Control(svc.Stop)
299-
if err != nil {
300-
return errors.Wrap(err, "could not stop service")
301-
}
302-
// Wait for the service to stop
303-
ticker := time.NewTicker(500 * time.Millisecond) //nolint:gomnd // 500ms
304-
defer ticker.Stop()
305-
for { // hacky cancellable do-while
306-
status, err := service.Query()
307-
if err != nil {
308-
return errors.Wrap(err, "could not query service status")
309-
}
310-
if status.State == svc.Stopped {
311-
break
312-
}
313-
select {
314-
case <-ctx.Done():
315-
return errors.New("context cancelled")
316-
case <-ticker.C:
317-
}
318-
}
319-
// Start the service again
320-
if err := service.Start(); err != nil {
321-
return errors.Wrap(err, "could not start service")
322-
}
323-
return nil
324-
}
325-
326277
func HasMellanoxAdapter() bool {
327278
m := &mellanox.Mellanox{}
328279
return hasNetworkAdapter(m)

0 commit comments

Comments
 (0)