diff --git a/dns_updater/workers/zone_worker.py b/dns_updater/workers/zone_worker.py index f95a8f3..a211029 100644 --- a/dns_updater/workers/zone_worker.py +++ b/dns_updater/workers/zone_worker.py @@ -2,6 +2,7 @@ from __future__ import print_function from dns_updater.utils.updater_util import * +import time TMP_DIR = CONF.etc.tmp_dir ZONE_DIR = CONF.bind_conf.zone_dir @@ -71,7 +72,7 @@ def handler(): tmp_zonefile_path = make_zone_file_from_dnsdb(name) if not is_need_update_zone(tmp_zonefile_path, current_zonefile_path): - return + continue checkzone(name, tmp_zonefile_path) zone_file_dict[name] = { 'src': tmp_zonefile_path, @@ -86,8 +87,10 @@ def handler(): reload_and_backup_zones(zone_file_dict) DnsdbApi.update_zone_serial(name) log.info('update_zone_serial') - return True + time.sleep(1) except UpdaterErr as e: log.error(e.message) + send_alarm_email(u'zone %s 更新失败\n原因: %s' % (name, e.message)) except Exception as e: log.exception(e) + send_alarm_email(u'zone %s 更新失败\n原因: %s' % (name, e)) diff --git a/dnsdb_common/dal/view_record.py b/dnsdb_common/dal/view_record.py index fe9c612..989a82a 100644 --- a/dnsdb_common/dal/view_record.py +++ b/dnsdb_common/dal/view_record.py @@ -218,7 +218,7 @@ def get_view_domain_info(domain): return { 'domain_name': domain, - 'is_migrate': ViewRecordDal.is_migrate_domain(domain), + 'is_migrate': ViewRecordDal.is_migrate_domain(view_domain), 'cnames': cdn_conf, 'rooms': room_confs } @@ -435,7 +435,7 @@ def insert_view_domain(username, domain_name, cnames, rooms): )) # 新增域名 更新dnsmaster2 ViewRecordDal.increase_serial_num(VIEW_ZONE) - ViewRecordDal.increase_serial_num(cname_zone) + # ViewRecordDal.increase_serial_num(cname_zone) @staticmethod def update_view_domain(username, domain_name, cnames, rooms): @@ -577,16 +577,16 @@ def update_view_domain_state(domain_name, isp_dict): @staticmethod @commit_on_success def delete_view_domain(domain_name): - session = db.session - record = DnsRecord.query.filter_by(record=domain_name).all() - if len(record): - raise BadParam('view domain has cname record: %s' % domain_name, - msg_ch=u'请先删除域名的cname记录') - - zone = ViewRecordDal.get_view_domain_zone(domain_name) - session.query(ViewRecords).filter_by(domain_name=domain_name).delete() - session.query(ViewDomainNameState).filter_by(domain_name=domain_name).delete() - session.query(ViewDomainNames).filter_by(domain_name=domain_name).delete() - - for update_zone in [zone, VIEW_ZONE]: + need_update = [VIEW_ZONE] + + need_update.append(ViewRecordDal.get_view_domain_zone(domain_name)) + ViewRecords.query.filter_by(domain_name=domain_name).delete() + ViewDomainNameState.query.filter_by(domain_name=domain_name).delete() + ViewDomainNames.query.filter_by(cname=domain_name).delete() + + record = DnsRecord.query.filter_by(record=domain_name).first() + need_update.append(record.zone_name) + db.session.delete(record) + + for update_zone in need_update: ViewRecordDal.increase_serial_num(update_zone)