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

fix: ovsdb.GetOvsPortForContIface should not return error if iface not found #305

Merged
merged 1 commit into from
Apr 24, 2024
Merged
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
9 changes: 8 additions & 1 deletion pkg/ovsdb/ovsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const (
ovsTable = "Open_vSwitch"
)

var (
errObjectNotFound = errors.New("object not found")
)

// Bridge defines an object in Bridge table
type Bridge struct {
UUID string `ovsdb:"_uuid"`
Expand Down Expand Up @@ -631,6 +635,9 @@ func (ovsd *OvsDriver) GetOvsPortForContIface(contIface, contNetnsPath string) (
colums := []string{"name", "external_ids"}
port, err := ovsd.findByCondition("Port", condition, colums)
if err != nil {
if errors.Is(err, errObjectNotFound) {
return "", false, nil
}
return "", false, err
}

Expand Down Expand Up @@ -745,7 +752,7 @@ func (ovsd *OvsDriver) findByCondition(table string, condition ovsdb.Condition,
}

if len(operationResult.Rows) != 1 {
return nil, fmt.Errorf("failed to find object from table %s", table)
return nil, fmt.Errorf("%w in the table %s", errObjectNotFound, table)
}

return operationResult.Rows[0], nil
Expand Down
Loading