diff -aruN keylime-6.5.2/keylime/registrar_common.py keylime-6.5.2.alma/keylime/registrar_common.py --- keylime-6.5.2/keylime/registrar_common.py 2023-09-12 18:48:23 +++ keylime-6.5.2.alma/keylime/registrar_common.py 2023-09-12 18:49:21 @@ -456,7 +456,16 @@ logger.error("SQLAlchemy Error: %s", e) raise else: - raise Exception(f"Auth tag {auth_tag} does not match expected value {ex_mac}") + if agent_id and session.query(RegistrarMain).filter_by(agent_id=agent_id).delete(): + try: + session.commit() + except SQLAlchemyError as e: + logger.error("SQLAlchemy Error: %s", e) + raise + + raise Exception( + f"Auth tag {auth_tag} for agent {agent_id} does not match expected value. The agent has been deleted from database, and a restart of it will be required" + ) web_util.echo_json_response(self, 200, "Success") logger.info("PUT activated: %s", agent_id)