Skip to content

Commit fff7bb3

Browse files
authored
fix: encode podSpecAnnotation content in JSON (cloudnative-pg#2618)
The PR cloudnative-pg#2243 mistakenly used the Protocol Buffers encoding for the podSpec annotation content. This commit changes the encoding to JSON as intended. Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
1 parent d3abbc7 commit fff7bb3

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

controllers/cluster_upgrade.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package controllers
1818

1919
import (
2020
"context"
21+
"encoding/json"
2122
"errors"
2223
"fmt"
2324
"io"
@@ -569,7 +570,7 @@ func checkPodSpecIsOutdated(
569570
}
570571

571572
var storedPodSpec corev1.PodSpec
572-
err := (&storedPodSpec).Unmarshal([]byte(podSpecAnnotation))
573+
err := json.Unmarshal([]byte(podSpecAnnotation), &storedPodSpec)
573574
if err != nil {
574575
return rollout{}, fmt.Errorf("while unmarshaling the pod resources annotation: %w", err)
575576
}

pkg/specs/pods.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
package specs
2020

2121
import (
22+
"encoding/json"
2223
"fmt"
2324
"reflect"
2425
"strconv"
@@ -380,7 +381,7 @@ func PodWithExistingStorage(cluster apiv1.Cluster, nodeSerial int) *corev1.Pod {
380381
Spec: podSpec,
381382
}
382383

383-
if podSpecMarshaled, err := podSpec.Marshal(); err == nil {
384+
if podSpecMarshaled, err := json.Marshal(podSpec); err == nil {
384385
pod.Annotations[utils.PodSpecAnnotationName] = string(podSpecMarshaled)
385386
}
386387

0 commit comments

Comments
 (0)