Error during module removal

NethServer Version: 8 core version 3.7.1
Module: Nethsercurity Controller version 1.2.7

Hi, I’ve installed some time ago the NSec Controller but I’ve never managed to get it working, so last weekend I’ve tried to uninstall it to re-install it again but whenver I try to uninstall it it says that there is a problem and the process ends.

This is the trace of the error that I’ve got:

{“context”:{“action”:“remove-module”,“data”:{“module_id”:“nethsecurity-controller1”,“preserve_data”:false},“extra”:{“description”:“Disinstallazione”,“eventId”:“9d4f2c6e-67c1-4b41-a398-2ea0a7595692”,“title”:“Disinstalla “},“id”:“8fda3301-6e14-41f4-b21b-49f8008e06cb”,“parent”:””,“queue”:“cluster/tasks”,“timestamp”:“2025-05-20T09:18:48.855845097Z”,“user”:“admin”},“status”:“aborted”,“progress”:0,“subTasks”:[{“context”:{“action”:“destroy-module”,“data”:{“module_id”:“nethsecurity-controller1”,“preserve_data”:false},“extra”:{},“id”:“bf833a15-ceff-484c-be83-1fd2e9111f89”,“parent”:“8fda3301-6e14-41f4-b21b-49f8008e06cb”},“status”:“aborted”,“progress”:14,“subTasks”:[{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1”},“extra”:{},“id”:“26749958-bfe1-40e4-91dc-18428cd17d7c”,“parent”:“bf833a15-ceff-484c-be83-1fd2e9111f89”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T09:18:49.560945389Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/26749958-bfe1-40e4-91dc-18428cd17d7c”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_grafana”},“extra”:{},“id”:“d81a4ff6-8e2c-48fe-bb21-d152de146370”,“parent”:“bf833a15-ceff-484c-be83-1fd2e9111f89”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T09:18:50.175756073Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/d81a4ff6-8e2c-48fe-bb21-d152de146370”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_loki”},“extra”:{},“id”:“10bcd397-6bd4-4873-9ca3-2aab8091731f”,“parent”:“bf833a15-ceff-484c-be83-1fd2e9111f89”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T09:18:50.843177303Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/10bcd397-6bd4-4873-9ca3-2aab8091731f”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_prometheus”},“extra”:{},“id”:“d59114e1-1ce7-41c4-a86d-0b10171feff8”,“parent”:“bf833a15-ceff-484c-be83-1fd2e9111f89”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T09:18:51.425491325Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/d59114e1-1ce7-41c4-a86d-0b10171feff8”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_webssh”},“extra”:{},“id”:“1a413db3-6f19-48ec-8c8f-c0c5c4cd3a00”,“parent”:“bf833a15-ceff-484c-be83-1fd2e9111f89”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T09:18:52.149962468Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/1a413db3-6f19-48ec-8c8f-c0c5c4cd3a00”,“output”:“”}}],“result”:{“error”:“Traceback (most recent call last):\n File "/home/nethsecurity-controller1/.config/actions/destroy-module/40firewall", line 10, in \n network = agent.read_envfile(‘network.env’)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File "/usr/local/agent/pypkg/agent/init.py", line 91, in read_envfile\n fo = open(file_path, ‘r’)\n ^^^^^^^^^^^^^^^^^^^^\nFileNotFoundError: [Errno 2] No such file or directory: ‘network.env’\n”,“exit_code”:1,“file”:“task/module/nethsecurity-controller1/bf833a15-ceff-484c-be83-1fd2e9111f89”,“output”:“”}}],“validated”:false,“result”:{“error”:“Traceback (most recent call last):\n File "/var/lib/nethserver/cluster/actions/remove-module/50update", line 72, in \n raise ex\n File "/var/lib/nethserver/cluster/actions/remove-module/50update", line 67, in \n raise Exception(f"non-zero exit-code from subtask")\nException: non-zero exit-code from subtask\n”,“exit_code”:1,“file”:“task/cluster/8fda3301-6e14-41f4-b21b-49f8008e06cb”,“output”:“”}}

Then the two actions:

