Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle missing pids during sidecar teardown
Make the sidecar container script tolerate missing pids during cleanup
to prevent spurious errors on shutdown.
  • Loading branch information
ironcladlou committed Dec 4, 2019
1 parent 6e9e960 commit 52362da
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assets/dns/daemonset.yaml
Expand Up @@ -75,7 +75,7 @@ spec:
#!/bin/bash
set -uo pipefail
trap 'kill $(jobs -p); exit 0' TERM
trap 'jobs -p | xargs kill || true; wait; exit 0' TERM
OPENSHIFT_MARKER="openshift-generated-node-resolver"
HOSTS_FILE="/etc/hosts"
Expand Down
8 changes: 4 additions & 4 deletions pkg/manifests/bindata.go

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

15 changes: 15 additions & 0 deletions pkg/operator/controller/controller_dns_daemonset.go
Expand Up @@ -194,6 +194,21 @@ func daemonsetConfigChanged(current, expected *appsv1.DaemonSet) (bool, *appsv1.
changed = true
}

// Detect changes to container commands
if len(current.Spec.Template.Spec.Containers) != len(expected.Spec.Template.Spec.Containers) {
updated.Spec.Template.Spec.Containers = expected.Spec.Template.Spec.Containers
changed = true
} else {
for i, a := range current.Spec.Template.Spec.Containers {
b := expected.Spec.Template.Spec.Containers[i]
if !cmp.Equal(a.Command, b.Command, cmpopts.EquateEmpty()) {
updated.Spec.Template.Spec.Containers = expected.Spec.Template.Spec.Containers
changed = true
break
}
}
}

if !changed {
return false, nil
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/operator/controller/controller_dns_daemonset_test.go
Expand Up @@ -104,6 +104,20 @@ func TestDaemonsetConfigChanged(t *testing.T) {
},
expect: true,
},
{
description: "if a container command length changed",
mutate: func(daemonset *appsv1.DaemonSet) {
daemonset.Spec.Template.Spec.Containers[1].Command = append(daemonset.Spec.Template.Spec.Containers[1].Command, "--foo")
},
expect: true,
},
{
description: "if a container command contents changed",
mutate: func(daemonset *appsv1.DaemonSet) {
daemonset.Spec.Template.Spec.Containers[0].Command[1] = "c"
},
expect: true,
},
}

for _, tc := range testCases {
Expand All @@ -120,10 +134,18 @@ func TestDaemonsetConfigChanged(t *testing.T) {
{
Name: "dns",
Image: "openshift/origin-coredns:v4.0",
Command: []string{
"a",
"b",
},
},
{
Name: "dns-node-resolver",
Image: "openshift/origin-cli:v4.0",
Command: []string{
"c",
"d",
},
},
},
NodeSelector: map[string]string{
Expand Down

0 comments on commit 52362da

Please sign in to comment.