Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete cm ovn-ic-config cause crash 1.11 #3665

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是直接 disable 就可以了,不续要下面的配置

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

disableOVNIC需要这些配置去初始化c.ovnLegacyClient.OvnICSbAddress,c.ovnLegacyClient.OvnICNbAddress

是不是直接 disable 就可以了,不续要下面的配置

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