Traceback (most recent call last):
File “/var/lib/nethserver/cluster/actions/remove-module/50update”, line 72, in
raise ex
File “/var/lib/nethserver/cluster/actions/remove-module/50update”, line 67, in
raise Exception(f"non-zero exit-code from subtask")
Exception: non-zero exit-code from subtask

Traceback (most recent call last):
File “/home/nethsecurity-controller1/.config/actions/destroy-module/40firewall”, line 10, in
network = agent.read_envfile(‘network.env’)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/agent/pypkg/agent/init.py”, line 91, in read_envfile
fo = open(file_path, ‘r’)
^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: ‘network.env’

I’ve tried everything that came to my mind but I can’t figure out how to get out from here.

Did you manually remove the file /home/nethsecurity-controller1/.config/state/network.env? It should have been created on installation.

I tested to remove the file and was able to reproduce the issue.

After recreating the file using following command I was able to successfully uninstall nethsecurity-controller1:

runagent -m nethsecurity-controller1 touch network.env
1 Like

Well re-creating the network.env file have did something but not what I expected.

now the trace is this one:

{“context”:{“action”:“remove-module”,“data”:{“module_id”:“nethsecurity-controller1”,“preserve_data”:false},“extra”:{“description”:“Disinstallazione”,“eventId”:“a2374aeb-aa64-4f66-aba8-59fe2002f7b7”,“title”:“Disinstalla “},“id”:“d098dde0-5ac3-4928-aa92-a3c785ad63db”,“parent”:””,“queue”:“cluster/tasks”,“timestamp”:“2025-05-20T15:49:08.826443648Z”,“user”:“admin”},“status”:“aborted”,“progress”:0,“subTasks”:[{“context”:{“action”:“destroy-module”,“data”:{“module_id”:“nethsecurity-controller1”,“preserve_data”:false},“extra”:{},“id”:“c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“parent”:“d098dde0-5ac3-4928-aa92-a3c785ad63db”},“status”:“aborted”,“progress”:14,“subTasks”:[{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1”},“extra”:{},“id”:“cb2f1a14-3b94-45c0-8245-298d0a453562”,“parent”:“c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T15:49:09.50427964Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/cb2f1a14-3b94-45c0-8245-298d0a453562”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_grafana”},“extra”:{},“id”:“abc0faa3-bf70-42bb-ac08-a47b7c1275be”,“parent”:“c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T15:49:10.108759657Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/abc0faa3-bf70-42bb-ac08-a47b7c1275be”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_loki”},“extra”:{},“id”:“fecc3ae4-a704-4b31-9b12-ead2596a7d7b”,“parent”:“c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T15:49:10.740081378Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/fecc3ae4-a704-4b31-9b12-ead2596a7d7b”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_prometheus”},“extra”:{},“id”:“49e3177e-8338-4cc2-b8a1-a9776687df21”,“parent”:“c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T15:49:11.325906265Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/49e3177e-8338-4cc2-b8a1-a9776687df21”,“output”:“”}},{“context”:{“action”:“delete-route”,“data”:{“instance”:“nethsecurity-controller1_webssh”},“extra”:{},“id”:“cfc015d5-68ab-406c-a9b4-3a1a12e41dff”,“parent”:“c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“queue”:“module/traefik1/tasks”,“timestamp”:“2025-05-20T15:49:11.927052708Z”,“user”:“module/nethsecurity-controller1”},“status”:“completed”,“progress”:100,“subTasks”:,“result”:{“error”:“”,“exit_code”:0,“file”:“task/module/traefik1/cfc015d5-68ab-406c-a9b4-3a1a12e41dff”,“output”:“”}},{“context”:{“action”:“remove-public-service”,“data”:{“service”:“nethsecurity-controller1”},“extra”:{},“id”:“1944cfd0-8662-4b57-9403-899f5f91e8cd”,“parent”:“c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“queue”:“node/1/tasks”,“timestamp”:“2025-05-20T15:49:12.923084031Z”,“user”:“module/nethsecurity-controller1”},“status”:“aborted”,“progress”:0,“subTasks”:,“result”:{“error”:“<7>firewall-cmd --permanent --delete-service=nethsecurity-controller1\nError: INVALID_SERVICE: nethsecurity-controller1\nTraceback (most recent call last):\n File "/var/lib/nethserver/node/actions/remove-public-service/50remove", line 31, in \n agent.run_helper(‘firewall-cmd’, ‘–permanent’, f’–delete-service={name}').check_returncode()\n File "/usr/lib64/python3.11/subprocess.py", line 502, in check_returncode\n raise CalledProcessError(self.returncode, self.args, self.stdout,\nsubprocess.CalledProcessError: Command ‘(‘firewall-cmd’, ‘–permanent’, ‘–delete-service=nethsecurity-controller1’)’ returned non-zero exit status 101.\n”,“exit_code”:1,“file”:“task/node/1/1944cfd0-8662-4b57-9403-899f5f91e8cd”,“output”:“”}}],“result”:{“error”:“Assertion failed\n File "/home/nethsecurity-controller1/.config/actions/destroy-module/40firewall", line 11, in \n agent.assert_exp(agent.remove_public_service(os.environ[‘MODULE_ID’]))\n”,“exit_code”:2,“file”:“task/module/nethsecurity-controller1/c4a0e9ce-8d09-4e05-8de3-0bcd45716bc1”,“output”:“”}}],“validated”:false,“result”:{“error”:“Traceback (most recent call last):\n File "/var/lib/nethserver/cluster/actions/remove-module/50update", line 72, in \n raise ex\n File "/var/lib/nethserver/cluster/actions/remove-module/50update", line 67, in \n raise Exception(f"non-zero exit-code from subtask")\nException: non-zero exit-code from subtask\n”,“exit_code”:1,“file”:“task/cluster/d098dde0-5ac3-4928-aa92-a3c785ad63db”,“output”:“”}}

And the actions:

Cluster/remove-module
Traceback (most recent call last):
File “/var/lib/nethserver/cluster/actions/remove-module/50update”, line 72, in
raise ex
File “/var/lib/nethserver/cluster/actions/remove-module/50update”, line 67, in
raise Exception(f"non-zero exit-code from subtask")
Exception: non-zero exit-code from subtask

Cluster/Destroy-module
Assertion failed
File “/home/nethsecurity-controller1/.config/actions/destroy-module/40firewall”, line 11, in
agent.assert_exp(agent.remove_public_service(os.environ[‘MODULE_ID’]))

node/1/remove-public-service
<7>firewall-cmd --permanent --delete-service=nethsecurity-controller1
Error: INVALID_SERVICE: nethsecurity-controller1
Traceback (most recent call last):
File “/var/lib/nethserver/node/actions/remove-public-service/50remove”, line 31, in
agent.run_helper(‘firewall-cmd’, ‘–permanent’, f’–delete-service={name}').check_returncode()
File “/usr/lib64/python3.11/subprocess.py”, line 502, in check_returncode
raise CalledProcessError(self.returncode, self.args, self.stdout,
subprocess.CalledProcessError: Command ‘(‘firewall-cmd’, ‘–permanent’, ‘–delete-service=nethsecurity-controller1’)’ returned non-zero exit status 101.

Could you please share the content of the original network.env?

Even if i create another istance the network.env seems to be empty or missing…

I’m installing the controller again to be able to send you a working network.env.

But I think the issue is that the firewall service for the nethsec controller can’t be deleted because the service isn’t set.

Please check the firewall service:

firewall-cmd --info-service nethsecurity-controller1

If there’s an error “INVALID_SERVICE” then you could use the following commands to recreate the firewall service:

firewall-cmd --permanent --new-service=nethsecurity-controller1
firewall-cmd --reload

Now there should be no issue regarding the firewall service deletion on uninstallation anymore.

EDIT:

Here’s the content of a network.env which is created on installation.

OVPN_UDP_PORT=20075
OVPN_TUN=tunnsc3
API_PORT=20076
API_BIND_IP=127.0.0.1
LISTEN_ADDRESS=127.0.0.1:20076
UI_PORT=20077
UI_BIND_IP=127.0.0.1
PROXY_PORT=20078
PROXY_BIND_UI=127.0.0.1
WEBSSH_PORT=20084

Uninstalling the controller also worked with an empty network.env, it’s just important that the file exists.

I think that when something goes wrong at installation, the network.env and the firewall service aren’t created.

Oh lord it worked

2 Likes