Skip to content

Commit

Permalink
replace sbctl operate chassis
Browse files Browse the repository at this point in the history
  • Loading branch information
bobz965 committed Aug 7, 2023
1 parent 4571248 commit ad1dfb0
Show file tree
Hide file tree
Showing 12 changed files with 476 additions and 214 deletions.
243 changes: 243 additions & 0 deletions mocks/pkg/ovs/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions pkg/controller/external-gw.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,13 @@ func (c *Controller) getGatewayChassis(config map[string]string) ([]string, erro
klog.Errorf("patch external gw node %s failed %v", gw, err)
return chassises, err
}
chassisID, err := c.ovnLegacyClient.GetChassis(gw)
chassis, err := c.ovnSbClient.GetChassisByNode(gw)
if err != nil {
klog.Errorf("failed to get external gw %s chassisID, %v", gw, err)
klog.Errorf("failed to get chassis by node name: %s, %v", gw, err)
return chassises, err
}
if chassisID == "" {
return chassises, fmt.Errorf("no chassisID for external gw %s", gw)
}
chassises = append(chassises, chassisID)

chassises = append(chassises, chassis.UUID)
}
if len(chassises) == 0 {
klog.Error("no available external gw")
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ func (c *Controller) gcStaticRoute() error {

func (c *Controller) gcChassis() error {
klog.Infof("start to gc chassis")
chassises, err := c.ovnLegacyClient.GetAllChassis()
chassises, err := c.ovnSbClient.GetKubeOvnChassisses()
if err != nil {
klog.Errorf("failed to get all chassis, %v", err)
}
Expand All @@ -676,16 +676,16 @@ func (c *Controller) gcChassis() error {
klog.Errorf("failed to list nodes, %v", err)
return err
}
for _, chassis := range chassises {
for _, chassis := range *chassises {
matched := true
for _, node := range nodes {
if chassis == node.Annotations[util.ChassisAnnotation] {
if chassis.Name == node.Annotations[util.ChassisAnnotation] {
matched = false
break
}
}
if matched {
if err := c.ovnLegacyClient.DeleteChassisByName(chassis); err != nil {
if err := c.ovnSbClient.DeleteChassis(chassis.Name); err != nil {
klog.Errorf("failed to delete chassis %s %v", chassis, err)
return err
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,11 +855,15 @@ func (c *Controller) initNodeChassis() error {
klog.Errorf("failed to list nodes: %v", err)
return err
}
chssisNodes, err := c.ovnLegacyClient.GetAllChassisMap()
chssises, err := c.ovnSbClient.GetKubeOvnChassisses()
if err != nil {
klog.Errorf("failed to get chassis nodes: %v", err)
return err
}
chssisNodes := make(map[string]string, len(*chssises))
for _, chssis := range *chssises {
chssisNodes[chssis.Name] = chssis.Hostname
}
for _, node := range nodes {
chassisName := node.Annotations[util.ChassisAnnotation]
if chassisName != "" {
Expand All @@ -868,7 +872,7 @@ func (c *Controller) initNodeChassis() error {
continue
} else {
klog.Infof("node %s sbdb chassis %s host name %s", node.Name, chassisName, hostname)
err = c.ovnLegacyClient.InitChassisNodeTag(chassisName, node.Name)
err = c.ovnSbClient.InitChassisNodeTag(chassisName, node.Name)
if err != nil {
klog.Errorf("failed to set chassis nodeTag: %v", err)
return err
Expand Down
Loading

0 comments on commit ad1dfb0

Please sign in to comment.