Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give an error on non-existing devices #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions hostdevice.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func (d HostDevice) Expand() ([]*ExpandedHostDevice, error) {
if err != nil {
return nil, err
}
if len(matchedHostPath) == 0 {
return nil, fmt.Errorf("no file matched: %s", d.HostPath)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking change. Could you introduce feature switch for this??

}

expanded := []*ExpandedHostDevice{}
baseHostPath := strings.Split(d.HostPath, "*")[0]
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
log.Println("Starting FS watcher.")
watcher, err := newFSWatcher(pluginapi.DevicePluginPath)
if err != nil {
log.Println("Failed to created FS watcher.")
log.Printf("Failed to created FS watcher: %v", err)
os.Exit(1)
}
defer watcher.Close()
Expand All @@ -34,7 +34,7 @@ func main() {
log.Println("Reading /k8s-host-device-plugin/config.json")
raw, err := ioutil.ReadFile(ConfigFilePath)
if err != nil {
fmt.Println(err.Error())
log.Printf("Fatal error reading config file: %v", err)
os.Exit(1)
}

Expand All @@ -56,7 +56,7 @@ L:

devicePlugin, err = NewHostDevicePlugin(config)
if err != nil {
fmt.Println(err.Error())
log.Printf("Fatal error configuring host device: %v", err)
os.Exit(1)
}
expandedHostDevicesStr := []string{}
Expand Down