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

Python ObjectMeta output not propagating correctly #26

Closed
maxromanovsky opened this issue Feb 28, 2021 · 2 comments · Fixed by #143
Closed

Python ObjectMeta output not propagating correctly #26

maxromanovsky opened this issue Feb 28, 2021 · 2 comments · Fixed by #143
Assignees
Labels
area/codegen Affects quality or correctness of generated code kind/bug Some behavior is incorrect or out of spec language/python resolution/fixed This issue was fixed

Comments

@maxromanovsky
Copy link

Python ObjectMeta output not propagating correctly.
It is impossible to use custom resource metadata name for other resources.
Case: I can't use cert-manager's ClusterIssuer metadata['name'] for the Certificate.

Expected behavior

issuer_resource.metadata['name'] is available

Current behavior

    error: Program failed with an unhandled exception:
    error: Traceback (most recent call last):
      File "/usr/local/bin/pulumi-language-python-exec", line 85, in <module>
        loop.run_until_complete(coro)
      File "/usr/local/Cellar/[email protected]/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
        return future.result()
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 83, in run_in_stack
        await run_pulumi_func(lambda: Stack(func))
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/stack.py", line 51, in run_pulumi_func
        await RPC_MANAGER.rpcs.pop()
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/rpc_manager.py", line 67, in rpc_wrapper
        result = await rpc
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/output.py", line 91, in is_value_known
        return await is_known and not contains_unknowns(await future)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/output.py", line 91, in is_value_known
        return await is_known and not contains_unknowns(await future)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/output.py", line 91, in is_value_known
        return await is_known and not contains_unknowns(await future)
      [Previous line repeated 3 more times]
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/resource.py", line 358, in do_register
        resolver = await prepare_resource(res, ty, custom, props, opts)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/resource.py", line 86, in prepare_resource
        serialized_props = await rpc.serialize_properties(props, property_dependencies_resources, res.translate_input_property)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 78, in serialize_properties
        result = await serialize_property(v, deps, input_transformer)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 227, in serialize_property
        obj[transformed_key] = await serialize_property(v, deps, input_transformer)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 227, in serialize_property
        obj[transformed_key] = await serialize_property(v, deps, input_transformer)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 199, in serialize_property
        value = await serialize_property(output.future(), deps, input_transformer)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/runtime/rpc.py", line 185, in serialize_property
        future_return = await asyncio.ensure_future(awaitable)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/output.py", line 116, in get_value
        val = await self._future
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/output.py", line 178, in run
        transformed: Input[U] = func(value)
      File "/path/to/project/.venv/lib/python3.9/site-packages/pulumi/output.py", line 236, in <lambda>
        return self.apply(lambda v: UNKNOWN if isinstance(v, Unknown) else cast(Any, v)[key], True)
    KeyError: 'name'
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

Steps to reproduce

wget https://github.com/jetstack/cert-manager/releases/download/v0.15.0/cert-manager.crds.yaml
crd2pulumi -cert-manager.crds.yaml

pulumi_crds/meta_v1/outputs.py file:

# coding=utf-8
# *** WARNING: this file was generated by crd2pulumi. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***

import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union
from .. import _utilities, _tables

__all__ = [
    'ObjectMeta',
]

@pulumi.output_type
class ObjectMeta(dict):
    def __init__(__self__):
        pass

    def _translate_property(self, prop):
        return _tables.CAMEL_TO_SNAKE_CASE_TABLE.get(prop) or prop

Steps:

    issuer_prod = ClusterIssuer(
        issuer_prod_name,
        metadata=ObjectMetaArgs(name=issuer_prod_name),
       [...]
    )

    
    cert = CustomResource(
        name, "cert-manager.io/v1alpha3", "Certificate",
        metadata={
       [...]
        },
        spec={
            "issuerRef": {
                "name": issuer_resource.metadata['name'],
                "kind": issuer_resource.kind,
            },
       [...]
     )

Context (Environment)

$ pulumi version
v2.21.2

$ crd2pulumi --version
crd2pulumi version v1.0.5
pulumi==2.21.2
pulumi-kubernetes==2.8.2

Affected feature

@maxromanovsky maxromanovsky added the kind/bug Some behavior is incorrect or out of spec label Feb 28, 2021
@leezen leezen added kind/bug Some behavior is incorrect or out of spec and removed kind/bug Some behavior is incorrect or out of spec labels Mar 2, 2021
@mattolenik mattolenik added language/python area/codegen Affects quality or correctness of generated code labels Jun 2, 2022
@Aetf
Copy link

Aetf commented Jun 3, 2024

Also encountered this issue today with pulumi 3.117.0 and pulumi-kubernetes 4.12, crd2pulumi version is 1.4.0

@pulumi-bot
Copy link

This issue has been addressed in PR #143 and shipped in release v1.5.0.

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

Successfully merging a pull request may close this issue.

6 participants