瀏覽代碼

feat(api): add debug output for healthcheck timestamp update

Peter Thomassen 5 年之前
父節點
當前提交
4435ca1c1e
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      api/desecapi/management/commands/chores.py

+ 6 - 3
api/desecapi/management/commands/chores.py

@@ -23,25 +23,28 @@ class Command(BaseCommand):
 
     @staticmethod
     def update_healthcheck_timestamp():
+        name = 'internal-timestamp.desec.test'
         try:
-            domain = models.Domain.objects.get(name='internal-timestamp.desec.test')
+            domain = models.Domain.objects.get(name=name)
         except models.Domain.DoesNotExist:
             # Fail silently. If external alerting is configured, it will catch the problem; otherwise, we don't need it.
+            print(f'{name} zone is not configured; skipping TXT record update')
             return
 
         instances = domain.rrset_set.filter(subname='', type='TXT').all()
         timestamp = int(time.time())
+        content = f'"{timestamp}"'
         data = [{
             'subname': '',
             'type': 'TXT',
             'ttl': '3600',
-            'records': [f'"{timestamp}"']
+            'records': [content]
         }]
         serializer = serializers.RRsetSerializer(instances, domain=domain, data=data, many=True, partial=True)
         serializer.is_valid(raise_exception=True)
         with PDNSChangeTracker():
             serializer.save()
-
+        print(f'TXT {name} updated to {content}')
 
     def handle(self, *args, **kwargs):
         self.delete_expired_captchas()