Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in main loop: invalid literal for int() with base 10: '' #9

Open
Ilmereth opened this issue Oct 12, 2024 · 7 comments
Open

Error in main loop: invalid literal for int() with base 10: '' #9

Ilmereth opened this issue Oct 12, 2024 · 7 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@Ilmereth
Copy link

Ilmereth commented Oct 12, 2024

After installing using the installer

curl -sSL https://raw.githubusercontent.com/fabriziosalmi/proxmox-lxc-autoscale/main/install.sh | bash
then configuring it by using
curl -sSL https://raw.githubusercontent.com/fabriziosalmi/proxmox-lxc-autoscale/main/lxc_autoscale/lxc_autoscale_autoconf.sh | bash

systemctl status lxc_autoscale.service

reports the following error:

● lxc_autoscale.service - LXC AutoScale Daemon
Loaded: loaded (/etc/systemd/system/lxc_autoscale.service; enabled; preset: enabled)
Active: active (running) since Sat 2024-10-12 18:32:02 CEST; 4min 52s ago
Docs: https://github.com/fabriziosalmi/proxmox-lxc-autoscale
Main PID: 15839 (python3)
Tasks: 1 (limit: 76769)
Memory: 42.2M
CPU: 15.851s
CGroup: /system.slice/lxc_autoscale.service
└─15839 /usr/bin/python3 /usr/local/bin/lxc_autoscale/lxc_autoscale.py

Okt 12 18:32:04 blackbox python3[15839]: 2024-10-12 18:32:04 - CPU usage for container 101 using Load Average Method: 100.0%
Okt 12 18:32:04 blackbox python3[15839]: 2024-10-12 18:32:04 - CPU usage for container 254 using Load Average Method: 100.0%
Okt 12 18:32:04 blackbox python3[15839]: 2024-10-12 18:32:04 - CPU usage for container 249 using Load Average Method: 100.0%
Okt 12 18:32:04 blackbox python3[15839]: 2024-10-12 18:32:04 - CPU usage for container 111 using Load Average Method: 100.0%
Okt 12 18:32:04 blackbox python3[15839]: 2024-10-12 18:32:04 - CPU usage for container 108 using Load Average Method: 100.0%
Okt 12 18:32:04 blackbox python3[15839]: 2024-10-12 18:32:04 - CPU usage for container 244 using Load Average Method: 70.0%
Okt 12 18:32:04 blackbox python3[15839]: 2024-10-12 18:32:04 - CPU usage for container 100 using Load Average Method: 93.33%
Okt 12 18:32:05 blackbox python3[15839]: 2024-10-12 18:32:05 - Starting resource allocation process...
Okt 12 18:32:05 blackbox python3[15839]: 2024-10-12 18:32:05 - Ignoring LXC Containers: set()
Okt 12 18:32:05 blackbox python3[15839]: 2024-10-12 18:32:05 - Error in main loop: invalid literal for int() with base 10: ''

To Reproduce
Reboot Node
systemctl status lxc_autoscale.service

Desktop (please complete the following information):

  • OS: Debian LXC on ProxMox 8.2.7
@fabriziosalmi
Copy link
Owner

TY to share this, I will fix it asap!

@Ilmereth
Copy link
Author

Ilmereth commented Oct 14, 2024

Thanks a lot. Looking forward to testing it.
If you need Logs, or error messages let me know.

@fabriziosalmi
Copy link
Owner

can I ask you your polling value?

@Ilmereth
Copy link
Author

Ilmereth commented Oct 15, 2024

My Polling Value is 600.
I haven`t changed any values in /etc/lxc_autoscale/lxc_autoscale.yaml

One Correction to my first Post:
Your script is not running in an LXC, but directly on the ProxMox Server.

@Ilmereth
Copy link
Author

Ilmereth commented Oct 16, 2024

when I run
systemctl status lxcfs.service
I get the following:

● lxcfs.service - FUSE filesystem for LXC
Loaded: loaded (/lib/systemd/system/lxcfs.service; enabled; preset: enabled)
Active: active (running) since Wed 2024-10-16 17:33:55 CEST; 43s ago
Docs: man:lxcfs(1)
Main PID: 7817 (lxcfs)
Tasks: 4 (limit: 76768)
Memory: 564.0K
CPU: 3ms
CGroup: /system.slice/lxcfs.service
└─7817 /usr/bin/lxcfs /var/lib/lxcfs -l

Okt 16 17:33:55 blackbox lxcfs[7817]: - proc_meminfo
Okt 16 17:33:55 blackbox lxcfs[7817]: - proc_stat
Okt 16 17:33:55 blackbox lxcfs[7817]: - proc_swaps
Okt 16 17:33:55 blackbox lxcfs[7817]: - proc_uptime
Okt 16 17:33:55 blackbox lxcfs[7817]: - proc_slabinfo
Okt 16 17:33:55 blackbox lxcfs[7817]: - shared_pidns
Okt 16 17:33:55 blackbox lxcfs[7817]: - cpuview_daemon
Okt 16 17:33:55 blackbox lxcfs[7817]: - loadavg_daemon
Okt 16 17:33:55 blackbox lxcfs[7817]: - pidfds
Okt 16 17:33:55 blackbox lxcfs[7817]: Ignoring invalid max threads value 4294967295 > max (100000).

I‘m Not sure if that is helping, or if it is an entirely different issue that ha nothing to do with your Software.

@fabriziosalmi
Copy link
Owner

i will try this route to fix it..

def main_loop(poll_interval, energy_mode):
    """
    The main loop for managing container resources.
    
    Args:
        poll_interval (int): The interval in seconds between each resource check.
        energy_mode (bool): Whether to enable energy-saving mode during off-peak hours.
    """
    while True:
        # Example of where CPU or memory might be retrieved
        containers = get_containers()  # Assume this returns a list of container IDs

        for ctid in containers:
            try:
                cpu_usage = get_cpu_usage(ctid)  # Fetch CPU usage for the container
                memory_usage = get_memory_usage(ctid)  # Fetch memory usage for the container
                
                # Ensure CPU and memory are valid numbers before proceeding
                if cpu_usage.isdigit():
                    cpu_usage = int(cpu_usage)
                else:
                    logging.error(f"Invalid CPU usage for container {ctid}: {cpu_usage}")
                    continue  # Skip this container if the value is invalid
                
                if memory_usage.isdigit():
                    memory_usage = int(memory_usage)
                else:
                    logging.error(f"Invalid memory usage for container {ctid}: {memory_usage}")
                    continue  # Skip this container if the value is invalid

                # Perform scaling or other resource management actions based on CPU/memory usage

            except ValueError as e:
                logging.error(f"Error in processing container {ctid}: {e}")
                continue  # Skip to the next container in case of an error

        # Wait for the poll interval before checking again
        time.sleep(poll_interval)

gimme some time more to achieve it :)
it seems that the value returned of cpu load or memory is not well managed and break the script

@fabriziosalmi fabriziosalmi self-assigned this Oct 18, 2024
@fabriziosalmi fabriziosalmi added bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed labels Oct 18, 2024
@Ilmereth
Copy link
Author

Thank you. Take all the time you need. I wish I could help you, but my knowledge of python is limited to installing the required Packages.
Have a nice Weekend :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants