kubernetes-client/python

Deployment spec properties are inadvertently removed when serializing

Open

#2.435 aberto em 14 de ago. de 2025

Ver no GitHub
 (4 comments) (0 reactions) (0 assignees)Python (3.323 forks)batch import
help wantedkind/bug

Métricas do repositório

Stars
 (6.225 stars)
Métricas de merge de PR
 (Mesclagem média 10d 3h) (2 fundiu PRs em 30d)

Description

Summary

Various valid deployment spec properties are seemingly wiped out when I load it into a V1DeploymentSpec object, make a small change, then re-serialize to a dict.

Details

I am extracting a V1DeploymentSpec from a ClusterServiceVersion manifest, making a small mutation to it, then re-serializing it and adding it back into the ClusterServiceVersion. This leads to multiple mutations that were not intended. See the following sequence of diffs (none of which were intended) for reference:

@@ -356,287 +355,126 @@

-          selector:
-            matchLabels:
-              name: my-operator
+          selector: {}

...

             spec:
-              affinity:
-                nodeAffinity:
-                  requiredDuringSchedulingIgnoredDuringExecution:
-                    nodeSelectorTerms:
-                    - matchExpressions:
-                      - key: kubernetes.io/arch
-                        operator: In
-                        values:
-                        - s390x
-                        - amd64
+              affinity: {}

...

                 - name: WATCH_NAMESPACE
-                  valueFrom:
-                    fieldRef:
-                      fieldPath: metadata.annotations['olm.targetNamespaces']
                 - name: POD_NAME
-                  valueFrom:
-                    fieldRef:
-                      fieldPath: metadata.name

...

-                imagePullPolicy: Always
-                livenessProbe:
-                  failureThreshold: 4
-                  httpGet:
-                    path: /healthz
-                    port: 8081
-                  initialDelaySeconds: 15
-                  periodSeconds: 15
-                  successThreshold: 1
-                  timeoutSeconds: 3
-                readinessProbe:
-                  failureThreshold: 3
-                  httpGet:
-                    path: /healthz
-                    port: 8081
-                  initialDelaySeconds: 15
-                  periodSeconds: 15
-                  successThreshold: 1
-                  timeoutSeconds: 3

Guia do colaborador