Hi, I have an issue where when running a refresh ...
# azure
i
Hi, I have an issue where when running a refresh preview pulumi states it will recreate an azure service bus even though there are no changes to the azure service bus. However, when I create from new and refresh it is as expected. The stacks where it wants to replace azure service bus has been deployed for months and I am wondering if this could be because of a change from azure-native v1 to v2 but when previewing and deploying there was no issue with replacing etc. Does anyone have any ideas on what the issue could be. I see this output on the queues for the azure service bus and wondering if this why pulumi thinks it needs to recreate everything: namespaceName : "{string value}" => outputstring This is using pulumi version: v3.122.0 but looking back it first seemed to occur in v3.106.0.
g
We dont have issues with re-creation, but it does always tend to update the privateEndpointConnection values
a
What are your input parameters? Are you only providing resourceName or also namespaceName?
If you only provide resourceName Pulumi will go ahead and append a random suffix to the actual name: https://www.pulumi.com/docs/concepts/resources/names/ If this is the case, you can simply provide the current actual name of the namespace with the namespaceName parameter.
i
Using c# and code is essentially the same as in the doc snippet so passing in a string as the namespace and then setting the namespace to the same value so no suffix is being appended to actual name.
a
What parameters does
pulumi pre --diff --refresh
show changing which are triggering recreation?
i
Copy code
+-azure-native:servicebus:Namespace: (replace)
        [id={id}]
        [urn={urn}]
        [provider={provider}]
      - disableLocalAuth          : false
      - minimumTlsVersion         : "1.0"
      - privateEndpointConnections: []
      - zoneRedundant             : false
debug: Fields to assign: ["zoneRedundant","alternateName","privateEndpointConnections","tags","type","updatedAt","publicNetworkAccess","urn","createdAt","systemData","sku","location","provisioningState","serviceBusEndpoint","identity","metricId","minimumTlsVersion","id","status","disableLocalAuth","encryption","name"]
debug: Registering resource start: t=azure-native:servicebus:Namespace, name={name}, custom=True, remote=False
debug: Preparing resource: t=azure-native:servicebus:Namespace, name={name}, custom=True, remote=False
debug: Prepared resource: t=azure-native:servicebus:Namespace, name={name}, custom=True, remote=False
a
ZoneRedundant
is the only parameter there that will trigger recreation (if changed)
i
So using standard sku and don't set
ZoneRedundant
in code. I can have a look at setting to false explicitly to see if this clears it.
Thanks, that seems to have to have fixed and no longer trying to recreate. Not sure why needs to set value now but maybe issue with defaulting values for v1 and v2 being null vs false.
Spoke too soon, this now wants to replace when previewing.
a
Can you see which Azure API version was being used for
servicebus.Namespace
prior to updating azure-native to v2?
You could try to import that particular API version if it's also available in the v2 specs
Can you share your code snippet where you define the Namespace?
i
Will have a look re the api version. Main concern was if needing to refresh to get to a desired state (DR drills) and then changing something not impacted etc. But replacing on a deploy is the lesser of 2 evils it it needs to do this.
Where _config.Name is string value and _depedencies values are output<string> from the actual resources created in pulumi
Copy code
var serviceBusNamespace = new Namespace(_config.Name, new()
        {
            NamespaceName = _config.Name,
            Location = _dependencies.ResourceGroupLocation,
            ResourceGroupName = _dependencies.ResourceGroupName,
            Sku = new SBSkuArgs
            {
                Name = SkuName.Standard,
                Tier = SkuTier.Standard
            },
            Tags = _config.Tags
        });
then
ZoneRedundant = false
to fix recreate for refresh but caused recreate on preview, but not for the v2 deployment so think it is something with defaults for that value in v1 and v2 as comparing azure template it is the same for v1 and v2 with exception name for environment etc.
a
So you were running
pulumi refresh
and then
pulumi preview
?What happens when you run
pulumi pre --refresh --diff
i
1. service bus was initially deployed with azure native v1: a. Code from above i.
pulumi preview -diff
shows no changes ii.
pulumi preview --refresh -diff
states that the service bus needs to be recreated b. Adding in ZoneRedundant = false i.
pulumi preview -diff
states that the service bus needs to be recreated ii.
pulumi preview --refresh -diff
shows no changes 2. service bus deployed with azure native v2 a. Code from above i.
pulumi preview -diff
shows no changes ii.
pulumi preview --refresh -diff
shows no changes b. Adding in ZoneRedundant = false i.
pulumi preview -diff
wants to add new property but doesn't recreate ii.
pulumi preview --refresh -diff
wants to add new property but doesn't recreate
a
pulumi preview --refresh -diff
shows no changes
That means it won't make any changes.
If concerned you can create a read-only & delete resource locks from the Portal before running an update
Btw. when you run a Pulumi operation without refresh it's just comparing your code with the current Pulumi state. Refresh queries the Azure API on the actual current state of the resource within Azure.
i
yes but I guess thats the point. Initially deployed didn't touch and now saying if I refresh it will recreate and only for service bus not for any other resources. May be how the zone redundant was set in v1 compared to v2 or azure api change or similar. I think I will just take the hit on deploying and recreate and manage it that way or create another and swap out.
a
But you said running with refresh that it showed no changes?
i
thats if I add the zone redundant = false but then on preview it will recreate, so just shifts the problem from refresh to up. Only for a new infra deployment which is using azure native v2 will not try to recreate for a refresh or up.
a
Then just run
pulumi up --refresh --diff
– if that doesn't show any pending updates to be applied, then you're fine.
I recommend to everybody to add this to Pulumi.yaml
Copy code
options:
  refresh: always
That will default on querying the Azure API on current state before doing any updates (default in Terraform but not Pulumi). This will slow things down a bit but I personally don't like applying changes into the dark...
And like I said, just create read-only & delete locks on the Namespace in the portal and test the update – it will fail if something is actually going to be changed or deleted.