Skip to content

Commit 1c01efe

Browse files
authored
Merge pull request kubernetes#89945 from k-toyoda-pi/add_error_check_e2e_disruption
Add error check for marshaling json in e2e/apps/disruption
2 parents 81d2707 + effd064 commit 1c01efe

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test/e2e/apps/disruption.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ var _ = SIGDescribe("DisruptionController", func() {
132132

133133
ginkgo.By("Patching PodDisruptionBudget status")
134134
patched, _ := patchPDBOrDie(cs, dc, ns, defaultName, func(old *policyv1beta1.PodDisruptionBudget) (bytes []byte, err error) {
135-
oldBytes, _ := json.Marshal(old)
135+
oldBytes, err := json.Marshal(old)
136+
framework.ExpectNoError(err, "failed to marshal JSON for old data")
136137
old.Status.DisruptedPods = make(map[string]metav1.Time)
137-
newBytes, _ := json.Marshal(old)
138+
newBytes, err := json.Marshal(old)
139+
framework.ExpectNoError(err, "failed to marshal JSON for new data")
138140
return jsonpatch.CreateMergePatch(oldBytes, newBytes)
139141
}, "status")
140142
framework.ExpectEmpty(patched.Status.DisruptedPods, "Expecting the PodDisruptionBudget's be empty")
@@ -303,10 +305,12 @@ var _ = SIGDescribe("DisruptionController", func() {
303305
ginkgo.By("Patching the pdb to disallow a pod to be evicted")
304306
patchPDBOrDie(cs, dc, ns, defaultName, func(old *policyv1beta1.PodDisruptionBudget) (bytes []byte, err error) {
305307
oldData, err := json.Marshal(old)
308+
framework.ExpectNoError(err, "failed to marshal JSON for old data")
306309
old.Spec.MinAvailable = nil
307310
maxUnavailable := intstr.FromInt(0)
308311
old.Spec.MaxUnavailable = &maxUnavailable
309-
newData, _ := json.Marshal(old)
312+
newData, err := json.Marshal(old)
313+
framework.ExpectNoError(err, "failed to marshal JSON for new data")
310314
return jsonpatch.CreateMergePatch(oldData, newData)
311315
})
312316

0 commit comments

Comments
 (0)