I've noticed in two cases today that typos in my K...
# python
c
I've noticed in two cases today that typos in my Kubernetes configuration have just silently omitted the misconfigured part of the spec, instead of warning or erroring on
pulumi up
.
First, in a pod spec, I had the following for an env var:
Copy code
{
                                "name": "VAULT_REDIRECT_ADDR",
                                "valueFrom:": {
                                    "configMapKeyRef": {
                                        "name": "config",
                                        "key": "vault-addr",
                                    }
                                },
                            },
Notice that there's an extra colon in
"valueFrom:"
just a silly typo.
pulumi up
worked fine, and what I ended up with was an empty env var in my pod.
Copy code
spec:
  containers:
  - env:
    - name: VAULT_REDIRECT_ADDR
Like that.
The other case was me trying to abstract a pod spec
affinity
statement out into a function.
Copy code
def self_antiaffinity(namespace, component):
    """Returns a pod spec affinity block specifying antiaffinity with other pods
    with this component."""

    return {
        "affinity": {
            "podAntiAffinity": {
                "requiredDuringSchedulingIgnoredDuringExecution": [
                    {
                        "labelSelector": {
                            "matchExpressions": [
                                {
                                    "key": "component",
                                    "operator": "In",
                                    "values": [
                                        component,
                                    ],
                                },
                            ],
                        },
                        "namespaces": [
                            namespace,
                        ],
                        "topologyKey": "<http://kubernetes.io/hostname|kubernetes.io/hostname>",
                    },
                ],
            },
        }
    }
And then I use it in my spec like so:
Copy code
vault_deployment = appsv1.Deployment(
    "vault",
    spec={
        "affinity": self_antiaffinity(namespace, "vault")
    }
)
The mistake I've made here is that there's an extra
"affinity"
key, so I end up with nested
{"affinity": {"affinity": ...}}
, which is incorrect.
But again,
pulumi up
worked, and what I actually got in my spec was
affinity: {}
.
c
@clean-engineer-75963 the API server, bizarrely, does not reject certain classes of errors, like this
I’m not sure why. It’s very odd indeeed.
we depend on it to do the validation, and over time I’ve just kind of hoped they fix this, but they haven’t.
c
Okay. Thanks for clarifying.
c
I’m not entirely sure, yet, how we’d fix this downstream
If you use TypeScript, this is “solved” by the fact that TS types don’t allow you to have random extra fields,
For Python there might not be a good answer