Open sscargal opened 1 week ago
We can fix this SyntaxError with:
source ./logging.sh
I see a bug caused by my previous commit.
wget -O mmcai_adjust_requests.py https://raw.githubusercontent.com/MemVerge/mmc.ai-setup/refs/heads/main/mmcai-drain.sh
Should be
wget -O mmcai_adjust_requests.py https://raw.githubusercontent.com/MemVerge/mmc.ai-setup/refs/heads/main/mmcai_adjust_requests.py
I get a new error running mmcai-drain.sh
:
File "/home/mmai-admin/mmc.ai-setup/mmcai_adjust_requests.py", line 42
'container': container.name
^^^^^^^^^^^^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?
This is part of an object an is missing the comma:
pod_list.append({
'namespace': pod.metadata.namespace,
'name': pod.metadata.name,
'labels': pod.metadata.labels,
'cpu_request': cpu_request_m,
'container': container.name, # Add a comma here
'owner': pod.metadata.owner_references[0]
})
After fixing the previous issues, I got a new error:
Traceback (most recent call last):
File "/home/mmai-admin/mmc.ai-setup/./mmcai_adjust_requests.py", line 194, in <module>
main()
File "/home/mmai-admin/mmc.ai-setup/./mmcai_adjust_requests.py", line 176, in main
restart_deployment(pod['deployment'])
TypeError: restart_deployment() missing 2 required positional arguments: 'deployment' and 'namespace'
The restart_deployment()
function requires three arguments, but only two are used:
def restart_deployment(v1_apps, deployment, namespace):
From the main function:
# Restart the modified pods to apply the changes
for pod in modified_pods:
if 'deployment' in pod:
restart_deployment(pod['deployment']). <<<<<<<<<
else:
restart_pod(pod['name'], pod['namespace'])
We need to call the function with the correct arguments:
restart_deployment(apps_v1, pod['deployment'], pod['namespace'])
When executing
mmcai-drain.sh
, it callsmmcai_adjust_requests.py
which fails with the following error: