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

Outputs for Image registry properties in Python fail #190

Closed
joeduffy opened this issue Jun 10, 2020 · 1 comment
Closed

Outputs for Image registry properties in Python fail #190

joeduffy opened this issue Jun 10, 2020 · 1 comment
Assignees
Milestone

Comments

@joeduffy
Copy link
Member

I get an error, Output' object is not callable, if Image's registry argument contains outputs:

   error: Traceback (most recent call last):
      File "/usr/local/bin/pulumi-language-python-exec", line 85, in <module>
        loop.run_until_complete(coro)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
        return future.result()
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 81, in run_in_stack
        await run_pulumi_func(lambda: Stack(func))
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/runtime/stack.py", line 50, in run_pulumi_func
        await RPC_MANAGER.rpcs.pop()
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/runtime/rpc_manager.py", line 67, in rpc_wrapper
        result = await rpc
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/runtime/resource.py", line 440, in do_register_resource_outputs
        serialized_props = await rpc.serialize_properties(outputs, {})
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 68, in serialize_properties
        result = await serialize_property(v, deps, input_transformer)
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 173, in serialize_property
        value = await serialize_property(output.future(), deps, input_transformer)
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/runtime/rpc.py", line 159, in serialize_property
        future_return = await asyncio.ensure_future(awaitable)
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/output.py", line 114, in get_value
        val = await self._future
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/output.py", line 155, in run
        value = await self._future
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/output.py", line 155, in run
        value = await self._future
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/output.py", line 155, in run
        value = await self._future
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi/output.py", line 176, in run
        transformed: Input[U] = func(value)
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi_docker/image.py", line 234, in <lambda>
        lambda args: get_image_data(_ImageArgs(*args))
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi_docker/image.py", line 225, in get_image_data
        image_args.skip_push,
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi_docker/docker.py", line 228, in build_and_push_image
        login_to_registry(registry, log_resource)
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi_docker/docker.py", line 513, in login_to_registry
        log_resource, report_full_command_line=False, stdin=password)
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi_docker/docker.py", line 585, in run_command_that_must_succeed
        cmd, args, log_resource, report_full_command_line, False, stdin, env)
      File "/Users/joeduffy/temp/docker-build/docker/py/venv/lib/python3.7/site-packages/pulumi_docker/docker.py", line 651, in run_command_that_can_fail
        outs, errs = process.communicate(input=stdin)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/subprocess.py", line 939, in communicate
        stdout, stderr = self._communicate(input, endtime, timeout)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1663, in _communicate
        self._save_input(input)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1739, in _save_input
        self.stdin.errors)
    TypeError: 'Output' object is not callable
    error: an unhandled error occurred: Program exited with non-zero exit code: 1

It appears we handle the case when the entire registry itself is an Output, but not the individual properties on that object. They are typed as Input[str], so I expected that to work.

For example, this code fails:

import pulumi
import pulumi_docker as docker

# Fetch the Docker Hub auth info from config.
config = pulumi.Config()
username = config.require('dockerUsername')
password = config.require_secret('dockerPassword')

# Build and publish the image.
image = docker.Image('my-image',
    build='app',
    image_name=f'{username}/myapp',
    registry=docker.ImageRegistry(
        server='docker.io',
        username=username,
        password=password,
    ),
)

# Export the resulting base name in addition to the specific version pushed.
pulumi.export('imageName', image.image_name)

whereas this code works just fine:

import pulumi
import pulumi_docker as docker

# Fetch the Docker Hub auth info from config.
config = pulumi.Config()
username = config.require('dockerUsername')
password = config.require_secret('dockerPassword')

def get_registry(pwd):
    return docker.ImageRegistry(
        server='docker.io',
        username=username,
        password=pwd,
    )

# Build and publish the image.
image = docker.Image('my-image',
    build='app',
    image_name=f'{username}/myapp',
    registry=password.apply(lambda pwd: get_registry(pwd))
)

# Export the resulting base name in addition to the specific version pushed.
pulumi.export('imageName', image.image_name)
@joeduffy
Copy link
Member Author

Note, I believe this is because Output.all in Python doesn't await outputs recursively like we do in Node.js. So this line

image_data = pulumi.Output.all(image_name, build, local_image_name, registry, skip_push).apply(
doesn't actually unpack the inner properties on, for instance, the registry object. We ran into this recently and I think it's (unfortunately) by design -- meaning we probably need to manually unpack all of the inner possibly-output properties by hand.

@komalali komalali added this to the current milestone Jul 14, 2020
@leezen leezen modified the milestones: current, 0.40 Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants