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

Canonicalize provider version during default provider lookup #16109

Merged
merged 4 commits into from May 6, 2024

Conversation

EronWright
Copy link
Contributor

@EronWright EronWright commented May 2, 2024

Description

This PR addresses a problem that leads to two default providers for a given package+version. The problem occurs when given a combination of unversioned and versioned provider requests, as can occur in multi-language programs.

The fix is as follows: given an unversioned provider request, apply the default version before looking into the provider cache.

More background: #2767

Fixes #16108

Example

Given the example program from #16108 plus this fix, the stack state has one provider as expected:

{
    "urn": "urn:pulumi:dev::issue-1939-nodejs::pulumi:providers:kubernetes::default_4_10_0",
    "custom": true,
    "id": "c19b65b0-dd5a-432f-8c75-d7544de782ec",
    "type": "pulumi:providers:kubernetes",
    "inputs": {
        "version": "4.10.0"
    },
    "outputs": {
        "version": "4.10.0"
    },
    "created": "2024-05-02T21:22:09.72166Z",
    "modified": "2024-05-02T21:22:09.72166Z"
}
{
    "urn": "urn:pulumi:dev::issue-1939-nodejs::kubernetes:yaml/v2:ConfigGroup$kubernetes:core/v1:ConfigMap::example:eron/example",
    "custom": true,
    "id": "eron/example",
    "type": "kubernetes:core/v1:ConfigMap",
    "parent": "urn:pulumi:dev::issue-1939-nodejs::kubernetes:yaml/v2:ConfigGroup::example",
    "provider": "urn:pulumi:dev::issue-1939-nodejs::pulumi:providers:kubernetes::default_4_10_0::c19b65b0-dd5a-432f-8c75-d7544de782ec",
    "propertyDependencies": {
        "apiVersion": [],
        "kind": [],
        "metadata": []
    },
}

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@EronWright EronWright requested a review from tgummerer May 2, 2024 21:49
@pulumi-bot
Copy link
Contributor

pulumi-bot commented May 2, 2024

Changelog

[uncommitted] (2024-05-03)

Bug Fixes

  • [engine] Normalize provider version during default provider lookup
    #16109

Copy link
Contributor Author

@EronWright EronWright May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the "normalization" logic out of newRegisterDefaultProviderEvent into a normalizeProviderRequest function, so that it could be executed before the provider cache is checked.

Note that the logic will execute more often, i.e. for cache hits and for misses, and so I simplified the logging a little bit.

@EronWright EronWright marked this pull request as ready for review May 2, 2024 22:46
@EronWright EronWright requested a review from a team as a code owner May 2, 2024 22:46
@EronWright EronWright added this pull request to the merge queue May 3, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 3, 2024
@tgummerer tgummerer added this pull request to the merge queue May 6, 2024
Merged via the queue into master with commit 89d3467 May 6, 2024
49 checks passed
@tgummerer tgummerer deleted the issue-16108 branch May 6, 2024 09:30
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

Successfully merging this pull request may close these issues.

Pulumi loads multiple default providers for same package
4 participants