diff --git a/assets/router/deployment.yaml b/assets/router/deployment.yaml index f913a4b2a..98edce13c 100644 --- a/assets/router/deployment.yaml +++ b/assets/router/deployment.yaml @@ -8,7 +8,6 @@ spec: template: metadata: annotations: - "unsupported.do-not-use.openshift.io/override-liveness-grace-period-seconds": "10" target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}' spec: serviceAccountName: router @@ -34,6 +33,7 @@ spec: httpGet: path: /healthz port: 1936 + terminationGracePeriodSeconds: 10 readinessProbe: httpGet: path: /healthz/ready diff --git a/pkg/manifests/bindata.go b/pkg/manifests/bindata.go index 0d7f53933..58df07193 100644 --- a/pkg/manifests/bindata.go +++ b/pkg/manifests/bindata.go @@ -6,7 +6,7 @@ // assets/canary/service.yaml (331B) // assets/router/cluster-role-binding.yaml (329B) // assets/router/cluster-role.yaml (883B) -// assets/router/deployment.yaml (2.26kB) +// assets/router/deployment.yaml (2.215kB) // assets/router/metrics/cluster-role-binding.yaml (285B) // assets/router/metrics/cluster-role.yaml (259B) // assets/router/metrics/role-binding.yaml (297B) @@ -222,7 +222,7 @@ func assetsRouterClusterRoleYaml() (*asset, error) { return a, nil } -var _assetsRouterDeploymentYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x55\x4f\x6f\xe2\xc8\x13\xbd\xf3\x29\x4a\xe4\x30\x27\x63\xc8\x6f\x7e\x59\xad\x6f\x08\x9c\x5d\xa4\x21\x41\x81\x99\x2b\xaa\xb4\x0b\xd3\x4a\xbb\xbb\xb7\xba\x9a\x2c\xb3\xda\xef\xbe\xb2\x4d\x12\x9b\x64\x32\x91\x56\xcb\xa9\xe9\xaa\x7e\xaf\xfe\xbc\x2a\x5f\xc0\x9c\xbc\x71\xc7\x8a\xac\xc0\xa3\x96\x3d\x14\xb4\xc3\x68\x04\x0e\x68\x22\x85\xc1\x05\x2c\x6c\xc9\x14\x02\xcc\x9c\x15\x76\xc6\x10\x43\xf0\xa4\xf4\x4e\xab\x93\x13\x20\x13\xa0\xf7\x46\x53\x01\x28\xc0\xd1\x8a\xae\x68\x34\x78\xd0\xb6\xc8\x3a\x0c\x03\xf4\xfa\x1b\x71\xd0\xce\x66\xf5\x83\x90\x1e\x26\x83\x0b\xb0\x58\x11\xa0\x2d\x9a\x43\xf0\xa8\xa8\x41\x0c\x24\x3d\xb4\x9a\x35\x1b\x00\x78\x76\x4d\x44\x73\xc2\xc2\x68\x4b\x6b\x52\xce\x16\x21\x83\xab\xf1\x78\x00\x20\x54\x79\x83\x42\xb5\x2b\x40\x45\x82\x05\x0a\xb6\xff\x00\xd0\x5a\x27\x28\xda\xd9\xf0\x74\x05\x30\x8c\x36\x44\xef\x1d\x0b\x15\xa3\xc2\x25\xd6\x49\x12\x03\x8d\x9c\x27\x1b\xf6\x7a\x27\x23\xed\x52\x77\x20\x66\x5d\x50\x62\xf4\x81\x2c\x85\x90\x94\x8c\x8a\x12\x4f\xac\x5d\x91\x84\x36\x8a\x61\x06\xc3\xc9\x78\xf8\x0c\x2d\xc8\x25\xc9\xe8\xd1\xf1\x83\x71\x58\xf4\x21\x2b\xb4\x58\x52\x5d\x99\x0c\x3e\xfd\x35\xa4\xdd\x8e\x94\xd4\x08\x2b\xa6\x1d\x31\x53\x31\x8f\xac\x6d\xb9\x56\x7b\x2a\xa2\xd1\xb6\x1c\xfe\xfd\xa9\x81\x7e\xaa\x45\x73\x26\x3e\x68\x45\x53\xa5\x5c\xb4\x72\x83\x15\x65\xc0\x2e\x0a\xf1\xc9\xe1\x02\xac\x2b\x68\x4d\x86\x94\x38\x06\x1d\x5e\x95\xb6\xf5\xf3\xac\x1d\x6b\x39\xce\x0c\x86\xd0\xe2\x84\x63\x10\xaa\x12\x65\x62\x10\xe2\x44\xb1\x16\xad\xd0\x9c\x1e\x28\x67\x05\xb5\x25\xee\xd4\x32\x69\xba\x78\x16\x41\x1b\x85\xae\xb0\xa4\x1f\xd3\xd7\xbf\xc6\x65\x15\x8d\x59\x39\xa3\xd5\x31\x83\xc5\xee\xc6\xc9\x8a\x29\xd4\xf2\x79\xf1\x0b\xa4\x62\x13\xaa\xb3\x42\x7f\x4a\xd6\x31\xd5\x4c\x6b\x22\xd8\x8b\xf8\x90\xa5\xe9\x7d\x2c\xbf\x6b\x63\x70\xc4\x54\xec\x51\x46\xca\x55\xe9\xe5\x78\xfc\xcb\xe5\xe7\xab\xde\x2b\x34\xc6\x3d\xae\x58\x1f\xb4\xa1\x92\xf2\xa0\xd0\x34\x3a\xc9\x40\x38\x52\xc7\x55\x88\x2b\x6d\x1b\xdb\x92\x42\xa8\x03\x3e\x05\x7b\x8d\xc6\xdc\xa3\x7a\xd8\xb8\x2f\xae\x0c\xb7\x36\x67\x76\xfd\x12\x2c\x89\xcb\xb3\x21\x79\x31\x93\x3d\x74\x13\x79\xaa\xe4\xdd\xed\xd7\x4d\x7e\xb7\x5d\xe7\x77\xdf\x16\xb3\x7c\x7b\x33\x5d\xe6\xeb\xd5\x74\x96\xf7\xa2\x6f\x26\x31\x83\x67\x79\x25\xba\x1d\xdb\x37\xf0\xe6\xf9\xf5\xf4\xeb\x97\xcd\x76\x96\xdf\x6d\x16\xd7\x8b\xd9\x74\x93\x6f\xe7\x8b\xbb\xb7\xe0\x52\x12\x95\xfa\x07\x9d\x8a\x09\xa9\x67\x7d\x40\xa1\x77\x10\xe7\xf9\x7a\xb3\xb8\x99\x6e\x16\xb7\x37\xdb\xd9\x74\xbb\x9a\x6e\x7e\x7f\x13\xf5\x80\x9c\x72\xb4\xa9\x72\x76\xa7\xcb\x0a\x7d\x48\x4f\x22\x4e\x14\x76\x8e\x23\xc5\xdd\xa6\x3f\x0d\xde\x8a\xdd\x3d\xf5\x5b\x5e\x37\xfb\x37\x3a\xd3\x01\x80\x47\xd9\x67\x90\xee\x09\x8d\xec\xbf\x9f\x1b\x1d\x4b\x06\x93\x5f\xff\xd7\xd5\x01\x13\x16\xfa\xdf\x90\xa4\x35\xc2\xf1\x23\x54\x41\x90\x25\xfa\x37\x88\x76\xa8\x4d\x64\xda\xec\x99\xc2\xde\x99\x22\x83\xc9\xe5\xf8\xbf\x0c\x05\xa0\xdd\x62\xcf\xab\x74\xd2\x2b\x49\x70\x91\x15\x85\x3e\x1b\xd3\x1f\x91\x82\x84\xf3\x18\x94\x8f\x19\x4c\xc6\xe3\xea\xec\xbe\xa2\xca\xf1\x31\x83\xcb\xff\x5f\x2d\x75\xc7\x76\x70\x26\x56\xb4\xac\x77\x57\xe8\xcb\xbf\xaa\xef\x56\x6d\x4a\xef\x0b\x11\x4e\x42\x3c\x7d\xbc\x12\x45\x2c\xf5\x07\xea\xdc\xab\x2e\xc8\xad\x35\xc7\x57\x33\xdd\x27\x7b\x57\x9f\x6f\xd0\xbe\x18\x93\xfb\x68\x0b\xf3\x01\xd2\x36\xeb\xe7\x84\x93\x0f\x24\x10\x48\x71\xbf\xe5\x27\xef\xa5\x2b\x28\x83\xcf\x3d\x89\xd4\x3b\xb0\x76\xaf\xd7\x78\x7f\xe5\x26\xdd\xb5\x93\xfc\x34\x83\xb6\x06\x4b\xf4\x5d\x62\x2d\x54\x9d\x35\xeb\x81\x8e\x5d\x98\xb3\xd1\x7d\x92\xe6\x0f\x1d\x7e\x5e\x48\xe7\xeb\x8d\x8b\x26\x83\x1d\x9a\xf0\x62\x79\x55\x84\x7f\x02\x00\x00\xff\xff\x49\x0a\x8b\xa5\xd4\x08\x00\x00") +var _assetsRouterDeploymentYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x55\x51\x6f\xe3\x36\x0c\x7e\xcf\xaf\x20\xda\x87\x7b\x4a\x9c\x76\xb7\x1b\xe6\xb7\x20\x71\x6f\x01\x2e\x6d\xd0\xe4\xee\x35\x60\x65\xda\x16\x2a\x4b\x1a\x45\xa5\xcb\x0d\xfb\xef\x83\x9d\xb4\xb5\xdd\x5e\xaf\xc0\xb0\x3c\x29\xe2\x27\xf2\x23\xf9\x91\x3e\x87\x05\x79\xe3\x0e\x35\x59\x81\x07\x2d\x15\xe4\x54\x60\x34\x02\x7b\x34\x91\xc2\xe8\x1c\x96\xb6\x64\x0a\x01\xe6\xce\x0a\x3b\x63\x88\x21\x78\x52\xba\xd0\xea\x04\x02\x64\x02\xf4\xde\x68\xca\x01\x05\x38\x5a\xd1\x35\x4d\x46\xf7\xda\xe6\x69\x27\xc2\x08\xbd\xfe\x46\x1c\xb4\xb3\x69\xf3\x20\x24\xfb\x8b\xd1\x39\x58\xac\x09\xd0\xe6\xed\x21\x78\x54\xd4\x7a\x0c\x24\x3d\x6f\x4d\xd4\x74\x04\xe0\xd9\xb5\x8c\x16\x84\xb9\xd1\x96\x36\xa4\x9c\xcd\x43\x0a\x9f\xa6\xd3\x11\x80\x50\xed\x0d\x0a\x35\x50\x80\x9a\x04\x73\x14\x3c\xfe\x03\x40\x6b\x9d\xa0\x68\x67\xc3\xe3\x15\x80\x20\x97\x24\x93\x07\xc7\xf7\xc6\x61\x3e\x71\x9e\x6c\xa8\x74\x21\x13\xed\x92\x1a\x2d\x96\xd4\xd0\x4f\xe1\xc3\xdf\x67\x54\x14\xa4\xe4\x2c\x85\xb3\x35\x53\x41\xcc\x94\x2f\x22\x6b\x5b\x6e\x54\x45\x79\x34\xda\x96\x67\xff\x7c\x68\x5d\x3f\x12\x6e\xcf\xc4\x7b\xad\x68\xa6\x94\x8b\x56\xae\xb1\xa6\x14\xd8\x45\x21\x3e\x01\xce\xc1\xba\x9c\x36\x64\x48\x89\x63\xd0\xe1\x45\xfe\x47\x9c\x67\xed\x58\xcb\x61\x6e\x30\x84\xa3\x9f\x70\x08\x42\xf5\x58\x99\x18\x84\x78\xac\x58\x8b\x56\x68\x4e\x0f\x94\xb3\x82\xda\x12\x77\x12\x1e\xb7\xa5\x1e\x30\x38\xb2\xd0\x35\x96\xf4\xe3\xf0\xcd\xaf\x85\xac\xa3\x31\x6b\x67\xb4\x3a\xa4\xb0\x2c\xae\x9d\xac\x99\x42\xd3\xe3\x67\x5c\x20\x15\x5b\xaa\xce\x0a\xfd\x25\x69\xc7\xd4\x44\xda\x10\x41\x25\xe2\x43\x9a\x24\x77\xb1\xfc\xae\x8d\xc1\x09\x53\x5e\xa1\x4c\x94\xab\x93\xcb\xe9\xf4\xb7\xcb\x8f\x9f\x7a\xaf\xd0\x18\xf7\xb0\x66\xbd\xd7\x86\x4a\xca\x82\x42\xd3\x36\x33\x05\xe1\x48\x1d\xa8\x10\xd7\xda\xb6\xb6\x15\x85\xd0\x10\x3e\x91\xbd\x42\x63\xee\x50\xdd\x6f\xdd\x17\x57\x86\x1b\x9b\x31\xbb\x7e\x09\x56\xc4\xe5\x40\xc9\xcf\x66\xb2\xfb\x6e\x22\x8f\x95\xbc\xbd\xf9\xba\xcd\x6e\x77\x9b\xec\xf6\xdb\x72\x9e\xed\xae\x67\xab\x6c\xb3\x9e\xcd\xb3\x1e\xfb\x76\x5c\x52\x78\x92\xd7\x58\x1f\x67\xeb\x15\x7f\x8b\xec\x6a\xf6\xf5\xcb\x76\x37\xcf\x6e\xb7\xcb\xab\xe5\x7c\xb6\xcd\x76\x8b\xe5\xed\x6b\xee\x12\x12\x95\xf8\x7b\x9d\x88\x09\x89\x67\xbd\x47\xa1\x37\x3c\x2e\xb2\xcd\x76\x79\x3d\xdb\x2e\x6f\xae\x77\xf3\xd9\x6e\x3d\xdb\xfe\xf1\xaa\xd7\x3d\x72\xc2\xd1\x26\xca\xd9\x42\x97\x35\xfa\x90\x9c\x44\x3c\x56\xd8\x39\x4e\x14\x77\x9b\x6e\xf4\x9e\x2c\x85\xb0\x66\x77\x47\xfd\x96\x37\xcd\xfe\x4c\x03\x1d\x00\x78\x94\x2a\x85\xa4\x22\x34\x52\x7d\x1f\x1a\x1d\x4b\x0a\x17\xbf\xff\xd2\xd7\x41\xa7\xbd\x9f\x19\x15\xad\x89\xb5\xcb\x9f\x36\xc1\xc5\xb4\x83\x66\xc2\x5c\xff\x17\x4a\x49\xe3\xe1\xf0\x1e\x62\x41\x90\x25\xfa\x57\x02\x15\xa8\x4d\x64\xda\x56\x4c\xa1\x72\x26\x4f\xe1\xe2\x72\xfa\x7f\x52\x01\xf0\x83\x9a\xf4\x4a\x12\x5c\x64\x45\xa1\x1f\x8d\xe9\xcf\x48\x41\xc2\x90\x83\xf2\xb1\xa9\xe9\xb4\x1e\xdc\xd7\x54\x3b\x3e\xa4\x70\xf9\xeb\xa7\x95\xee\xd8\xf6\xce\xc4\x9a\x56\xcd\xa6\x0b\xfd\x61\xa9\x9b\xbb\xf5\x31\xa5\xb7\x65\x0b\x27\xd9\x9e\xbe\x47\x63\x45\x2c\xcd\x37\x67\x88\x6a\x0a\x72\x63\xcd\xe1\xc5\x06\xe8\x07\x7b\x53\xcd\xaf\x84\x7d\x36\x8e\xef\xa2\xcd\xcd\x3b\x82\x1e\xb3\x7e\x4a\x78\xfc\x8e\x04\x02\x29\xee\xb7\xfc\x84\x5e\xb9\x9c\x52\xf8\xd8\x93\x48\xb3\x31\x1b\x78\xb3\xf4\xfb\x0b\x7a\xdc\x5d\x52\xe3\x9f\x66\x70\xac\xc1\x0a\x7d\x37\xb0\x16\xaa\x07\xcd\xba\xa7\x43\xd7\xcd\x60\xd0\x1f\xa5\xf9\x43\xc0\xcf\x0b\xe9\x7c\x33\xc0\x68\x52\x28\xd0\x84\x67\xcb\x8b\x22\xfc\x1b\x00\x00\xff\xff\x43\xe3\xb8\x07\xa7\x08\x00\x00") func assetsRouterDeploymentYamlBytes() ([]byte, error) { return bindataRead( @@ -237,8 +237,8 @@ func assetsRouterDeploymentYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "assets/router/deployment.yaml", size: 2260, mode: os.FileMode(420), modTime: time.Unix(1, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x2a, 0xd4, 0x77, 0x69, 0xab, 0xa7, 0xb4, 0xba, 0xb, 0xc6, 0xa6, 0x9, 0x6, 0x83, 0xe2, 0x16, 0x9e, 0x83, 0xa8, 0xc2, 0x5a, 0x50, 0xf5, 0x50, 0x56, 0x27, 0x27, 0xbb, 0x4, 0xc0, 0xc8, 0x94}} + info := bindataFileInfo{name: "assets/router/deployment.yaml", size: 2215, mode: os.FileMode(420), modTime: time.Unix(1, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x94, 0xc4, 0x1e, 0x49, 0xc9, 0xd2, 0x27, 0x4b, 0x92, 0xf8, 0xb3, 0xc1, 0xfd, 0x5d, 0xb3, 0x59, 0x4c, 0x16, 0xbc, 0x81, 0xa7, 0x3, 0x62, 0xd4, 0xa3, 0xb8, 0x96, 0xb5, 0x97, 0xcd, 0xa2, 0xe0}} return a, nil } diff --git a/pkg/operator/controller/ingress/deployment.go b/pkg/operator/controller/ingress/deployment.go index 9ac79367f..a7b7e2284 100644 --- a/pkg/operator/controller/ingress/deployment.go +++ b/pkg/operator/controller/ingress/deployment.go @@ -1562,11 +1562,15 @@ func deploymentConfigChanged(current, expected *appsv1.Deployment) (bool, *appsv annotations := []string{LivenessGracePeriodSecondsAnnotation, WorkloadPartitioningManagement} for _, key := range annotations { - if val, ok := expected.Spec.Template.Annotations[key]; ok && len(val) > 0 { + currentVal, have := current.Spec.Template.Annotations[key] + expectedVal, want := expected.Spec.Template.Annotations[key] + if want && (!have || currentVal != expectedVal) { if updated.Spec.Template.Annotations == nil { updated.Spec.Template.Annotations = make(map[string]string) } - updated.Spec.Template.Annotations[key] = val + updated.Spec.Template.Annotations[key] = expectedVal + } else if have && !want { + delete(updated.Spec.Template.Annotations, key) } } @@ -1614,6 +1618,9 @@ func copyProbe(a, b *corev1.Probe) { b.ProbeHandler.HTTPGet.Scheme = a.ProbeHandler.HTTPGet.Scheme } } + if a.TerminationGracePeriodSeconds != nil { + b.TerminationGracePeriodSeconds = a.TerminationGracePeriodSeconds + } // Users are permitted to modify the timeout, so *don't* copy it. diff --git a/pkg/operator/controller/ingress/deployment_test.go b/pkg/operator/controller/ingress/deployment_test.go index 789420d87..4f13cdd64 100644 --- a/pkg/operator/controller/ingress/deployment_test.go +++ b/pkg/operator/controller/ingress/deployment_test.go @@ -362,14 +362,12 @@ func TestDesiredRouterDeploymentSpecTemplate(t *testing.T) { } } - if expected, got := 2, len(deployment.Spec.Template.Annotations); expected != got { + if expected, got := 1, len(deployment.Spec.Template.Annotations); expected != got { t.Errorf("expected len(annotations)=%v, got %v", expected, got) } - if val, ok := deployment.Spec.Template.Annotations[LivenessGracePeriodSecondsAnnotation]; !ok { - t.Errorf("missing annotation %q", LivenessGracePeriodSecondsAnnotation) - } else if expected := "10"; expected != val { - t.Errorf("expected annotation %q to be %q, got %q", LivenessGracePeriodSecondsAnnotation, expected, val) + if val, ok := deployment.Spec.Template.Annotations[LivenessGracePeriodSecondsAnnotation]; ok { + t.Errorf("expected annotation %[1]q not to be set, got %[1]s=%[2]s", LivenessGracePeriodSecondsAnnotation, val) } if val, ok := deployment.Spec.Template.Annotations[WorkloadPartitioningManagement]; !ok { @@ -389,6 +387,9 @@ func TestDesiredRouterDeploymentSpecTemplate(t *testing.T) { if len(deployment.Spec.Template.Spec.Containers[0].LivenessProbe.ProbeHandler.HTTPGet.Host) != 0 { t.Errorf("expected empty liveness probe host, got %q", deployment.Spec.Template.Spec.Containers[0].LivenessProbe.ProbeHandler.HTTPGet.Host) } + if deployment.Spec.Template.Spec.Containers[0].LivenessProbe.TerminationGracePeriodSeconds == nil { + t.Error("expected liveness probe's termination grace period to be set") + } if len(deployment.Spec.Template.Spec.Containers[0].ReadinessProbe.ProbeHandler.HTTPGet.Host) != 0 { t.Errorf("expected empty readiness probe host, got %q", deployment.Spec.Template.Spec.Containers[0].ReadinessProbe.ProbeHandler.HTTPGet.Host) } @@ -1342,6 +1343,14 @@ func TestDeploymentConfigChanged(t *testing.T) { }, expect: true, }, + { + description: "if the liveness probe's terminationGracePeriodSeconds is changed", + mutate: func(deployment *appsv1.Deployment) { + v := int64(123) + deployment.Spec.Template.Spec.Containers[0].LivenessProbe.TerminationGracePeriodSeconds = &v + }, + expect: true, + }, { description: "if readiness probe values are set to non-default values", mutate: func(deployment *appsv1.Deployment) { @@ -1453,6 +1462,15 @@ func TestDeploymentConfigChanged(t *testing.T) { }, expect: true, }, + { + // This test case can be removed after OpenShift 4.13. + // See . + description: "if the unsupported.do-not-use.openshift.io/override-liveness-grace-period-seconds annotation is removed", + mutate: func(deployment *appsv1.Deployment) { + delete(deployment.Spec.Template.Annotations, LivenessGracePeriodSecondsAnnotation) + }, + expect: true, + }, } for _, tc := range testCases { @@ -1479,7 +1497,8 @@ func TestDeploymentConfigChanged(t *testing.T) { controller.ControllerDeploymentHashLabel: "1", }, Annotations: map[string]string{ - WorkloadPartitioningManagement: "{\"effect\": \"PreferredDuringScheduling\"}", + LivenessGracePeriodSecondsAnnotation: "10", + WorkloadPartitioningManagement: "{\"effect\": \"PreferredDuringScheduling\"}", }, }, Spec: corev1.PodSpec{