Skip to main content

Api2 delsubdomain does not remove DNS entries?

Comments

7 comments

  • cPanelMichael
    Hello, I'm able to successfully delete a subdomain using the SubDomain::delsubdomain cPanel API 2 function:
    # cpapi2 --user=cptest01 SubDomain delsubdomain domain=twothree.cptest01.com --- cpanelresult: apiversion: 2 data: - reason: "Bind reloading on release using rndc zone: [cptest01.com]\nThe subdomain "twothree.cptest01.com" has been removed." result: 1 event: result: 1 func: delsubdomain module: SubDomain
    Have you tested this function using the command line instead of the script to verify if the issue is isolated to your custom PHP script? Thank you.
    0
  • ds00424
    Thanks for the reply. The API in the posted code returns successfully (result == 1). After it's execution, looking at the cPanel GUI Subdomains tool the subdomain is no longer listed. However, some (not all) of the subdomain's DNS records still exist as viewed Advanced DNS Zone Editor tool (IIRC, subdomain.example.com and www.subdomain.example.com are still listed). Without deleting these subdomain DNS entries, any attempt to again create the subdomain (via cPanel GUI or code) results in error. Steps to reproduce (apologies for not posting this initially):
      ]
    • Create a Subdomain (cPanel GUI or programmatic). See that several DNS records have been created (subdomain.example.com, www.subdomain.example.com, cpcalendars.subdomain.example.com, webdisk.subdomain.example.com, cpcontacts.subdomain.example.com)
    • Delete the subdomain using the api2 interface (as shown in posted PHP code). See that the api result is all good.
    • Via the cPanel GUI SubDomains tool, see that the subdomain is no longer listed
    • Via the cPanel GUI Advanced DNS Zone Editor tool, see that subdomain.example.com and www.subdomain.example.com still exist
    • Via the cPanel GUI Subdomains tools create subdomain.example.com - see that this action fails.
    (If you like, I can go thru the above steps and post results/data/images.) If the subdomain delete is executed from the cPanel GUI Subdomains tool, all is good. I am not familiar with the command line. Will it use the api2 interface? BTW, The posted php is pretty vanilla, follows the docs (AFAICT), and returns a successful result. Thanks. ds00424
    0
  • cPanelMichael
    I am not familiar with the command line. Will it use the api2 interface?

    Yes, the command line method uses the same function. It's documented at:
    0
  • ds00424
    Sorry, been busy with a project. I see: "cPanel Version 56.0 (build 22)" as well as "cPanel Pro 1.0 (RC1)" Created foobar.example.com via cpanel GUI Deleted foobar subdomain via PHP Still see www.foobar.example.com and foobar.example.com in Advanced Zone editor error_log addition during the event: ======================= ==> cpsrvd 11.56.0.22 started ==> cpsrvd: loading security policy....Done ==> cpsrvd: Setting up native SSL support ... Done ==> cpsrvd: transferred port bindings ==> cpsrvd: bound to ports ======================= HTH Will try cli later or tomorrow. For now my code will not only delete the subdomain but then delete the zones that remain. I don't like the zone delete, as it is by line and must be requeried after each delete. Plus this is not threadsafe (or multiprocess safe) due to need to query/delete. I respectfully request the ZoneEdit:remove_zone_record api be by Name and not line number. That would make things more straight forward and safe. Thanks for looking into this. Much appreciated.
    0
  • ds00424
    Deleting via CLI give same result as posted
    cpapi2 --user=cpuser SubDomain delsubdomain domain=foobar.example.com
    Give successful result:
    cpanelresult: apiversion: 2 data: - reason: The subdomain "foobar.mydbcx.net" result: 1 event: result: 1 func: delsubdomain module: SubDomain
    Via Subdomains tool, foobar.example.com is not shown However, via Advanced Zone Editor, foobar.example.com and www.foobar.example.com remain Now here is a thought. (This may be a red herring) When this VPS was originally set up, the hosting provider set the account and cpanel user to (something like) "businessna6". For various reasons I won't get into, I asked them to change it to "businessname". Instead they led me thru steps creating another cpanel account named "businessname" that can control the system and along the way set a temp domain name (I think for busnessna6 - but it was over a year ago). All of my cpanel actions have been using cpuser "businessname" So I tried: Via the cpanel "businessname" account, created foobar.example.com via CLI with cpuser "businessna6" delete subdomain I get lots of error output and an api return of:
    cpanelresult: apiversion: 2 data: - reason: subdomain 'foobar.example.com.example-temp.com' does not exist for user 'businessna6' result: 0 error: subdomain 'foobar.example.com.example-temp.com' does not exist for user 'businessna6' event: result: 1 func: delsubdomain module: SubDomain
    Again, I do not know if this is relevant to the issue at hand, but thought I would mention it as it is probably different than the norm. Thanks.
    0
  • cPanelMichael
    Could you open a support ticket using the link in my signature so we can take a closer look? You can post the ticket number here so we can update this thread with the outcome. Thank you.
    0
  • cPanelMichael
    Hello @ds00424, I've not seen any additional feedback to this thread. I'm marking this thread as resolved, however feel free to let us know if you require additional assistance, or to let us know the ticket number of the ticket you opened. Thank you.
    0

Please sign in to leave a comment.