Skip to content

Commit febccb2

Browse files
author
guoli.luo
committed
update view domain migrate
1 parent 2b09ab3 commit febccb2

2 files changed

Lines changed: 19 additions & 16 deletions

File tree

dns_updater/workers/zone_worker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import print_function
44
from dns_updater.utils.updater_util import *
5+
import time
56

67
TMP_DIR = CONF.etc.tmp_dir
78
ZONE_DIR = CONF.bind_conf.zone_dir
@@ -71,7 +72,7 @@ def handler():
7172

7273
tmp_zonefile_path = make_zone_file_from_dnsdb(name)
7374
if not is_need_update_zone(tmp_zonefile_path, current_zonefile_path):
74-
return
75+
continue
7576
checkzone(name, tmp_zonefile_path)
7677
zone_file_dict[name] = {
7778
'src': tmp_zonefile_path,
@@ -86,8 +87,10 @@ def handler():
8687
reload_and_backup_zones(zone_file_dict)
8788
DnsdbApi.update_zone_serial(name)
8889
log.info('update_zone_serial')
89-
return True
90+
time.sleep(1)
9091
except UpdaterErr as e:
9192
log.error(e.message)
93+
send_alarm_email(u'zone %s 更新失败\n原因: %s' % (name, e.message))
9294
except Exception as e:
9395
log.exception(e)
96+
send_alarm_email(u'zone %s 更新失败\n原因: %s' % (name, e))

dnsdb_common/dal/view_record.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def get_view_domain_info(domain):
218218

219219
return {
220220
'domain_name': domain,
221-
'is_migrate': ViewRecordDal.is_migrate_domain(domain),
221+
'is_migrate': ViewRecordDal.is_migrate_domain(view_domain),
222222
'cnames': cdn_conf,
223223
'rooms': room_confs
224224
}
@@ -435,7 +435,7 @@ def insert_view_domain(username, domain_name, cnames, rooms):
435435
))
436436
# 新增域名 更新dnsmaster2
437437
ViewRecordDal.increase_serial_num(VIEW_ZONE)
438-
ViewRecordDal.increase_serial_num(cname_zone)
438+
# ViewRecordDal.increase_serial_num(cname_zone)
439439

440440
@staticmethod
441441
def update_view_domain(username, domain_name, cnames, rooms):
@@ -577,16 +577,16 @@ def update_view_domain_state(domain_name, isp_dict):
577577
@staticmethod
578578
@commit_on_success
579579
def delete_view_domain(domain_name):
580-
session = db.session
581-
record = DnsRecord.query.filter_by(record=domain_name).all()
582-
if len(record):
583-
raise BadParam('view domain has cname record: %s' % domain_name,
584-
msg_ch=u'请先删除域名的cname记录')
585-
586-
zone = ViewRecordDal.get_view_domain_zone(domain_name)
587-
session.query(ViewRecords).filter_by(domain_name=domain_name).delete()
588-
session.query(ViewDomainNameState).filter_by(domain_name=domain_name).delete()
589-
session.query(ViewDomainNames).filter_by(domain_name=domain_name).delete()
590-
591-
for update_zone in [zone, VIEW_ZONE]:
580+
need_update = [VIEW_ZONE]
581+
582+
need_update.append(ViewRecordDal.get_view_domain_zone(domain_name))
583+
ViewRecords.query.filter_by(domain_name=domain_name).delete()
584+
ViewDomainNameState.query.filter_by(domain_name=domain_name).delete()
585+
ViewDomainNames.query.filter_by(cname=domain_name).delete()
586+
587+
record = DnsRecord.query.filter_by(record=domain_name).first()
588+
need_update.append(record.zone_name)
589+
db.session.delete(record)
590+
591+
for update_zone in need_update:
592592
ViewRecordDal.increase_serial_num(update_zone)

0 commit comments

Comments
 (0)