--- a/keylime/registrar_common.py 2023-07-19 17:26:50.320894695 +0200 +++ b/keylime/registrar_common.py 2023-07-19 17:27:16.797790852 +0200 @@ -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)