# Found info from node, such as nodeinfo URL, detection mode that needs to be
# written to database. Both arrays must be filled at the same time or else
-# update_nodeinfos() will fail
+# update_instance_data() will fail
nodeinfos = {
# Detection mode: 'AUTO_DISCOVERY', 'STATIC_CHECKS' or 'GENERATOR'
# NULL means all detection methods have failed (maybe still reachable instance)
nodeinfos["last_blocked"] = time.time()
# Running pending updated
- # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
- update_nodeinfos(domain)
+ # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+ update_instance_data(domain)
# DEBUG: print("DEBUG: EXIT!")
# DEBUG: print(f"DEBUG: has_pending='{has_pending}' - EXIT!")
return has_pending
-def update_nodeinfos(domain: str):
+def update_instance_data(domain: str):
if type(domain) != str:
raise ValueError(f"WARNING: domain[]={type(domain)} is not 'str'")
# DEBUG: print(f"DEBUG: Success! (rowcount={cursor.rowcount })")
if cursor.rowcount == 0:
- print("WARNING: Did not update any rows:", domain)
- else:
- connection.commit()
+ print(f"WARNING: Did not update any rows: domain='{domain}',fields()={len(fields)} - EXIT!")
+ return
+
+ connection.commit()
+
+ # DEBUG: print("DEBUG: Deleting nodeinfos for domain:", domain)
+ for key in nodeinfos:
+ try:
+ # DEBUG: print("DEBUG: Deleting key:", key)
+ del nodeinfos[key][domain]
+ except:
+ pass
except BaseException as e:
print(f"ERROR: failed SQL query: domain='{domain}',sql='{sql}',exception[{type(e)}]:'{str(e)}'")
sys.exit(255)
- # DEBUG: print("DEBUG: Deleting nodeinfos for domain:", domain)
- for key in nodeinfos:
- try:
- # DEBUG: print("DEBUG: Deleting key:", key)
- del nodeinfos[key][domain]
- except:
- pass
-
# DEBUG: print("DEBUG: EXIT!")
def log_error(domain: str, res: any):
nodeinfos["last_error_details"][domain] = res.reason
# Running pending updated
- # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
- update_nodeinfos(domain)
+ # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+ update_instance_data(domain)
log_error(domain, res)
nodeinfos["last_instance_fetch"][domain] = time.time()
# Running pending updated
- # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
- update_nodeinfos(domain)
+ # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+ update_instance_data(domain)
# DEBUG: print("DEBUG: EXIT!")
nodeinfos["last_updated"][domain] = time.time()
# Running pending updated
- # DEBUG: print(f"DEBUG: Invoking update_nodeinfos({domain}) ...")
- update_nodeinfos(domain)
+ # DEBUG: print(f"DEBUG: Invoking update_instance_data({domain}) ...")
+ update_instance_data(domain)
# DEBUG: print("DEBUG: EXIT!")
if has_pending_nodeinfos(domain):
# DEBUG: print(f"DEBUG: domain='{domain}' has pending nodeinfo being updated ...")
- update_nodeinfos(domain)
+ update_instance_data(domain)
remove_pending_error(domain)
if domain in pending_errors: