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

Refresh command does not detect differences in letter casing for resource name #3629

Open
cermakp opened this issue Sep 27, 2024 · 12 comments
Open
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec

Comments

@cermakp
Copy link

cermakp commented Sep 27, 2024

What happened?

When there is a difference in letter casing in a resource's name, the pulumi refresh command does not detect it. The pulumi refresh command should recognize such changes and synchronize the stack with the resource name in Azure.

Example

  1. Define a Log Analytics workspace in Azure named "lawTestService".
  2. Define the stack containing the same resource, but with different letter casing in the workspace name, such as:
    "workspaceName": "lawtestservice".
  3. Run pulumi refresh in the command line – no changes are detected.

Expected behavior
The workspace name in the stack should be overwritten to "lawTestService" and synchronized with the name defined in the Azure provider.

Output of pulumi about

running 'dotnet build -nologo .'
  Determining projects to restore...

  All projects are up-to-date for restore.

C:\Users\cerma\.nuget\packages\microsoft.codeanalysis.netanalyzers\7.0.4\build\Microsoft.CodeAnalysis.NetAnalyzers.targets(593,5): warning : The .NET SDK has newer analyzers with version '8.0.0' than what version '7.0.4' of 'Microsoft.CodeAnalysis.NetAnaly
zers' package provides. Update or remove this package reference. [C:\Sources\NetCoreBoilerplate\infrastructure\Ori.NetCoreBoilerplate.Infrastructure\Ori.NetCoreBoilerplate.Infrastructure.csproj]

  Ori.NetCoreBoilerplate.Infrastructure -> C:\Sources\NetCoreBoilerplate\infrastructure\Ori.NetCoreBoilerplate.Infrastructure\bin\Debug\net8.0\Ori.NetCoreBoilerplate.Infrastructure.dll



Build succeeded.


C:\Users\cerma\.nuget\packages\microsoft.codeanalysis.netanalyzers\7.0.4\build\Microsoft.CodeAnalysis.NetAnalyzers.targets(593,5): warning : The .NET SDK has newer analyzers with version '8.0.0' than what version '7.0.4' of 'Microsoft.CodeAnalysis.NetAnalyzers' package provides. Update or remove this package reference. [C:\Sources\NetCoreBoilerplate\infrastructure\Ori.NetCoreBoilerplate.Infrastructure\Ori.NetCoreBoilerplate.Infrastructure.csproj]
    1 Warning(s)
    0 Error(s)



Time Elapsed 00:00:00.86



Workload updates are available. Run `dotnet workload list` for more information.

'dotnet build -nologo .' completed successfully
CLI
Version      3.133.0
Go Version   go1.23.1
Go Compiler  gc

Plugins
KIND      NAME          VERSION
resource  azure         5.78.0
resource  azure-native  2.42.1
resource  azuread       5.50.0
resource  azuredevops   3.1.1
language  dotnet        unknown

Host
OS       Microsoft Windows 11 Pro
Version  10.0.22631 Build 22631
Arch     x86_64

This project is written in dotnet: executable='C:\Program Files\dotnet\dotnet.exe' version='8.0.402'

Current Stack: organization/NcBoilerplateInfrastructureStack/we.uat

TYPE                                                      URN
pulumi:pulumi:Stack                                       urn:pulumi:we.uat::NcBoilerplateInfrastructureStack::pulumi:pulumi:Stack::NcBoilerplateInfrastructureStack-we.uat
pulumi:providers:azure-native                             urn:pulumi:we.uat::NcBoilerplateInfrastructureStack::pulumi:providers:azure-native::azure-native-tenant-e46bc88e-1a4b-44ff-a158-1b9f7eb4561e-subscription-bf92e86b-7b0b-4d78-8785-c104ce8ffaf4
pulumi:providers:azure                                    urn:pulumi:we.uat::NcBoilerplateInfrastructureStack::pulumi:providers:azure::azure-tenant-e46bc88e-1a4b-44ff-a158-1b9f7eb4561e-subscription-bf92e86b-7b0b-4d78-8785-c104ce8ffaf4
azure-native:resources:ResourceGroup                      urn:pulumi:we.uat::NcBoilerplateInfrastructureStack::azure-native:resources:ResourceGroup::rgncboilerplateuatwe-online
azure-native:operationalinsights:Workspace                urn:pulumi:we.uat::NcBoilerplateInfrastructureStack::azure-native:operationalinsights:Workspace::lawncboilerplateuatwe-online


Found no pending operations associated with we.uat

Backend
Name           Pavel-PC
URL            azblob://frameworks
User           PAVEL-PC\cerma
Organizations
Token type     personal

Dependencies:
NAME                           VERSION
Ori.Common.Analyzers.CSharp    7.0.2
Ori.Common.Analyzers.Security  5.0.1
Ori.Common.Pulumi              0.1.35

Additional context

Although pulumi refresh does not detect changes in letter casing, pulumi up does and attempts to replace the resource.

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

@cermakp cermakp added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Sep 27, 2024
@Frassle Frassle transferred this issue from pulumi/pulumi Sep 27, 2024
@danielrbradley
Copy link
Member

@cermakp thanks for writing this up. Please could you provide a minimal example program of the "before" and "after" programs that we can run to reproduce the issue and use as a basis of the investigation.

It's quite likely that this behaviour is coming from the upstream terraform provider though, so might be best to raise an issue on their side. There have been a number of new versions since v5.78.0 (including a major version) which might be worth testing first to see if this has already been addressed.

@danielrbradley danielrbradley added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Sep 30, 2024
@cermakp
Copy link
Author

