Skip to content

Commit

Permalink
fix(stop-support-session): prevent action failure
Browse files Browse the repository at this point in the history
If support sessions have never been started, the stop-support-session
action fails with the following error:

Traceback (most recent call last):
  File "/var/lib/nethserver/node/actions/stop-support-session/51publish_event", line 13, in <module>
    session_id = agent.read_envfile("support.env").get("VPN_PASSWORD")
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/agent/pypkg/agent/__init__.py", line 90, in read_envfile
    fo = open(file_path, 'r')
         ^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'support.env'
  • Loading branch information
gsanchietti committed Jan 28, 2025
1 parent 149c2da commit 293be86
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
# SPDX-License-Identifier: GPL-3.0-or-later
#

import sys
import agent
import os
import json

node_id = os.environ['NODE_ID']
session_id = agent.read_envfile("support.env").get("VPN_PASSWORD")
try:
session_id = agent.read_envfile("support.env").get("VPN_PASSWORD")
except:
# If file does not exists, no support sessions have ever been started
sys.exit(0)
support_user = agent.redis_connect().hget("cluster/subscription", "support_user")

agent.redis_connect(privileged=True).publish("node/" + node_id + "/event/support-session-stopped", json.dumps({
Expand Down

0 comments on commit 293be86

Please sign in to comment.