-
Notifications
You must be signed in to change notification settings - Fork 14
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
Preview with refresh failing with Authentication errors #1339
Comments
Hey @asvinours, thanks for bringing this issue up. Could you please run Could you also help me reproduce this issue? Ideally a sample pulumi program and necessary steps that will show the broken behavior. |
I tried reproducing this, but couldn't. I used ECR as an example to test:
I exported the following env variables (replace AWS_ACCOUNT_ID):
After that I did the following:
|
Hey, here's the output of
Here's the code to reproduce the issue, I tried to keep it somewhat close to our real application: from __future__ import annotations
import os
from pulumi import ComponentResource
from pulumi import InvokeOptions
from pulumi import ResourceOptions
import pulumi_docker as docker
class CustomComponentTwo(ComponentResource):
def __init__(self, name: str, opts: ResourceOptions = None) -> None:
super().__init__("custom:component:two", name, None, opts)
default_resource_options = ResourceOptions(parent=self)
default_invoke_options = InvokeOptions(parent=self)
# removed the actual image name here - needs to be replaced with a proper image reference
gitlab_image = docker.get_registry_image(name="[...]", opts=default_invoke_options)
docker.RemoteImage(
name,
name=gitlab_image.name,
pull_triggers=[gitlab_image.sha256_digest],
opts=default_resource_options,
)
class CustomComponentOne(ComponentResource):
def __init__(self, name: str, opts: ResourceOptions = None) -> None:
super().__init__("custom:component:one", name, None, opts)
docker_provider = docker.Provider(
"this",
registry_auth=[
docker.ProviderRegistryAuthArgs(
address=os.environ.get("CI_REGISTRY"),
username=os.environ.get("CI_REGISTRY_USER"),
password=os.environ.get("CI_REGISTRY_PASSWORD"),
),
],
)
default_resource_options = ResourceOptions(parent=self, providers={"docker": docker_provider})
CustomComponentTwo(
name="this",
opts=default_resource_options,
)
CustomComponentOne(name="test-gitlab-docker") Pulumi config: ---
name: test-pulumi-docker-provider
runtime:
name: python
options:
refresh: always
disable-default-providers: ['*'] I was able to reproduce the issue with the following steps:
pulumi preview --diff
Please choose a stack, or create a new one: default
Enter your passphrase to unlock config/secrets
(set PULUMI_CONFIG_PASSPHRASE or PULUMI_CONFIG_PASSPHRASE_FILE to remember):
Enter your passphrase to unlock config/secrets
Previewing update (default):
~ custom:component:one: (refresh)
[urn=urn:pulumi:default::test-pulumi-docker-provider::custom:component:one::test-gitlab-docker]
~ pulumi:pulumi:Stack: (refresh)
[urn=urn:pulumi:default::test-pulumi-docker-provider::pulumi:pulumi:Stack::test-pulumi-docker-provider-default]
~ custom:component:two: (refresh)
[urn=urn:pulumi:default::test-pulumi-docker-provider::custom:component:one$custom:component:two::this]
~ pulumi:providers:docker: (refresh)
[id=9a5ecf06-6282-47f3-916d-ec3161e854f6]
[urn=urn:pulumi:default::test-pulumi-docker-provider::pulumi:providers:docker::this]
~ docker:index/remoteImage:RemoteImage: (refresh)
[id=sha256:c58b1e54efd8db1b900a6fb5ec07236c1b326c1cd463f45bdd79709f52a7377e[...]]
[urn=urn:pulumi:default::test-pulumi-docker-provider::custom:component:one$custom:component:two$docker:index/remoteImage:RemoteImage::this]
[provider=urn:pulumi:default::test-pulumi-docker-provider::pulumi:providers:docker::this::9a5ecf06-6282-47f3-916d-ec3161e854f6]
pulumi:pulumi:Stack: (same)
[urn=urn:pulumi:default::test-pulumi-docker-provider::pulumi:pulumi:Stack::test-pulumi-docker-provider-default]
error: Program failed with an unhandled exception:
Traceback (most recent call last):
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/__main__.py", line 52, in <module>
CustomComponentOne(name="test-gitlab-docker")
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/__main__.py", line 46, in __init__
CustomComponentTwo(
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/__main__.py", line 20, in __init__
gitlab_image = docker.get_registry_image(name="[...]", opts=default_invoke_options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/.venv/lib/python3.12/site-packages/pulumi_docker/get_registry_image.py", line 114, in get_registry_image
__ret__ = pulumi.runtime.invoke('docker:index/getRegistryImage:getRegistryImage', __args__, opts=opts, typ=GetRegistryImageResult).value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/.venv/lib/python3.12/site-packages/pulumi/runtime/invoke.py", line 127, in invoke
return _sync_await(awaitableInvokeResult)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/.venv/lib/python3.12/site-packages/pulumi/runtime/sync_await.py", line 66, in _sync_await
return fut.result()
^^^^^^^^^^^^
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/.venv/lib/python3.12/site-packages/pulumi/runtime/invoke.py", line 357, in wait_for_fut
return await asyncio.ensure_future(do_rpc())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/fbaumann/projects/poc/pulumi-docker-provider/.venv/lib/python3.12/site-packages/pulumi/runtime/invoke.py", line 353, in do_rpc
raise error
Exception: invoke of docker:index/getRegistryImage:getRegistryImage failed: invocation of docker:index/getRegistryImage:getRegistryImage returned an error: invoking docker:index/getRegistryImage:getRegistryImage: 1 error occurred:
* Got error when attempting to fetch image version [...] from registry: Got bad response from registry: 401 Unauthorized then I downgraded the pulumi-docker provider to pulumi preview --diff
Please choose a stack, or create a new one: default
Enter your passphrase to unlock config/secrets
(set PULUMI_CONFIG_PASSPHRASE or PULUMI_CONFIG_PASSPHRASE_FILE to remember):
Enter your passphrase to unlock config/secrets
Previewing update (default):
~ custom:component:one: (refresh)
[urn=urn:pulumi:default::test-pulumi-docker-provider::custom:component:one::test-gitlab-docker]
~ custom:component:two: (refresh)
[urn=urn:pulumi:default::test-pulumi-docker-provider::custom:component:one$custom:component:two::this]
~ pulumi:pulumi:Stack: (refresh)
[urn=urn:pulumi:default::test-pulumi-docker-provider::pulumi:pulumi:Stack::test-pulumi-docker-provider-default]
~ pulumi:providers:docker: (refresh)
[id=9a5ecf06-6282-47f3-916d-ec3161e854f6]
[urn=urn:pulumi:default::test-pulumi-docker-provider::pulumi:providers:docker::this]
~ docker:index/remoteImage:RemoteImage: (refresh)
[id=sha256:c58b1e54efd8db1b900a6fb5ec07236c1b326c1cd463f45bdd79709f52a7377e[...]]
[urn=urn:pulumi:default::test-pulumi-docker-provider::custom:component:one$custom:component:two$docker:index/remoteImage:RemoteImage::this]
[provider=urn:pulumi:default::test-pulumi-docker-provider::pulumi:providers:docker::this::9a5ecf06-6282-47f3-916d-ec3161e854f6]
pulumi:pulumi:Stack: (same)
[urn=urn:pulumi:default::test-pulumi-docker-provider::pulumi:pulumi:Stack::test-pulumi-docker-provider-default]
~ pulumi:providers:docker: (update)
[id=9a5ecf06-6282-47f3-916d-ec3161e854f6]
[urn=urn:pulumi:default::test-pulumi-docker-provider::pulumi:providers:docker::this]
registryAuth: [secret]
~ version : "4.6.0" => "4.5.8"
Resources:
~ 1 to update
4 unchanged |
Thanks @asvinours, I was able to reproduce it with your example! The problem arises under the following circumstances:
What triggers this behavior under the hood is that pulumi creates a provider during the refresh phase using the credentials from state ( This is definitely a regression introduced in #1327, I'm sorry! I'll pick this up right away. For other users running into this issue, please either use an earlier version (e.g. v4.5.8) or run refresh separately from |
We've reverted the offending change. The release should go out shortly |
This issue has been addressed in PR #1341 and shipped in release v4.6.1. |
@asvinours the fix has been shipped. Could you verify whether everything works as expected again? |
I upgraded to 4.6.1 and ran the gitlab pipeline couple of times and it is successful now. Thank you for the quick fix 🙏 |
Describe what happened
A user reported that v4.6.0 of the provider seems to have a bug in how authentication is working during preview with refresh.
They've configured the provider with temporary tokens exposed via env variables:
With the provider
< 4.6.0
, everything seems fine, but once they upgrade, the pulumi preview job with automatic refresh keeps failing with a 401 error when trying to connect to the gitlab registry:Sample program
n/a
Log output
No response
Affected Resource(s)
No response
Output of
pulumi about
tbd
Additional context
No response
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).
The text was updated successfully, but these errors were encountered: