Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kustomize.v2.Directory raises "Unexpected type. Expected 'list' got '<class 'str'>'" [Python] #3389

Open
moltob opened this issue Dec 21, 2024 · 1 comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec

Comments

@moltob
Copy link

moltob commented Dec 21, 2024

What happened?

When using the kustomize directory resource, the sub resources are deployed correctly to the cluster as far as I can tell, but the execution fails with this stack on Python:

    error: Program failed with an unhandled exception:
    Traceback (most recent call last):
      File "/home/mpagel/.pulumi/bin/pulumi-language-python-exec", line 192, in <module>
        loop.run_until_complete(coro)
        ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
      File "/usr/lib/python3.13/asyncio/base_events.py", line 720, in run_until_complete
        return future.result()
               ~~~~~~~~~~~~~^^
      File "/home/mpagel/work/pulumi/deploy-kubernetes/.venv/lib/python3.13/site-packages/pulumi/runtime/stack.py", line 143, in run_in_stack
        await run_pulumi_func(run)
      File "/home/mpagel/work/pulumi/deploy-kubernetes/.venv/lib/python3.13/site-packages/pulumi/runtime/stack.py", line 55, in run_pulumi_func
        await wait_for_rpcs()
      File "/home/mpagel/work/pulumi/deploy-kubernetes/.venv/lib/python3.13/site-packages/pulumi/runtime/stack.py", line 119, in wait_for_rpcs
        await task
      File "/home/mpagel/work/pulumi/deploy-kubernetes/.venv/lib/python3.13/site-packages/pulumi/runtime/resource.py", line 1096, in do_register
        rpc.resolve_outputs(
        ~~~~~~~~~~~~~~~~~~~^
            res,
            ^^^^
        ...<6 lines>...
            keep_unknowns,
            ^^^^^^^^^^^^^^
        )
        ^
      File "/home/mpagel/work/pulumi/deploy-kubernetes/.venv/lib/python3.13/site-packages/pulumi/runtime/rpc.py", line 1356, in resolve_outputs
        translated_value = translate_output_properties(
            value,
        ...<3 lines>...
            path=_Path(translated_key, resource=f"{res._name}"),
        )
      File "/home/mpagel/work/pulumi/deploy-kubernetes/.venv/lib/python3.13/site-packages/pulumi/runtime/rpc.py", line 1232, in translate_output_properties
        element_type = _get_list_element_type(typ)
      File "/home/mpagel/work/pulumi/deploy-kubernetes/.venv/lib/python3.13/site-packages/pulumi/runtime/rpc.py", line 170, in _get_list_element_type
        raise AssertionError(f"Unexpected type. Expected 'list' got '{typ}'")
    AssertionError: Unexpected type. Expected 'list' got '<class 'str'>'

Example

The program is attempting to install the local-path-provisioner in the cluster:

# Talos cluster setup
...

k8s_provider = k8s.Provider(
    'k8s-provider',
    # enable_server_side_apply=True,
    kubeconfig=kube_config.kubeconfig_raw,
)

k8s.kustomize.v2.Directory(
    'kustomize-local-path-provisioner',
    directory='kustomize/local-path-provisioner',
    opts=pulumi.ResourceOptions(provider=k8s_provider),
)

The referenced directory contains local-path-storage.yaml and this kustomization.yaml:

# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - local-path-storage.yaml
patches:
  - patch: |-
      kind: ConfigMap
      apiVersion: v1
      metadata:
        name: local-path-config
        namespace: local-path-storage
      data:
        config.json: |-
          {
                  "nodePathMap":[
                  {
                          "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
                          "paths":["/var/mnt/data"]
                  }
                  ]
          }
  - patch: |-
      apiVersion: v1
      kind: Namespace
      metadata:
        name: local-path-storage
        labels:
          pod-security.kubernetes.io/enforce: privileged

Output of pulumi about

The shown resources are from after the failing update was run, so you see the subresources are in fact created, also in the pulumi stack:

CLI          
Version      3.143.0
Go Version   go1.23.4
Go Compiler  gc

Plugins
KIND      NAME        VERSION
resource  command     1.0.1
resource  kubernetes  4.19.0
resource  proxmoxve   6.18.0
language  python      3.143.0
resource  talos       0.4.1

Host     
OS       ubuntu
Version  22.04
Arch     x86_64

This project is written in python: executable='/home/mpagel/work/pulumi/deploy-kubernetes/.venv/bin/python' version='3.13.1'

Current Stack: moltob/deploy-kubernetes/dev

