Skip to content

Commit

Permalink
Global Catalog: remove DNS record only when last instance is removed
Browse files Browse the repository at this point in the history
During the GC uninstallation, all the GC-related DNS records are
deleted, even though another master may be providing the GC role.
Delete the records only when the last instance of GC is removed.

If the deletion fails for an unexpected reason, do not raise the
exception but continue the uninstallation after logging the error.

Fixes: #63
  • Loading branch information
flo-renaud authored and abbra committed Mar 16, 2021
1 parent 90ff931 commit ec09f27
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion ipaserver/install/gcinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
is_ds_running,
)
from ipaserver.install.adtrustinstance import make_netbios_name
from ipaserver.servroles import ENABLED
from ipapython.dnsutil import DNSName
from lib389 import DirSrv
from lib389.idm.ipadomain import IpaDomain
Expand Down Expand Up @@ -755,6 +756,10 @@ def __remove_gc_dns_records(self):
pass
except IPADomainIsNotManagedByIPAError:
pass
except Exception as e:
# print an error msg but do not prevent uninstallation
logger.error("Failed to delete DNS record for GC %s: %s",
record[0].to_text(), e)

def apply_updates(self):
# Question: do we need to support loading schema files from
Expand Down Expand Up @@ -793,7 +798,15 @@ def uninstall(self):
"service principal manually.")
else:
# Remove the DNS records for global catalog
self.__remove_gc_dns_records()
# if it was the last instance
try:
api.Command.server_role_find(
role_servrole=u'Global Catalog server',
status=ENABLED
)
except errors.EmptyResult:
# This server was the last GC, delete DNS records
self.__remove_gc_dns_records()

# Remove the service container entry
self.ldap_remove_service_container(self.serverid, api.env.host,
Expand Down

0 comments on commit ec09f27

Please sign in to comment.