https://pulumi.com logo
#general
Title
# general
c

creamy-monkey-35142

09/06/2023, 3:13 AM
Hello Pulumi Team, when trying to delete a Cloudflare dns record with command
pulumi up
, at preview state show 1 resource will be deleted but in apply state return nothing change, how I can troubleshoot why record didn’t deleted?
after ran command
Copy code
CLOUDFLARE_API_CLIENT_LOGGING=true TF_LOG=TRACE pulumi up -y --target "**<redacted>" --logtostderr --logflow -v=9 --skip-preview 2> out.txt
I have noticed that if I add into command
--skip-preview
then resource will be deleted, but if I remove
--skip-preview
then there is no resource deleted, no delete action recorded in log, Someone please help me take a look 😞
d

dry-keyboard-94795

09/07/2023, 11:35 AM
CF Records seem to delete fine for us with preview enabled. Do you have an example of how you're using the Record resource?
c

creamy-monkey-35142

09/07/2023, 11:42 AM
yeah, I don’t know why too, the code working fine before and the last change in code is 4 months ago =.=!
I have a json file which store parameter of record like
Copy code
{
  "record-name": {
    "value": "example",
    "type": "A",
    "proxied": true
  }
}
then in python code, it read on every json entry as `value`and call to function
Cloudfare.Record(**value)
, to remove a record, I need go to this json file and remove an element
without
--skip-preview
I can see events `DELETE`in log
but didn’t see it when remove
--skip-preview
the command
pulumi stack --show-urns
didn’t show urn of record anymore but record still exist on Cloudflare
d

dry-keyboard-94795

09/07/2023, 11:51 AM
For that one, you should be able to do a
pulumi refresh
, and it'll fix the state. Does trying to remove a record work after the refresh?
c

creamy-monkey-35142

09/07/2023, 11:52 AM
I already tried with
pulumi refresh
and
pulumi refresh --target "**<domain_name"
and it didn’t resolve the problem
d

dry-keyboard-94795

09/07/2023, 12:01 PM
outside of making sure everything is up to date, would need to know more about how
Record
is called within the stack. I've seen some people make resources within
.apply()
calls of an Output, which I can see causing issues like what you're seeing.
does it delete without
--target
? I've faced problems with that before (wish I could use it in production)
c

creamy-monkey-35142

09/07/2023, 12:02 PM
let me try without
--target
meanwhile, here the function
Record
will be called
it’ll call
DynamicFunction
at utils.py with
Copy code
def DynamicFunction(self, values, function_name = None):
        """
        Provide a dynamic function to call cloudflare class like cloudflare.TeamsList
        """
        # Get the function name from a calling module
        if function_name is None:
            function_name = inspect.stack()[1].function
        # get attr of function name from Cloudflare
        execute = getattr(cloudflare, function_name) 
        # **values to pass dictionary items as function arguments 
        result = execute(**values)
        return result
aka
Copy code
execute = getattr(cloudflare, Record) 
        # **values to pass dictionary items as function arguments 
        result = execute(**values)
equal to
Cloudflare.Record(**value)
d

dry-keyboard-94795

09/07/2023, 12:19 PM
definitely an interesting approach to generalise the record. At this point, it'd be worth launching a debugger to step through the code that's run.
pdb
doesn't work, but you should be able to setup debugpy and have vscode attach to it
e

echoing-dinner-19531

09/07/2023, 12:52 PM
Odd that both displays show 1427 unchanged. I wonder if the --target is causing an issue, can you run without --target?
c

creamy-monkey-35142

09/08/2023, 3:25 AM
Hi @echoing-dinner-19531 and @dry-keyboard-94795, here is result without --target it work as expected
after ran command above, I also try again with --target and the issue occurred
image.png
image.png
d

dry-keyboard-94795

09/08/2023, 6:42 AM
So, looks like an issue with
--target
then
You'll need to raise an issue on github. I'm not seeing a similar issue having been raised before
It's worth checking: • Does this happen on the current version of pulumi (there were some changes in v3.70 that seem relavant) • Does this happen if you specify the full URN of the record being deleted instead of the wildcard
You can find the URN by specifying
--diff
on a preview
c

creamy-monkey-35142

09/08/2023, 7:01 AM
the issue happened on older version (I didn’t remember) and current version on my computer is
v3.81.0
, issue also on Github Actions pulumi/actions@ddcac955fd004d13bc60bd0bdbbc389b1f524216 (suggested by @echoing-dinner-19531 before https://pulumi-community.slack.com/archives/C84L4E3N1/p1675078507601099)
I also tried with
pulumi/actions@v4.4.0
too but issue still exist
I’m not sure issue from pulumi or pulumi-python
Nothing deleted when specify the full URN
d

dry-keyboard-94795

09/08/2023, 7:09 AM
They're both part of the same repo
Oh that's interesting. The update can't find the URN itself
e

echoing-dinner-19531

09/08/2023, 7:55 AM
--targets is known to have some issues at the moment, the latest release should have helped a bit but I'm currently working on quite possibly a complete overhaul of them. For now I would recommend trying to make your workflows not need them.
c

creamy-monkey-35142

09/08/2023, 7:56 AM
sure, I’ll remove
--target
for now. Thank you for your suggestion