Skip to content

Commit

Permalink
delete cm ovn-ic-config cause crash 1.11 (#3665)
Browse files Browse the repository at this point in the history
* 1. fix delete cm ovn-ic-config cause crash
2. add ovn-ic-controller.log to hostpath

Signed-off-by: Changlu Yi <[email protected]>

* fix disable ovn ic

Signed-off-by: Changlu Yi <[email protected]>

---------

Signed-off-by: Changlu Yi <[email protected]>
  • Loading branch information
changluyi authored Jan 24, 2024
1 parent c0fa3db commit 0e98a62
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 9 deletions.
10 changes: 10 additions & 0 deletions dist/images/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3677,6 +3677,11 @@ spec:
image: "$REGISTRY/kube-ovn:$VERSION"
imagePullPolicy: $IMAGE_PULL_POLICY
command: ["/kube-ovn/start-ic-controller.sh"]
args:
- --log_file=/var/log/kube-ovn/kube-ovn-ic-controller.log
- --log_file_max_size=0
- --logtostderr=false
- --alsologtostderr=true
securityContext:
capabilities:
add: ["SYS_NICE"]
Expand Down Expand Up @@ -3707,6 +3712,8 @@ spec:
name: localtime
- mountPath: /var/run/tls
name: kube-ovn-tls
- mountPath: /var/log/kube-ovn
name: kube-ovn-log
nodeSelector:
kubernetes.io/os: "linux"
kube-ovn/role: "master"
Expand All @@ -3723,6 +3730,9 @@ spec:
- name: localtime
hostPath:
path: /etc/localtime
- name: kube-ovn-log
hostPath:
path: /var/log/kube-ovn
- name: kube-ovn-tls
secret:
optional: true
Expand Down
10 changes: 10 additions & 0 deletions kubeovn-helm/templates/ic-controller-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ spec:
image: {{ .Values.global.registry.address }}/{{ .Values.global.images.kubeovn.repository }}:{{ .Values.global.images.kubeovn.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/kube-ovn/start-ic-controller.sh"]
args:
- --log_file=/var/log/kube-ovn/kube-ovn-ic-controller.log
- --log_file_max_size=0
- --logtostderr=false
- --alsologtostderr=true
securityContext:
capabilities:
add: ["SYS_NICE"]
Expand Down Expand Up @@ -76,6 +81,8 @@ spec:
name: localtime
- mountPath: /var/run/tls
name: kube-ovn-tls
- mountPath: /var/log/kube-ovn
name: kube-ovn-log
nodeSelector:
kubernetes.io/os: "linux"
kube-ovn/role: "master"
Expand All @@ -92,6 +99,9 @@ spec:
- name: localtime
hostPath:
path: /etc/localtime
- name: kube-ovn-log
hostPath:
path: /var/log/kube-ovn
- name: kube-ovn-tls
secret:
optional: true
Expand Down
31 changes: 22 additions & 9 deletions pkg/ovn_ic_controller/ovn_ic_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@ const (
icConfigChange
)

func (c *Controller) disableOVNIC(azName string) {
func (c *Controller) disableOVNIC(azName string) error {
if err := c.removeInterConnection(azName); err != nil {
klog.Errorf("failed to remove ovn-ic, %v", err)
return
return err
}
if err := c.delLearnedRoute(); err != nil {
klog.Errorf("failed to remove learned static routes, %v", err)
return
return err
}

if err := c.RemoveOldChassisInSbDB(azName); err != nil {
klog.Errorf("failed to remove remote chassis: %v", err)
return err
}
return nil
}

func (c *Controller) setAutoRoute(autoRoute bool) {
Expand Down Expand Up @@ -117,22 +119,29 @@ func (c *Controller) resyncInterConnection() {
return
}
klog.Info("start to remove ovn-ic")
azName := ""
icDBHost := ""
var azName, icDBHost, icSBPort, icNBPort string
if cm != nil {
azName = cm.Data["az-name"]
icDBHost = cm.Data["ic-db-host"]
icSBPort = cm.Data["ic-sb-port"]
icNBPort = cm.Data["ic-nb-port"]
} else if lastIcCm != nil {
azName = lastIcCm["az-name"]
icDBHost = lastIcCm["ic-db-host"]
icSBPort = lastIcCm["ic-sb-port"]
icNBPort = lastIcCm["ic-nb-port"]
}

if icDBHost != "" {
c.ovnLegacyClient.OvnICSbAddress = genHostAddress(icDBHost, cm.Data["ic-sb-port"])
c.ovnLegacyClient.OvnICNbAddress = genHostAddress(icDBHost, cm.Data["ic-nb-port"])
c.ovnLegacyClient.OvnICSbAddress = genHostAddress(icDBHost, icSBPort)
c.ovnLegacyClient.OvnICNbAddress = genHostAddress(icDBHost, icNBPort)
}

c.disableOVNIC(azName)
err := c.disableOVNIC(azName)
if err != nil {
klog.Errorf("Disable az %s OVN IC failed ", azName)
return
}
icEnabled = "false"
lastIcCm = nil

Expand Down Expand Up @@ -169,7 +178,11 @@ func (c *Controller) resyncInterConnection() {
case icConfigChange:
c.ovnLegacyClient.OvnICSbAddress = genHostAddress(lastIcCm["ic-db-host"], cm.Data["ic-sb-port"])
c.ovnLegacyClient.OvnICNbAddress = genHostAddress(lastIcCm["ic-db-host"], cm.Data["ic-nb-port"])
c.disableOVNIC(lastIcCm["az-name"])
err := c.disableOVNIC(lastIcCm["az-name"])
if err != nil {
klog.Errorf("Disable az %s OVN IC failed ", lastIcCm["az-name"])
return
}
klog.Info("start to reestablish ovn-ic")
if err := c.establishInterConnection(cm.Data); err != nil {
klog.Errorf("failed to reestablish ovn-ic, %v", err)
Expand Down

0 comments on commit 0e98a62

Please sign in to comment.