Merge pull request #2515 from vepkenez/terrence-stamp

When rendering /status, don't fail, but log on StampNotSigned
pull/2523/head
Derek Pierre 2021-01-14 09:15:58 -05:00 committed by GitHub
commit ff7a39f26b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -0,0 +1 @@
Gentler handling of unsigned stamps from stranger Ursulas on status endpoint

View File

@ -1331,10 +1331,15 @@ class Teacher:
address_first6=self.checksum_address[2:8]
)
def known_nodes_details(self) -> dict:
def known_nodes_details(self, raise_invalid=True) -> dict:
abridged_nodes = {}
for checksum_address, node in self.known_nodes._nodes.items():
abridged_nodes[checksum_address] = self.node_details(node=node)
try:
abridged_nodes[checksum_address] = self.node_details(node=node)
except self.StampNotSigned:
if raise_invalid:
raise
self.log.error(f"encountered unsigned stamp for node with checksum: {checksum_address}")
return abridged_nodes
@staticmethod
@ -1367,11 +1372,11 @@ class Teacher:
}
return payload
def abridged_node_details(self) -> dict:
def abridged_node_details(self, raise_invalid=True) -> dict:
"""Self-Reporting"""
payload = self.node_details(node=self)
states = self.known_nodes.abridged_states_dict()
known = self.known_nodes_details()
known = self.known_nodes_details(raise_invalid=raise_invalid)
payload.update({'states': states, 'known_nodes': known})
if not self.federated_only:
payload.update({

View File

@ -421,7 +421,7 @@ def _make_rest_app(datastore: Datastore, this_node, domain: str, log: Logger) ->
@rest_app.route('/status/', methods=['GET'])
def status():
if request.args.get('json'):
payload = this_node.abridged_node_details()
payload = this_node.abridged_node_details(raise_invalid=False)
response = jsonify(payload)
return response