Skip to content

Commit

Permalink
Merge pull request #208 from karelyatin/OSPRH-3929
Browse files Browse the repository at this point in the history
Fix debug mode ovncontroller/ovndbcluster pods
  • Loading branch information
openshift-merge-bot[bot] committed Jan 24, 2024
2 parents 7fd3da9 + b6b5f85 commit dce6a91
Show file tree
Hide file tree
Showing 7 changed files with 421 additions and 16 deletions.
26 changes: 14 additions & 12 deletions pkg/ovncontroller/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ limitations under the License.
package ovncontroller

import (
"github.com/openstack-k8s-operators/lib-common/modules/common"
"github.com/openstack-k8s-operators/lib-common/modules/common/env"
"github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"

Expand Down Expand Up @@ -62,6 +61,7 @@ func DaemonSet(
var ovsVswitchdArgs []string
var ovsVswitchdPreStopCmd []string

var ovnControllerCmd []string
var ovnControllerArgs []string
var ovnControllerPreStopCmd []string

Expand All @@ -70,22 +70,23 @@ func DaemonSet(
Command: noopCmd,
}
ovsDbCmd = []string{
common.DebugCommand,
"/bin/sleep",
}
ovsDbArgs = []string{}
ovsDbArgs = []string{"infinity"}
ovsDbPreStopCmd = noopCmd
ovsVswitchdLivenessProbe.Exec = &corev1.ExecAction{
Command: noopCmd,
}
ovsVswitchdCmd = []string{
common.DebugCommand,
"/bin/sleep",
}
ovsVswitchdArgs = noopCmd
ovsVswitchdArgs = []string{"infinity"}
ovsVswitchdPreStopCmd = noopCmd

ovnControllerArgs = []string{
common.DebugCommand,
ovnControllerCmd = []string{
"/bin/sleep",
}
ovnControllerArgs = []string{"infinity"}
ovnControllerPreStopCmd = noopCmd
} else {
ovsDbLivenessProbe.Exec = &corev1.ExecAction{
Expand Down Expand Up @@ -122,6 +123,9 @@ func DaemonSet(
"/usr/share/openvswitch/scripts/ovs-ctl", "stop", "--no-ovsdb-server", ";", "sleep", "2",
}

ovnControllerCmd = []string{
"/bin/bash", "-c",
}
ovnControllerArgs = []string{
"/usr/local/bin/container-scripts/net_setup.sh && ovn-controller --pidfile unix:/run/openvswitch/db.sock",
}
Expand Down Expand Up @@ -207,11 +211,9 @@ func DaemonSet(
// ovn-controller container
// NOTE(slaweq): for some reason, when ovn-controller is started without
// bash shell, it fails with error "unrecognized option --pidfile"
Name: "ovn-controller",
Command: []string{
"/bin/bash", "-c",
},
Args: ovnControllerArgs,
Name: "ovn-controller",
Command: ovnControllerCmd,
Args: ovnControllerArgs,
Lifecycle: &corev1.Lifecycle{
PreStop: &corev1.LifecycleHandler{
Exec: &corev1.ExecAction{
Expand Down
2 changes: 1 addition & 1 deletion pkg/ovndbcluster/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func StatefulSet(
cmd := []string{"/usr/bin/dumb-init"}
args := []string{"--single-child", "--", "/bin/bash", "-c"}
if instance.Spec.Debug.Service {
args = append(args, common.DebugCommand)
args = append(args, "/bin/sleep infinity")
livenessProbe.Exec = &corev1.ExecAction{
Command: noopCmd,
}
Expand Down
9 changes: 6 additions & 3 deletions tests/functional/ovncontroller_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,20 @@ var _ = Describe("OVNController controller", func() {
Expect(ds.Spec.Template.Spec.Containers).To(HaveLen(3))
Expect(ds.Spec.Template.Spec.Containers[0].LivenessProbe.Exec.Command).To(
Equal([]string{"/bin/true"}))
Expect(ds.Spec.Template.Spec.Containers[0].Command[0]).Should(ContainSubstring("sleep infinity"))
Expect(ds.Spec.Template.Spec.Containers[0].Command[0]).Should(ContainSubstring("/bin/sleep"))
Expect(ds.Spec.Template.Spec.Containers[0].Args[0]).Should(ContainSubstring("infinity"))
Expect(ds.Spec.Template.Spec.Containers[0].Lifecycle.PreStop.Exec.Command).To(
Equal([]string{"/bin/true"}))

Expect(ds.Spec.Template.Spec.Containers[1].LivenessProbe.Exec.Command).To(
Equal([]string{"/bin/true"}))
Expect(ds.Spec.Template.Spec.Containers[1].Command[0]).Should(ContainSubstring("sleep infinity"))
Expect(ds.Spec.Template.Spec.Containers[1].Command[0]).Should(ContainSubstring("/bin/sleep"))
Expect(ds.Spec.Template.Spec.Containers[1].Args[0]).Should(ContainSubstring("infinity"))
Expect(ds.Spec.Template.Spec.Containers[1].Lifecycle.PreStop.Exec.Command).To(
Equal([]string{"/bin/true"}))

Expect(ds.Spec.Template.Spec.Containers[2].Args[0]).Should(ContainSubstring("sleep infinity"))
Expect(ds.Spec.Template.Spec.Containers[2].Command[0]).Should(ContainSubstring("/bin/sleep"))
Expect(ds.Spec.Template.Spec.Containers[2].Args[0]).Should(ContainSubstring("infinity"))
Expect(ds.Spec.Template.Spec.Containers[2].Lifecycle.PreStop.Exec.Command).To(
Equal([]string{"/bin/true"}))
})
Expand Down
Loading

0 comments on commit dce6a91

Please sign in to comment.