cermakp commented Oct 1, 2024

Hi @danielrbradley ,

You will find an example of the application here. The program defines a single resource group with a log analytics workspace inside it.

Here are the steps to reproduce the issue:

  1. Create a new stack running the program. The log analytics workspace name will be lawPulumiRefreshSample
    Image

  2. Open the stack definition file and manually change the workspace name to lawPulumiRefreshSAMPLE. This simulates a scenario where the resource name differs between the stack and Azure.
    Image

  3. Run the pulumi refresh command in the terminal. You'll notice that the refresh command does not detect the difference in letter casing.
    Image

  4. Run the pulumi up command in the terminal. The up command correctly detects the letter casing difference.
    Image

Expected behaviour

Command pulumi refresh should detect the difference in letter casing and synchronize the name from Azure to the stack.

@pulumi-bot pulumi-bot added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels Oct 1, 2024
@danielrbradley
Copy link
Member

Thanks for the extra detail. This is very helpful.

Firstly, it looks like you're using the Natvie provider rather than the classic provider? If so, I'll transfer this issue.

I think this might be related to refresh only affecting outputs and not the inputs, but will likely need further diagnosis to understand the scenario fully.

How does this currently impact your use of the tool? It looks like doing another up resolves the discrepancy?

@danielrbradley danielrbradley added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Oct 4, 2024
@cermakp
Copy link
Author

cermakp commented Oct 7, 2024

Firstly, it looks like you're using the Natvie provider rather than the classic provider? If so, I'll transfer this issue.

Yes, you are correct, we are using Azure native provider as it is recommended in Pulumi documentation for all new projects.

How does this currently impact your use of the tool? It looks like doing another up resolves the discrepancy?

Currently, our import process generates the resources for the import procedure, which initializes the stack. After this step, we run pulumi refresh to synchronize the stack with the current resource configuration in Azure. Finally, we execute pulumi up. When stack resources are initialized with different letter casing (for example), pulumi up attempts to replace the existing resource. We want to avoid replacing resources in Azure.

@pulumi-bot pulumi-bot added needs-triage Needs attention from the triage team and removed awaiting-feedback Blocked on input from the author labels Oct 7, 2024
@danielrbradley danielrbradley transferred this issue from pulumi/pulumi-azure Oct 7, 2024
@danielrbradley
Copy link
Member

Thanks for confirming.

Going back to your original scenario:

  1. Define a Log Analytics workspace in Azure named "lawTestService".
  2. Define the stack containing the same resource, but with different letter casing in the workspace name, such as: "workspaceName": "lawtestservice".
  3. Run pulumi refresh in the command line – no changes are detected.

Could you clarify these steps for my understanding :

  1. Create a Log Analytics workspace manually via the Azure Portal named "lawTestService"
  2. Write a Pulumi program containing a workspace with exactly the same properties, except for the casing of the name.
  3. Are you then performing an import via code, or an import via the CLI?
  4. Once the initial import is complete, performing a refresh shows no changes.

I think this likely stems from the fact that Azure doesn't always pass back the exact values that we passed as inputs, so we have some mechanisms for accounting for this to avoid perminant diffs.

The other workaround that should be fine here (apart from editing the state) would be re-importing with the correct case defined in the code.

@danielrbradley danielrbradley added impact/usability Something that impacts users' ability to use the product easily and intuitively and removed needs-triage Needs attention from the triage team labels Oct 8, 2024
@danielrbradley danielrbradley changed the title Pulumi refresh does not detect resource name changes due to letter casing differences Import with wrong case not fixable via refresh Oct 8, 2024
@danielrbradley
Copy link
Member

danielrbradley commented Oct 8, 2024

This might be resolved via #3633

@cermakp
Copy link
Author

cermakp commented Oct 8, 2024

Could you clarify these steps for my understanding :

  1. Create a Log Analytics workspace manually via the Azure Portal named "lawTestService"
  2. Write a Pulumi program containing a workspace with exactly the same properties, except for the casing of the name.
  3. Are you then performing an import via code, or an import via the CLI?
  4. Once the initial import is complete, performing a refresh shows no changes.

Yes, you are correct about the steps. Regarding the import, we are using a CLI tool for that.

However, the provided example program is unrelated to the import process itself. It simply demonstrates that the refresh command does not detect any changes in letter casing of the resources's name.

However, as you can see, the preview command is able to detect such changes, so I believe this detection is missing in the refresh command

@cermakp
Copy link
Author

cermakp commented Oct 9, 2024

This might be resolved via #3633

It does not seem that it is related to the issue with refresh

@cermakp
Copy link
Author

cermakp commented Oct 9, 2024

This might be resolved via #3633

I have just tried the latest version, including the fix to the issue you mentioned, but there is no difference. The issue with refresh command still exists.

@cermakp
Copy link
Author

cermakp commented Oct 17, 2024

Hi @danielrbradley, any news?

@cermakp
Copy link
Author

cermakp commented Nov 7, 2024

Hello, is there any progress?

@cermakp cermakp changed the title Import with wrong case not fixable via refresh Refresh command does not detect differences in letter casing for resource name Nov 7, 2024
@danielrbradley
Copy link
Member

Thanks for confirming those details. I think we've now captured all the relevant details in which will let us investigate the root cause.

The next step will likely be to reproduce the issue under a debugger to then write up a design for a fix. I can't currently give an ETA on that as this will need to be prioritised for work alongside other customer requests and ongoing maintenance work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/usability Something that impacts users' ability to use the product easily and intuitively kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

3 participants