Skip to content

Commit

Permalink
some OVN NB Table's Name field is a pointer type since its optional
Browse files Browse the repository at this point in the history
nil string pointer wasn't properly checked while determining whether
it had empty value

Signed-off-by: Girish Moodalbail <[email protected]>
  • Loading branch information
girishmg committed Feb 8, 2022
1 parent 0eb68cf commit 84b0d46
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions go-controller/pkg/libovsdbops/model_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,19 @@ func (m *ModelClient) create(opModel *OperationModel) ([]ovsdb.Operation, error)
})
} else if info, err := m.client.Cache().DatabaseModel().NewModelInfo(opModel.Model); err == nil {
if name, err := info.FieldByColumn("name"); err == nil {
if len(fmt.Sprint(name)) > 0 {
var objName string
var ok bool
if objName, ok = name.(string); !ok {
if strPtr, ok := name.(*string); ok {
if strPtr != nil {
objName = *strPtr
}
}
}
if len(objName) > 0 {
klog.Warningf("OVSDB Create operation detected without setting opModel Name. Name: %s, %#v",
name, info)
objName, info)

}
}
}
Expand Down

0 comments on commit 84b0d46

Please sign in to comment.