TYPE                                                        URN
pulumi:pulumi:Stack                                         urn:pulumi:dev::deploy-kubernetes::pulumi:pulumi:Stack::deploy-kubernetes-dev
pulumi:providers:talos                                      urn:pulumi:dev::deploy-kubernetes::pulumi:providers:talos::default_0_4_1_github_/api.github.com/pulumiverse
pulumi:providers:pulumi                                     urn:pulumi:dev::deploy-kubernetes::pulumi:providers:pulumi::default
talos:machine/secrets:Secrets                               urn:pulumi:dev::deploy-kubernetes::talos:machine/secrets:Secrets::common-talos-secrets
talos:imageFactory/schematic:Schematic                      urn:pulumi:dev::deploy-kubernetes::talos:imageFactory/schematic:Schematic::talos-schematic
pulumi:pulumi:StackReference                                urn:pulumi:dev::deploy-kubernetes::pulumi:pulumi:StackReference::moltob/deploy-proxmox/prod
pulumi:providers:proxmoxve                                  urn:pulumi:dev::deploy-kubernetes::pulumi:providers:proxmoxve::pve-provider
proxmoxve:Download/file:File                                urn:pulumi:dev::deploy-kubernetes::proxmoxve:Download/file:File::talos-boot-image
proxmoxve:VM/virtualMachine:VirtualMachine                  urn:pulumi:dev::deploy-kubernetes::proxmoxve:VM/virtualMachine:VirtualMachine::k8s-cp-0-vm-dev
proxmoxve:VM/virtualMachine:VirtualMachine                  urn:pulumi:dev::deploy-kubernetes::proxmoxve:VM/virtualMachine:VirtualMachine::k8s-wk-0-vm-dev
talos:machine/configurationApply:ConfigurationApply         urn:pulumi:dev::deploy-kubernetes::talos:machine/configurationApply:ConfigurationApply::k8s-wk-0-talos-configuration-apply
talos:machine/configurationApply:ConfigurationApply         urn:pulumi:dev::deploy-kubernetes::talos:machine/configurationApply:ConfigurationApply::k8s-cp-0-talos-configuration-apply
talos:machine/bootstrap:Bootstrap                           urn:pulumi:dev::deploy-kubernetes::talos:machine/bootstrap:Bootstrap::common-talos-bootstrap
pulumi:providers:kubernetes                                 urn:pulumi:dev::deploy-kubernetes::pulumi:providers:kubernetes::k8s-provider
kubernetes:kustomize/v2:Directory                           urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory::kustomize-local-path-provisioner
kubernetes:rbac.authorization.k8s.io/v1:ClusterRole         urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:rbac.authorization.k8s.io/v1:ClusterRole::kustomize-local-path-provisioner:local-path-provisioner-role
kubernetes:storage.k8s.io/v1:StorageClass                   urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:storage.k8s.io/v1:StorageClass::kustomize-local-path-provisioner:local-path
kubernetes:core/v1:Namespace                                urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:core/v1:Namespace::kustomize-local-path-provisioner:local-path-storage
kubernetes:rbac.authorization.k8s.io/v1:ClusterRoleBinding  urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:rbac.authorization.k8s.io/v1:ClusterRoleBinding::kustomize-local-path-provisioner:local-path-provisioner-bind
kubernetes:rbac.authorization.k8s.io/v1:Role                urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:rbac.authorization.k8s.io/v1:Role::kustomize-local-path-provisioner:local-path-storage/local-path-provisioner-role
kubernetes:core/v1:ServiceAccount                           urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:core/v1:ServiceAccount::kustomize-local-path-provisioner:local-path-storage/local-path-provisioner-service-account
kubernetes:rbac.authorization.k8s.io/v1:RoleBinding         urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:rbac.authorization.k8s.io/v1:RoleBinding::kustomize-local-path-provisioner:local-path-storage/local-path-provisioner-bind
kubernetes:core/v1:ConfigMap                                urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:core/v1:ConfigMap::kustomize-local-path-provisioner:local-path-storage/local-path-config
kubernetes:apps/v1:Deployment                               urn:pulumi:dev::deploy-kubernetes::kubernetes:kustomize/v2:Directory$kubernetes:apps/v1:Deployment::kustomize-local-path-provisioner:local-path-storage/local-path-provisioner


Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/moltob
User           moltob
Organizations  moltob
Token type     personal

Dependencies:
NAME               VERSION
pip                24.3.1
pulumi_command     1.0.1
pulumi_kubernetes  4.19.0
pulumi_proxmoxve   6.18.0
pulumiverse_talos  0.4.1
pydantic           2.10.4
pyright            1.1.391
ruff               0.1.15

Pulumi locates its logs in /tmp by default

Additional context

As you might guess from the about output:

  • Python 3.13 on WSL 2 on Windows 11
  • Talos Linux as Kubernetes stack
  • Proxmox as VM environment
  • Test cluster with 1 CP and 1 worker node

Also what might be interesting: Doing kustomize outside of Pulumi and then using ConfigGroup or ConfigFile on the output works flawlessly!

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@moltob moltob added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 21, 2024
@mjeffryes
Copy link
Member

This looks like you're probably hitting Confusing error message in serialization logic in rpc.py· pulumi/13506 I can't immediately spot a type error in the code you've shared, but that would be what I would suggest looking for as a next step. The fact that the kustomize resources are created also makes me wonder if the error is actually with another resource later in the program?

@mjeffryes mjeffryes added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants