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

AKS: got an unexpected keyword argument 'status' #1755

Closed
yellowhat opened this issue Oct 5, 2021 · 8 comments
Closed

AKS: got an unexpected keyword argument 'status' #1755

yellowhat opened this issue Oct 5, 2021 · 8 comments
Assignees
Labels
area/yaml kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed

Comments

@yellowhat
Copy link

Hello!

  • 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)

Issue details

Hi,
I am trying to create a AKS cluster with AAD pod identity capability:

from urllib.request import urlretrieve
import pulumi
import pulumi_azure as azure
import pulumi_kubernetes as kubernetes

RG = "zz"
LOCATION = "uksouth"

# Resource Group
rg = azure.core.ResourceGroup(
    "rg",
    name=RG,
    location=LOCATION,
)

# Cluster
aks = azure.containerservice.KubernetesCluster(
    "aks",
    name="aks",
    resource_group_name=rg.name,
    location=rg.location,
    dns_prefix="aks000aks",
    network_profile=azure.containerservice.KubernetesClusterNetworkProfileArgs(
        network_plugin="azure",
    ),
    default_node_pool=azure.containerservice.KubernetesClusterDefaultNodePoolArgs(
        name="default",
        node_count=1,
        vm_size="Standard_F8s_v2",
    ),
    role_based_access_control=azure.containerservice.KubernetesClusterRoleBasedAccessControlArgs(
        enabled=True,
    ),
    identity=azure.containerservice.KubernetesClusterIdentityArgs(
        type="SystemAssigned",
    ),
)

# Kubectl
aks_provider = kubernetes.Provider(
    "aks",
    kubeconfig=aks.kube_config_raw,
)

# AAD Pod Identity (https://azure.github.io/aad-pod-identity/docs/demo/standard_walkthrough)
urls = [
    "https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment-rbac.yaml",
    "https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/mic-exception.yaml",
]

for url in urls:
    yaml = url.split("/")[-1]
    urlretrieve(url, yaml)
    _ = kubernetes.yaml.ConfigFile(
        yaml,
        file=yaml,
        opts=pulumi.ResourceOptions(provider=aks_provider),
    )

But I get:

$ pulumi preview
Previewing update (dev):
     Type                                                                 Name                                    Plan       Info
 +   pulumi:pulumi:Stack                                                  cyclecloud-dev                          create     3 errors
 +   ├─ kubernetes:yaml:ConfigFile                                        deployment-rbac.yaml                    create
 +   │  ├─ kubernetes:core/v1:ServiceAccount                              default/aad-pod-id-nmi-service-account  create
 +   │  ├─ kubernetes:core/v1:ServiceAccount                              default/aad-pod-id-mic-service-account  create
 +   │  ├─ kubernetes:rbac.authorization.k8s.io/v1:ClusterRole            aad-pod-id-nmi-role                     create
 +   │  ├─ kubernetes:apps/v1:DaemonSet                                   default/nmi                             create
 +   │  ├─ kubernetes:rbac.authorization.k8s.io/v1:ClusterRoleBinding     aad-pod-id-mic-binding                  create
 +   │  ├─ kubernetes:rbac.authorization.k8s.io/v1:ClusterRoleBinding     aad-pod-id-nmi-binding                  create
 +   │  ├─ kubernetes:apps/v1:Deployment                                  default/mic                             create
 +   │  └─ kubernetes:rbac.authorization.k8s.io/v1:ClusterRole            aad-pod-id-mic-role                     create
 +   ├─ kubernetes:yaml:ConfigFile                                        mic-exception.yaml                      create
 +   │  ├─ kubernetes:aadpodidentity.k8s.io/v1:AzurePodIdentityException  default/mic-exception                   create
 +   │  └─ kubernetes:aadpodidentity.k8s.io/v1:AzurePodIdentityException  kube-system/aks-addon-exception         create
 +   ├─ azure:core:ResourceGroup                                          rg                                      create
 +   ├─ azure:containerservice:KubernetesCluster                          aks                                     create
 +   └─ pulumi:providers:kubernetes                                       aks                                     create

Diagnostics:
  pulumi:pulumi:Stack (cyclecloud-dev):
    error: Program failed with an unhandled exception:
    error: Traceback (most recent call last):
      File "/usr/local/bin/pulumi-language-python-exec", line 92, in <module>
        loop.run_until_complete(coro)
      File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
        return future.result()
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 110, in run_in_stack
        await run_pulumi_func(lambda: Stack(func))
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 45, in run_pulumi_func
        await wait_for_rpcs()
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 65, in wait_for_rpcs
        await RPC_MANAGER.rpcs.pop()
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/rpc_manager.py", line 65, in rpc_wrapper
        result = await rpc
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/resource.py", line 592, in do_register_resource_outputs
        serialized_props = await rpc.serialize_properties(outputs, {})
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 149, in serialize_properties
        result = await serialize_property(v, deps, input_transformer, get_type(k), keep_output_values)
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 290, in serialize_property
        value = await serialize_property(output.future(), deps, input_transformer, typ, keep_output_values=False)
      File "/usr/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 276, in serialize_property
        future_return = await asyncio.ensure_future(awaitable)
      File "/usr/lib/python3.9/site-packages/pulumi/output.py", line 119, in get_value
        val = await self._future
      File "/usr/lib/python3.9/site-packages/pulumi/output.py", line 160, in run
        value = await self._future
      File "/usr/lib/python3.9/site-packages/pulumi/output.py", line 418, in gather_futures
        return await asyncio.gather(*value_futures_list)
      File "/usr/lib/python3.9/site-packages/pulumi/output.py", line 119, in get_value
        val = await self._future
      File "/usr/lib/python3.9/site-packages/pulumi/output.py", line 160, in run
        value = await self._future
      File "/usr/lib/python3.9/site-packages/pulumi/output.py", line 181, in run
        transformed: Input[U] = func(value)
      File "/usr/lib/python3.9/site-packages/pulumi_kubernetes/yaml.py", line 543, in <lambda>
        CustomResourceDefinition(f"{x}", opts, **obj)))]
      File "/usr/lib/python3.9/site-packages/pulumi_kubernetes/apiextensions/v1/CustomResourceDefinition.py", line 126, in __init__
        __self__._internal_init(resource_name, *args, **kwargs)
    TypeError: _internal_init() got an unexpected keyword argument 'status'
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

Steps to reproduce

  1. pulumi preview

Expected: deploy
Actual: error above

Any ideas?

Thanks

@yellowhat yellowhat added the kind/bug Some behavior is incorrect or out of spec label Oct 5, 2021
@mikhailshilkov
Copy link
Member

I can repro it with a simple

import pulumi_kubernetes as kubernetes

_ = kubernetes.yaml.ConfigFile(
    "deployment-rbac.yaml",
    file="https://raw.githubusercontent.com/Azure/aad-pod-identity/master/deploy/infra/deployment-rbac.yaml",
)

The exact same code works in TypeScript, so there may be something Python-specific here...

@yellowhat
Copy link
Author

Same error using Helm:

aks_pod_identity = kubernetes.helm.v3.Chart(
    "aks_pod_identity",
    kubernetes.helm.v3.ChartOpts(
        chart="aad-pod-identity",
        version="4.1.5",
        namespace="kube-system",
        fetch_opts=kubernetes.helm.v3.FetchOpts(
            repo="https://raw.githubusercontent.com/Azure/aad-pod-identity/master/charts",
        ),
    ),
    opts=pulumi.ResourceOptions(provider=aks_provider),
)

Not sure if it helps to troubleshoot.

@yellowhat
Copy link
Author

Are there any update on this?

Thanks

@JHeilCoveo
Copy link

Got the same error but I workarounded it like this:

def _fix_status(obj: Any, opts: pulumi.ResourceOptions):
    if obj.get("kind") == "CustomResourceDefinition":
        # Remove offending parameter
        del obj["status"]

kubernetes.helm.v3.Chart(
    kubernetes.helm.v3.ChartOpts(
        ...
        transformations=[_fix_status],
    )
    ...
)

@darkshade9
Copy link

darkshade9 commented Oct 21, 2021

Thanks for that @JHeilCoveo
obj: any worked for me

@yellowhat
Copy link
Author

Should be a typing annotation: from typing import Any.

@JHeilCoveo
Copy link

Yes it's from typing, you can remove Any and pulumi.ResourceOptions if it's bothering you.

AndreiChenchik added a commit to AndreiChenchik/local-cluster that referenced this issue May 30, 2022
@lblackstone lblackstone self-assigned this Jul 14, 2023
@lblackstone lblackstone added the resolution/fixed This issue was fixed label Jul 14, 2023
@lblackstone
Copy link
Member

It looks like this was fixed in #2183

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/yaml kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

5 participants