Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/agent/server/ifaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package server
import (
"context"
"fmt"
"io/ioutil"
"os"
"path"
"strings"
"sync"
Expand Down Expand Up @@ -150,7 +150,7 @@ func (ij *ifaceJanitor) scan(ctx context.Context) error {

func (ij *ifaceJanitor) scanDescs(hc *utils.HostConfig) (brIfaceMap, error) {
serversPath := hc.ServersPath
fis, err := ioutil.ReadDir(serversPath)
fis, err := os.ReadDir(serversPath)
if err != nil {
return nil, fmt.Errorf("scan servers path %s: %s", serversPath, err)
}
Expand Down
21 changes: 18 additions & 3 deletions pkg/agent/server/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,11 @@ func (w *serversWatcher) FindGuestDescByHostLocalIp(hostLocal *utils.HostLocal,
func (w *serversWatcher) watchEvent(ev *fsnotify.Event) (wev *watchEvent) {
dir, file := filepath.Split(ev.Name)
dir = path.Clean(dir)
if REGEX_UUID.MatchString(file) && dir == w.hostConfig.ServersPath {
log.Debugf("watchEvent: ev.Name: %s, dir: %s, file: %s", ev.Name, dir, file)
if dir == w.hostConfig.ServersPath {
if !REGEX_UUID.MatchString(file) {
return nil
}
wev = &watchEvent{
guestId: file,
guestPath: ev.Name,
Expand All @@ -461,7 +465,18 @@ func (w *serversWatcher) watchEvent(ev *fsnotify.Event) (wev *watchEvent) {
wev.evType = watchEventTypeDelServerDir
return wev
}
} else if file == "desc" {
return nil
}
// else dir != w.hostConfig.ServersPath
parentDir, baseDir := filepath.Split(dir)
if parentDir != w.hostConfig.ServersPath {
return nil
}
if !REGEX_UUID.MatchString(baseDir) {
return nil
}
switch file {
case "desc":
_, guestId := filepath.Split(dir)
if ev.Op&fsnotify.Write != 0 {
wev = &watchEvent{
Expand All @@ -471,7 +486,7 @@ func (w *serversWatcher) watchEvent(ev *fsnotify.Event) (wev *watchEvent) {
}
return wev
}
} else if file == "pid" {
case "pid":
_, guestId := filepath.Split(dir)
wev = &watchEvent{
guestId: guestId,
Expand Down
Loading