Skip to content

Commit 9290758

Browse files
authored
diff SecurityContext of containers (#1255)
* diff SecurityContext of containers * change log messages to use "does not" vs "doesn't"
1 parent 83fbcca commit 9290758

File tree

7 files changed

+42
-39
lines changed

7 files changed

+42
-39
lines changed

kubectl-pg/cmd/util.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,20 @@ package cmd
2525
import (
2626
"flag"
2727
"fmt"
28+
"log"
29+
"os"
30+
"os/exec"
31+
"path/filepath"
32+
"strconv"
33+
"strings"
34+
2835
PostgresqlLister "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/typed/acid.zalan.do/v1"
2936
v1 "k8s.io/api/apps/v1"
3037
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3138
"k8s.io/client-go/kubernetes"
3239
restclient "k8s.io/client-go/rest"
3340
"k8s.io/client-go/tools/clientcmd"
3441
"k8s.io/client-go/util/homedir"
35-
"log"
36-
"os"
37-
"os/exec"
38-
"path/filepath"
39-
"strconv"
40-
"strings"
4142
)
4243

4344
const (
@@ -88,7 +89,7 @@ func confirmAction(clusterName string, namespace string) {
8889
}
8990
clusterDetails := strings.Split(confirmClusterDetails, "/")
9091
if clusterDetails[0] != namespace || clusterDetails[1] != clusterName {
91-
fmt.Printf("cluster name or namespace doesn't match. Please re-enter %s/%s\nHint: Press (ctrl+c) to exit\n", namespace, clusterName)
92+
fmt.Printf("cluster name or namespace does not match. Please re-enter %s/%s\nHint: Press (ctrl+c) to exit\n", namespace, clusterName)
9293
} else {
9394
return
9495
}

pkg/cluster/cluster.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (c *Cluster) Create() error {
248248
}
249249
if role == Master {
250250
// replica endpoint will be created by the replica service. Master endpoint needs to be created by us,
251-
// since the corresponding master service doesn't define any selectors.
251+
// since the corresponding master service does not define any selectors.
252252
ep, err = c.createEndpoint(role)
253253
if err != nil {
254254
return fmt.Errorf("could not create %s endpoint: %v", role, err)
@@ -412,7 +412,7 @@ func (c *Cluster) compareStatefulSetWith(statefulSet *appsv1.StatefulSet) *compa
412412
match = false
413413
needsReplace = true
414414
needsRollUpdate = true
415-
reasons = append(reasons, "new statefulset's pod template metadata annotations doesn't match the current one")
415+
reasons = append(reasons, "new statefulset's pod template metadata annotations does not match the current one")
416416
}
417417
if !reflect.DeepEqual(c.Statefulset.Spec.Template.Spec.SecurityContext, statefulSet.Spec.Template.Spec.SecurityContext) {
418418
match = false
@@ -488,20 +488,22 @@ func (c *Cluster) compareContainers(description string, setA, setB []v1.Containe
488488
}
489489

490490
checks := []containerCheck{
491-
newCheck("new statefulset %s's %s (index %d) name doesn't match the current one",
491+
newCheck("new statefulset %s's %s (index %d) name does not match the current one",
492492
func(a, b v1.Container) bool { return a.Name != b.Name }),
493-
newCheck("new statefulset %s's %s (index %d) ports don't match the current one",
493+
newCheck("new statefulset %s's %s (index %d) ports do not match the current one",
494494
func(a, b v1.Container) bool { return !reflect.DeepEqual(a.Ports, b.Ports) }),
495-
newCheck("new statefulset %s's %s (index %d) resources don't match the current ones",
495+
newCheck("new statefulset %s's %s (index %d) resources do not match the current ones",
496496
func(a, b v1.Container) bool { return !compareResources(&a.Resources, &b.Resources) }),
497-
newCheck("new statefulset %s's %s (index %d) environment doesn't match the current one",
497+
newCheck("new statefulset %s's %s (index %d) environment does not match the current one",
498498
func(a, b v1.Container) bool { return !reflect.DeepEqual(a.Env, b.Env) }),
499-
newCheck("new statefulset %s's %s (index %d) environment sources don't match the current one",
499+
newCheck("new statefulset %s's %s (index %d) environment sources do not match the current one",
500500
func(a, b v1.Container) bool { return !reflect.DeepEqual(a.EnvFrom, b.EnvFrom) }),
501+
newCheck("new statefulset %s's %s (index %d) security context does not match the current one",
502+
func(a, b v1.Container) bool { return !reflect.DeepEqual(a.SecurityContext, b.SecurityContext) }),
501503
}
502504

503505
if !c.OpConfig.EnableLazySpiloUpgrade {
504-
checks = append(checks, newCheck("new statefulset %s's %s (index %d) image doesn't match the current one",
506+
checks = append(checks, newCheck("new statefulset %s's %s (index %d) image does not match the current one",
505507
func(a, b v1.Container) bool { return a.Image != b.Image }))
506508
}
507509

pkg/cluster/connection_pooler_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,25 +810,25 @@ func TestConnectionPoolerDeploymentSpec(t *testing.T) {
810810
func testResources(cluster *Cluster, podSpec *v1.PodTemplateSpec, role PostgresRole) error {
811811
cpuReq := podSpec.Spec.Containers[0].Resources.Requests["cpu"]
812812
if cpuReq.String() != cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultCPURequest {
813-
return fmt.Errorf("CPU request doesn't match, got %s, expected %s",
813+
return fmt.Errorf("CPU request does not match, got %s, expected %s",
814814
cpuReq.String(), cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultCPURequest)
815815
}
816816

817817
memReq := podSpec.Spec.Containers[0].Resources.Requests["memory"]
818818
if memReq.String() != cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultMemoryRequest {
819-
return fmt.Errorf("Memory request doesn't match, got %s, expected %s",
819+
return fmt.Errorf("Memory request does not match, got %s, expected %s",
820820
memReq.String(), cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultMemoryRequest)
821821
}
822822

823823
cpuLim := podSpec.Spec.Containers[0].Resources.Limits["cpu"]
824824
if cpuLim.String() != cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultCPULimit {
825-
return fmt.Errorf("CPU limit doesn't match, got %s, expected %s",
825+
return fmt.Errorf("CPU limit does not match, got %s, expected %s",
826826
cpuLim.String(), cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultCPULimit)
827827
}
828828

829829
memLim := podSpec.Spec.Containers[0].Resources.Limits["memory"]
830830
if memLim.String() != cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultMemoryLimit {
831-
return fmt.Errorf("Memory limit doesn't match, got %s, expected %s",
831+
return fmt.Errorf("Memory limit does not match, got %s, expected %s",
832832
memLim.String(), cluster.OpConfig.ConnectionPooler.ConnectionPoolerDefaultMemoryLimit)
833833
}
834834

pkg/cluster/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ func (c *Cluster) syncVolumeClaims() error {
599599
return fmt.Errorf("could not compare size of the volume claims: %v", err)
600600
}
601601
if !act {
602-
c.logger.Infof("volume claims don't require changes")
602+
c.logger.Infof("volume claims do not require changes")
603603
return nil
604604
}
605605
if err := c.resizeVolumeClaims(c.Spec.Volume); err != nil {

pkg/controller/node_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestNodeIsReady(t *testing.T) {
8888
for _, tt := range testTable {
8989
nodeTestController.opConfig.NodeReadinessLabel = tt.readinessLabel
9090
if isReady := nodeTestController.nodeIsReady(tt.in); isReady != tt.out {
91-
t.Errorf("%s: expected response %t doesn't match the actual %t for the node %#v",
91+
t.Errorf("%s: expected response %t does not match the actual %t for the node %#v",
9292
testName, tt.out, isReady, tt.in)
9393
}
9494
}

pkg/util/k8sutil/k8sutil.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func (client *KubernetesClient) SetPostgresCRDStatus(clusterName spec.Namespaced
201201
func SameService(cur, new *v1.Service) (match bool, reason string) {
202202
//TODO: improve comparison
203203
if cur.Spec.Type != new.Spec.Type {
204-
return false, fmt.Sprintf("new service's type %q doesn't match the current one %q",
204+
return false, fmt.Sprintf("new service's type %q does not match the current one %q",
205205
new.Spec.Type, cur.Spec.Type)
206206
}
207207

@@ -211,13 +211,13 @@ func SameService(cur, new *v1.Service) (match bool, reason string) {
211211
/* work around Kubernetes 1.6 serializing [] as nil. See https://github.com/kubernetes/kubernetes/issues/43203 */
212212
if (len(oldSourceRanges) != 0) || (len(newSourceRanges) != 0) {
213213
if !reflect.DeepEqual(oldSourceRanges, newSourceRanges) {
214-
return false, "new service's LoadBalancerSourceRange doesn't match the current one"
214+
return false, "new service's LoadBalancerSourceRange does not match the current one"
215215
}
216216
}
217217

218218
match = true
219219

220-
reasonPrefix := "new service's annotations doesn't match the current one:"
220+
reasonPrefix := "new service's annotations does not match the current one:"
221221
for ann := range cur.Annotations {
222222
if _, ok := new.Annotations[ann]; !ok {
223223
match = false
@@ -253,7 +253,7 @@ func SamePDB(cur, new *policybeta1.PodDisruptionBudget) (match bool, reason stri
253253
//TODO: improve comparison
254254
match = reflect.DeepEqual(new.Spec, cur.Spec)
255255
if !match {
256-
reason = "new PDB spec doesn't match the current one"
256+
reason = "new PDB spec does not match the current one"
257257
}
258258

259259
return
@@ -267,14 +267,14 @@ func getJobImage(cronJob *batchv1beta1.CronJob) string {
267267
func SameLogicalBackupJob(cur, new *batchv1beta1.CronJob) (match bool, reason string) {
268268

269269
if cur.Spec.Schedule != new.Spec.Schedule {
270-
return false, fmt.Sprintf("new job's schedule %q doesn't match the current one %q",
270+
return false, fmt.Sprintf("new job's schedule %q does not match the current one %q",
271271
new.Spec.Schedule, cur.Spec.Schedule)
272272
}
273273

274274
newImage := getJobImage(new)
275275
curImage := getJobImage(cur)
276276
if newImage != curImage {
277-
return false, fmt.Sprintf("new job's image %q doesn't match the current one %q",
277+
return false, fmt.Sprintf("new job's image %q does not match the current one %q",
278278
newImage, curImage)
279279
}
280280

pkg/util/k8sutil/k8sutil_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestSameService(t *testing.T) {
6363
v1.ServiceTypeLoadBalancer,
6464
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
6565
match: false,
66-
reason: `new service's type "LoadBalancer" doesn't match the current one "ClusterIP"`,
66+
reason: `new service's type "LoadBalancer" does not match the current one "ClusterIP"`,
6767
},
6868
{
6969
about: "services differ on lb source ranges",
@@ -82,7 +82,7 @@ func TestSameService(t *testing.T) {
8282
v1.ServiceTypeLoadBalancer,
8383
[]string{"185.249.56.0/22"}),
8484
match: false,
85-
reason: `new service's LoadBalancerSourceRange doesn't match the current one`,
85+
reason: `new service's LoadBalancerSourceRange does not match the current one`,
8686
},
8787
{
8888
about: "new service doesn't have lb source ranges",
@@ -101,7 +101,7 @@ func TestSameService(t *testing.T) {
101101
v1.ServiceTypeLoadBalancer,
102102
[]string{}),
103103
match: false,
104-
reason: `new service's LoadBalancerSourceRange doesn't match the current one`,
104+
reason: `new service's LoadBalancerSourceRange does not match the current one`,
105105
},
106106
{
107107
about: "services differ on DNS annotation",
@@ -120,7 +120,7 @@ func TestSameService(t *testing.T) {
120120
v1.ServiceTypeLoadBalancer,
121121
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
122122
match: false,
123-
reason: `new service's annotations doesn't match the current one: 'external-dns.alpha.kubernetes.io/hostname' changed from 'clstr.acid.zalan.do' to 'new_clstr.acid.zalan.do'.`,
123+
reason: `new service's annotations does not match the current one: 'external-dns.alpha.kubernetes.io/hostname' changed from 'clstr.acid.zalan.do' to 'new_clstr.acid.zalan.do'.`,
124124
},
125125
{
126126
about: "services differ on AWS ELB annotation",
@@ -139,7 +139,7 @@ func TestSameService(t *testing.T) {
139139
v1.ServiceTypeLoadBalancer,
140140
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
141141
match: false,
142-
reason: `new service's annotations doesn't match the current one: 'service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout' changed from '3600' to '1800'.`,
142+
reason: `new service's annotations does not match the current one: 'service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout' changed from '3600' to '1800'.`,
143143
},
144144
{
145145
about: "service changes existing annotation",
@@ -160,7 +160,7 @@ func TestSameService(t *testing.T) {
160160
v1.ServiceTypeLoadBalancer,
161161
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
162162
match: false,
163-
reason: `new service's annotations doesn't match the current one: 'foo' changed from 'bar' to 'baz'.`,
163+
reason: `new service's annotations does not match the current one: 'foo' changed from 'bar' to 'baz'.`,
164164
},
165165
{
166166
about: "service changes multiple existing annotations",
@@ -184,7 +184,7 @@ func TestSameService(t *testing.T) {
184184
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
185185
match: false,
186186
// Test just the prefix to avoid flakiness and map sorting
187-
reason: `new service's annotations doesn't match the current one:`,
187+
reason: `new service's annotations does not match the current one:`,
188188
},
189189
{
190190
about: "service adds a new custom annotation",
@@ -204,7 +204,7 @@ func TestSameService(t *testing.T) {
204204
v1.ServiceTypeLoadBalancer,
205205
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
206206
match: false,
207-
reason: `new service's annotations doesn't match the current one: Added 'foo' with value 'bar'.`,
207+
reason: `new service's annotations does not match the current one: Added 'foo' with value 'bar'.`,
208208
},
209209
{
210210
about: "service removes a custom annotation",
@@ -224,7 +224,7 @@ func TestSameService(t *testing.T) {
224224
v1.ServiceTypeLoadBalancer,
225225
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
226226
match: false,
227-
reason: `new service's annotations doesn't match the current one: Removed 'foo'.`,
227+
reason: `new service's annotations does not match the current one: Removed 'foo'.`,
228228
},
229229
{
230230
about: "service removes a custom annotation and adds a new one",
@@ -245,7 +245,7 @@ func TestSameService(t *testing.T) {
245245
v1.ServiceTypeLoadBalancer,
246246
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
247247
match: false,
248-
reason: `new service's annotations doesn't match the current one: Removed 'foo'. Added 'bar' with value 'foo'.`,
248+
reason: `new service's annotations does not match the current one: Removed 'foo'. Added 'bar' with value 'foo'.`,
249249
},
250250
{
251251
about: "service removes a custom annotation, adds a new one and change another",
@@ -269,7 +269,7 @@ func TestSameService(t *testing.T) {
269269
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
270270
match: false,
271271
// Test just the prefix to avoid flakiness and map sorting
272-
reason: `new service's annotations doesn't match the current one: Removed 'foo'.`,
272+
reason: `new service's annotations does not match the current one: Removed 'foo'.`,
273273
},
274274
{
275275
about: "service add annotations",
@@ -286,7 +286,7 @@ func TestSameService(t *testing.T) {
286286
[]string{"128.141.0.0/16", "137.138.0.0/16"}),
287287
match: false,
288288
// Test just the prefix to avoid flakiness and map sorting
289-
reason: `new service's annotations doesn't match the current one: Added `,
289+
reason: `new service's annotations does not match the current one: Added `,
290290
},
291291
}
292292
for _, tt := range tests {

0 commit comments

Comments
 (0)