Skip to content

Commit

Permalink
do not exit if chassis is not found (#4246)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian committed Jul 2, 2024
1 parent d4002b8 commit 35563ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 4 additions & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,10 @@ func (c *Controller) initNodeChassis() error {
}
for _, node := range nodes {
if err := c.UpdateChassisTag(node); err != nil {
return err
if _, ok := err.(*ErrChassisNotFound); !ok {
klog.Error(err)
return err
}
}
}
return nil
Expand Down
17 changes: 13 additions & 4 deletions pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import (
"github.com/kubeovn/kube-ovn/pkg/util"
)

type ErrChassisNotFound struct {
Chassis string
Node string
}

func (e *ErrChassisNotFound) Error() string {
return fmt.Sprintf("chassis %s not found for node %s", e.Chassis, e.Node)
}

func (c *Controller) enqueueAddNode(obj interface{}) {
var key string
var err error
Expand Down Expand Up @@ -986,21 +995,21 @@ func (c *Controller) UpdateChassisTag(node *v1.Node) error {
}
chassis, err := c.OVNSbClient.GetChassis(annoChassisName, true)
if err != nil {
klog.Errorf("failed to get node %s chassis: %s, %v", node.Name, annoChassisName, err)
klog.Errorf("failed to get chassis %s for node %s: %v", annoChassisName, node.Name, err)
return err
}
if chassis == nil {
klog.Infof("chassis not registered for node %s, do chassis gc once", node.Name)
klog.Infof("chassis %q not registered for node %s, do chassis gc once", annoChassisName, node.Name)
// chassis name conflict, do GC
if err = c.gcChassis(); err != nil {
klog.Errorf("failed to gc chassis: %v", err)
return err
}
return fmt.Errorf("chassis not registered for node %s, will try again later", node.Name)
return &ErrChassisNotFound{Chassis: annoChassisName, Node: node.Name}
}

if chassis.ExternalIDs == nil || chassis.ExternalIDs["vendor"] != util.CniTypeName {
klog.Infof("init tag %s for node %s chassis", util.CniTypeName, node.Name)
klog.Infof("init tag %s for node %s chassis %s", util.CniTypeName, node.Name, chassis.Name)
if err = c.OVNSbClient.UpdateChassisTag(chassis.Name, node.Name); err != nil {
return fmt.Errorf("failed to init chassis tag, %v", err)
}
Expand Down

0 comments on commit 35563ed

Please sign in to comment.