diff --git a/coding-requirements.txt b/coding-requirements.txt index 62b2c01..cc0043c 100644 --- a/coding-requirements.txt +++ b/coding-requirements.txt @@ -1,6 +1,6 @@ ansible==8.1.0 ansible-core==2.15.1 - cryptography==41.0.2 + cryptography==41.0.3 cffi==1.15.1 pycparser==2.21 Jinja2==3.1.2 @@ -11,7 +11,7 @@ ansible==8.1.0 ansible-lint==6.17.2 ansible-compat==4.1.2 ansible-core==2.15.1 - cryptography==41.0.2 + cryptography==41.0.3 cffi==1.15.1 pycparser==2.21 Jinja2==3.1.2 @@ -19,7 +19,7 @@ ansible-lint==6.17.2 packaging==23.1 PyYAML==6.0 resolvelib==1.0.1 - jsonschema==4.18.0 + jsonschema==4.18.6 attrs==23.1.0 jsonschema-specifications==2023.6.1 referencing==0.29.1 @@ -33,7 +33,7 @@ ansible-lint==6.17.2 PyYAML==6.0 subprocess-tee==0.4.1 ansible-core==2.15.1 - cryptography==41.0.2 + cryptography==41.0.3 cffi==1.15.1 pycparser==2.21 Jinja2==3.1.2 @@ -46,10 +46,10 @@ ansible-lint==6.17.2 mypy-extensions==1.0.0 packaging==23.1 pathspec==0.11.1 - platformdirs==3.8.1 + platformdirs==3.10.0 tomli==2.0.1 filelock==3.12.2 - jsonschema==4.18.0 + jsonschema==4.18.6 attrs==23.1.0 jsonschema-specifications==2023.6.1 referencing==0.29.1 @@ -63,7 +63,7 @@ ansible-lint==6.17.2 pathspec==0.11.1 PyYAML==6.0 requests==2.31.0 - certifi==2023.7.22 + certifi==2023.5.7 charset-normalizer==3.2.0 idna==3.4 urllib3==2.0.3 @@ -80,7 +80,7 @@ ansible-lint==6.17.2 pathspec==0.11.1 PyYAML==6.0 bandit==1.7.5 - GitPython==3.1.31 + GitPython==3.1.32 gitdb==4.0.10 smmap==5.0.0 PyYAML==6.0 @@ -94,7 +94,7 @@ graphviz==0.20.1 pip-autoremove==0.10.0 pip==23.2.1 setuptools==68.0.0 -pipdeptree==2.9.4 +pipdeptree==2.12.0 pylint==2.17.4 astroid==2.15.6 lazy-object-proxy==1.9.0 @@ -103,25 +103,25 @@ pylint==2.17.4 dill==0.3.6 isort==5.12.0 mccabe==0.7.0 - platformdirs==3.8.1 + platformdirs==3.10.0 tomli==2.0.1 tomlkit==0.11.8 pywinrm==0.4.3 requests==2.31.0 - certifi==2023.7.22 + certifi==2023.5.7 charset-normalizer==3.2.0 idna==3.4 urllib3==2.0.3 requests-ntlm==1.2.0 - cryptography==41.0.2 + cryptography==41.0.3 cffi==1.15.1 pycparser==2.21 pyspnego==0.9.1 - cryptography==41.0.2 + cryptography==41.0.3 cffi==1.15.1 pycparser==2.21 requests==2.31.0 - certifi==2023.7.22 + certifi==2023.5.7 charset-normalizer==3.2.0 idna==3.4 urllib3==2.0.3 diff --git a/requirements.txt b/requirements.txt index f8bffef..55611dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ ansible==8.1.0 ansible-core==2.15.1 - cryptography==41.0.2 + cryptography==41.0.1 cffi==1.15.1 pycparser==2.21 Jinja2==3.1.2 @@ -11,20 +11,20 @@ ansible==8.1.0 pip==23.2.1 pywinrm==0.4.3 requests==2.31.0 - certifi==2023.7.22 + certifi==2023.5.7 charset-normalizer==3.2.0 idna==3.4 urllib3==2.0.3 requests-ntlm==1.2.0 - cryptography==41.0.2 + cryptography==41.0.1 cffi==1.15.1 pycparser==2.21 pyspnego==0.9.1 - cryptography==41.0.2 + cryptography==41.0.1 cffi==1.15.1 pycparser==2.21 requests==2.31.0 - certifi==2023.7.22 + certifi==2023.5.7 charset-normalizer==3.2.0 idna==3.4 urllib3==2.0.3 diff --git a/tdarr-noding/src/tdarr/logic.py b/tdarr-noding/src/tdarr/logic.py index 2e4bae3..c20f62a 100644 --- a/tdarr-noding/src/tdarr/logic.py +++ b/tdarr-noding/src/tdarr/logic.py @@ -70,7 +70,7 @@ def search_for_failed_health_checks(Server): payload, headers = Tdarr_Logic.payload_and_headers_file_modification("error") response = requests.post( - Server.search, json=payload, headers=headers, timeout=10 + Server.search, json=payload, headers=headers, timeout=30 ) response = json.loads(response.text) @@ -93,7 +93,7 @@ def search_for_skipped_transcodes(Server, container_type): payload, headers = Tdarr_Logic.payload_and_headers_file_modification("") response = requests.post( - Server.search, json=payload, headers=headers, timeout=10 + Server.search, json=payload, headers=headers, timeout=30 ) response = json.loads(response.text) @@ -126,7 +126,7 @@ def search_for_failed_transcodes(Server): ) response = requests.post( - Server.search, json=payload, headers=headers, timeout=10 + Server.search, json=payload, headers=headers, timeout=30 ) response = json.loads(response.text) @@ -158,7 +158,7 @@ def search_for_successful_transcodes(Server): ) response = requests.post( - Server.search, json=payload, headers=headers, timeout=10 + Server.search, json=payload, headers=headers, timeout=30 ) response = json.loads(response.text) @@ -188,7 +188,7 @@ def search_for_queued_transcodes(Server): payload, headers = Tdarr_Logic.payload_and_headers_file_modification("Queued") response = requests.post( - Server.search, json=payload, headers=headers, timeout=10 + Server.search, json=payload, headers=headers, timeout=30 ) response = json.loads(response.text) diff --git a/tdarr-noding/src/workhorse_class.py b/tdarr-noding/src/workhorse_class.py index d3c3ffa..f5183fb 100644 --- a/tdarr-noding/src/workhorse_class.py +++ b/tdarr-noding/src/workhorse_class.py @@ -209,6 +209,41 @@ def verify_primary_running(self): # check if primary node is running primary_node = self.Server.primary_node + # check if non-primary nodes are running + online_nodes = [] + for node_name, node_class in self.node_dictionary.items(): + if node_class.online: + online_nodes.append(node_name) + + # pop primary node from online nodes list + online_nodes.pop(online_nodes.index(primary_node)) + + # find nodes with and without work + nodes_with_work, nodes_without_work = tdarr.Tdarr_Logic.find_nodes_with_work( + self.Server + ) + + for node_name in online_nodes: + if node_name in nodes_with_work: + # set node to going down + self.Status.NodeStatusMaster.update_directive(node_name, "Going Down") + + elif node_name in nodes_without_work: + # shutdown node + # set workers to zero + tdarr.Tdarr_Orders.reset_workers_to_zero( + self.Server, node_name, self.node_dictionary + ) + # order shutdown + node_interactions.HostLogic.kill_node( + self.Configuration, self.node_dictionary, node_name, self.Status + ) + # set node status to offline + self.node_dictionary[node_name].line_state("Offline") + + # set node directive to sleep + self.Status.NodeStatusMaster.update_directive(node_name, "Sleeping") + # check if primary node is offline if not self.node_dictionary[primary_node].online: self.NormalHelpersClass.activate_node(primary_node) @@ -220,23 +255,62 @@ def verify_primary_running(self): # self.Status.print_status_file() # when primary node is online + # update nodes and check if primary node is online + self.update_classes() - current_errored_transcodes_quantity = ( - self.NormalHelpersClass.number_of_errored_transcodes(self.Server) - ) - previously_errored_transcode_quantity = self.Status.errored_transcodes_quantity + if self.node_dictionary[primary_node].online: + current_errored_transcodes_quantity = ( + self.NormalHelpersClass.number_of_errored_transcodes(self.Server) + ) + previously_errored_transcode_quantity = ( + self.Status.errored_transcodes_quantity + ) - if current_errored_transcodes_quantity > previously_errored_transcode_quantity: - # Call Refresh - self.refresh() + if previously_errored_transcode_quantity is not None: + if ( + current_errored_transcodes_quantity + > previously_errored_transcode_quantity + ): + # Call Refresh + self.refresh() - # Set status to refreshed - self.Status.change_state("Refreshed") + # Set status to refreshed + self.Status.change_state("Refreshed") - # print status again - self.Status.print_status_file() + # print status again + self.Status.print_status_file() + + self.post_refresh() + else: + # check quantity of work + quantity_of_work, _ = self.NormalHelpersClass.work_quantity_finder() + + # check if quantity of work is greater than zero + if quantity_of_work > 0: + # change status to normal + self.Status.change_state("Normal") + + # print status again + self.Status.print_status_file() - self.post_refresh() + else: + # Call Refresh + self.refresh() + + # Set status to refreshed + self.Status.change_state("Refreshed") + + # print status again + self.Status.print_status_file() + + self.post_refresh() + + else: + # change status to normal + self.Status.change_state("Normal") + + # print status file again + self.Status.print_status_file() def post_refresh(self): print("SECTION INFO: Starting workhorse 'post_refresh'")