Hello Pulumi Team, when trying to delete a Cloudfl...
# general
c
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
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
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
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
I already tried with
pulumi refresh
and
pulumi refresh --target "**<domain_name"
and it didn’t resolve the problem
d
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
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
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
Odd that both displays show 1427 unchanged. I wonder if the --target is causing an issue, can you run without --target?
c
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
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
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
They're both part of the same repo
Oh that's interesting. The update can't find the URN itself
e
--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
sure, I’ll remove
--target
for now. Thank you for your suggestion