Skip to content

Commit 4899c6a

Browse files
author
Marcell Sevcsik
committed
Fixes serialization problem
1 parent 94f5c6f commit 4899c6a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

pkg/gather/clusterconfig/clusterconfig.go

+19-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
corev1 "k8s.io/api/core/v1"
1919
apixv1beta1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1beta1"
20+
policyv1beta1 "k8s.io/api/policy/v1beta1"
2021
"k8s.io/apimachinery/pkg/api/errors"
2122
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2223
"k8s.io/apimachinery/pkg/runtime"
@@ -63,7 +64,7 @@ const (
6364
var (
6465
openshiftSerializer = openshiftscheme.Codecs.LegacyCodec(configv1.SchemeGroupVersion)
6566
kubeSerializer = kubescheme.Codecs.LegacyCodec(corev1.SchemeGroupVersion)
66-
67+
policyV1Beta1Serializer = kubescheme.Codecs.LegacyCodec(policyv1beta1.SchemeGroupVersion)
6768
// maxEventTimeInterval represents the "only keep events that are maximum 1h old"
6869
// TODO: make this dynamic like the reporting window based on configured interval
6970
maxEventTimeInterval = 1 * time.Hour
@@ -114,7 +115,7 @@ func New(client configv1client.ConfigV1Interface, coreClient corev1client.CoreV1
114115
registryClient: registryClient,
115116
crdClient: crdClient,
116117
networkClient: networkClient,
117-
policyClient: policyClient,
118+
policyClient: policyClient,
118119
}
119120
}
120121

@@ -157,8 +158,8 @@ func GatherPodDisruptionBudgets(i *Gatherer) func() ([]record.Record, []error) {
157158
records := []record.Record{}
158159
for _, pdb := range pdbs.Items {
159160
records = append(records, record.Record{
160-
Name: fmt.Sprintf("config/policy/%s", pdb.GetName()),
161-
Item: record.JSONMarshaller{Object: pdb},
161+
Name: fmt.Sprintf("config/pdbs/%s", pdb.GetName()),
162+
Item: PodDisruptionBudgetsAnonymizer{&pdb},
162163
})
163164
}
164165
return records, nil
@@ -1114,6 +1115,20 @@ func anonymizePod(pod *corev1.Pod) *corev1.Pod {
11141115
return pod
11151116
}
11161117

1118+
type PodDisruptionBudgetsAnonymizer struct {
1119+
*policyv1beta1.PodDisruptionBudget
1120+
}
1121+
1122+
// Marshal implements serialization of a Pod with anonymization
1123+
func (a PodDisruptionBudgetsAnonymizer) Marshal(_ context.Context) ([]byte, error) {
1124+
return runtime.Encode(policyV1Beta1Serializer, a.PodDisruptionBudget)
1125+
}
1126+
1127+
// GetExtension returns extension for anonymized pod objects
1128+
func (a PodDisruptionBudgetsAnonymizer) GetExtension() string {
1129+
return "json"
1130+
}
1131+
11171132
func isHealthyPod(pod *corev1.Pod, now time.Time) bool {
11181133
// pending pods may be unable to schedule or start due to failures, and the info they provide in status is important
11191134
// for identifying why scheduling has not happened

0 commit comments

Comments
 (0)