Skip to content

Commit

Permalink
Merge pull request #104 from sunya-ch/v1.0.4
Browse files Browse the repository at this point in the history
Fix HostInterface Reconcile, CNI Del/Check, and DaemonSet priorityclass
  • Loading branch information
sunya-ch authored May 11, 2023
2 parents ded0965 + 0d52320 commit 18ff99b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
29 changes: 16 additions & 13 deletions cni/plugins/main/multi-nic/multi-nic.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ func cmdDel(args *skel.CmdArgs) error {

n, deviceType, err := loadConf(args)
if err != nil {
return fmt.Errorf("fail to load conf: %v", err)
utils.Logger.Debug(fmt.Sprintf("fail to load conf: %v", err))
return nil
}
utils.Logger.Debug(fmt.Sprintf("Received an DEL request for: conf=%v", n))
// On chained invocation, IPAM block can be empty
Expand All @@ -199,12 +200,13 @@ func cmdDel(args *skel.CmdArgs) error {
// parse previous result
if n.NetConf.RawPrevResult != nil {
if err = version.ParsePrevResult(&n.NetConf); err != nil {
return fmt.Errorf("could not parse prevResult: %v", err)
utils.Logger.Debug(fmt.Sprintf("could not parse prevResult: %v", err))
return nil
}

result, err = current.NewResultFromResult(n.NetConf.PrevResult)
if err != nil {
return fmt.Errorf("could not convert result to current version: %v", err)
utils.Logger.Debug(fmt.Sprintf("could not convert result to current version: %v", err))
return nil
}
} else {
result = &current.Result{CNIVersion: current.ImplementedSpecVersion}
Expand All @@ -222,7 +224,7 @@ func cmdDel(args *skel.CmdArgs) error {
}
if err != nil {
utils.Logger.Debug(fmt.Sprintf("Fail loading %v: %v", string(args.StdinData), err))
return err
return nil
}
if len(confBytesArray) == 0 {
utils.Logger.Debug(fmt.Sprintf("zero config on cmdDel: %v (%d)", string(args.StdinData), len(n.Masters)))
Expand All @@ -238,7 +240,6 @@ func cmdDel(args *skel.CmdArgs) error {
return nil
}
}

return nil
}

Expand All @@ -249,19 +250,21 @@ func cmdCheck(args *skel.CmdArgs) error {

n, deviceType, err := loadConf(args)
if err != nil {
return fmt.Errorf("fail to load conf")
utils.Logger.Debug(fmt.Sprintf("fail to load conf: %v", err))
return nil
}

var result *current.Result
// parse previous result
if n.NetConf.RawPrevResult != nil {
if err = version.ParsePrevResult(&n.NetConf); err != nil {
return fmt.Errorf("could not parse prevResult: %v", err)
utils.Logger.Debug(fmt.Sprintf("could not parse prevResult: %v", err))
return nil
}

result, err = current.NewResultFromResult(n.NetConf.PrevResult)
if err != nil {
return fmt.Errorf("could not convert result to current version: %v", err)
utils.Logger.Debug(fmt.Sprintf("could not convert result to current version: %v", err))
return nil
}
} else {
result = &current.Result{CNIVersion: current.ImplementedSpecVersion}
Expand All @@ -279,7 +282,7 @@ func cmdCheck(args *skel.CmdArgs) error {
}
if err != nil {
utils.Logger.Debug(fmt.Sprintf("Fail loading %v: %v", string(args.StdinData), err))
return err
return nil
}
if len(confBytesArray) == 0 {
utils.Logger.Debug(fmt.Sprintf("zero config on cmdCheck: %v (%d)", string(args.StdinData), len(n.Masters)))
Expand All @@ -291,10 +294,10 @@ func cmdCheck(args *skel.CmdArgs) error {
utils.Logger.Debug(fmt.Sprintf("Exec %s %s: %s", command, ifName, string(confBytes)))
_, err := execPlugin(deviceType, command, confBytes, args, ifName, false)
if err != nil {
return err
utils.Logger.Debug(fmt.Sprintf("Fail execPlugin %v: %v", string(confBytes), err))
return nil
}
}

return nil
}

Expand Down
1 change: 1 addition & 0 deletions controllers/config_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ func (r *ConfigReconciler) newCNIDaemonSet(client *kubernetes.Clientset, name st
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: labels},
Spec: corev1.PodSpec{
PriorityClassName: "system-cluster-critical",
HostNetwork: true,
ServiceAccountName: vars.ServiceAccountName,
NodeSelector: daemonSpec.NodeSelector,
Expand Down
3 changes: 2 additions & 1 deletion controllers/hostinterface_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ func (r *HostInterfaceReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}

if !ConfigReady || !r.DaemonWatcher.IsDaemonSetReady() {
return ctrl.Result{RequeueAfter: vars.NormalReconcileTime}, nil
// only hostinterface must be reconciled urgently after config is ready because it's tightly coupling with daemon
return ctrl.Result{RequeueAfter: vars.UrgentReconcileTime}, nil
}

vars.HifLog.V(7).Info(fmt.Sprintf("HostInterface reconciled: %s", instance.ObjectMeta.Name))
Expand Down

0 comments on commit 18ff99b

Please sign in to comment.