ionos-cloud / cluster-api-provider-proxmox

Cluster API Provider for Proxmox VE (CAPMOX)
Apache License 2.0
181 stars 24 forks source link

scheduler: memory assignment of templates is included in calculations #36

Closed pborn-ionos closed 9 months ago

pborn-ionos commented 9 months ago

What steps did you take and what happened:

What did you expect to happen:

Anything else you would like to add:

Environment:

chengleqi commented 8 months ago
E0120 05:46:40.571594       1 controller.go:324] "Reconciler error" err="failed to reconcile VM: cannot reserve 2147483648B of memory on node newpve: 0B available memory left" controller="proxmoxmachine" controllerGroup="infrastructure.cluster.x-k8s.io" controllerKind="ProxmoxMachine" ProxmoxMachine="default/proxmox-quickstart-control-plane-gnjd5" namespace="default" name="proxmox-quickstart-control-plane-gnjd5" reconcileID="2e95a13b-e769-4197-8a37-7287ee874c22"

Hi, My PVE Node has enough mem, but I got this error. Do you have any solution?

capmox-controller-manager' version is v0.1.1

chengleqi commented 8 months ago

I think I have found the reason. In the function below, the variable reservableMemory is set to 0 because the maximum memory set for my other virtual machines exceeds the node's memory. https://github.com/ionos-cloud/cluster-api-provider-proxmox/blob/ed0cbf14cf9ab78edbc21f9bc861d414e5552bc2/pkg/proxmox/goproxmox/api_client.go#L184

I have a question, why not directly use node.Memory.Free?

package main

import (
    "context"
    "crypto/tls"
    "fmt"
    "github.com/luthermonson/go-proxmox"
    "net/http"
)

func main() {
    insecureHTTPClient := http.Client{
        Transport: &http.Transport{
            TLSClientConfig: &tls.Config{
                InsecureSkipVerify: true,
            },
        },
    }
    tokenID := ""
    secret := ""

    client := proxmox.NewClient("https://192.168.3.50:8006/api2/json",
        proxmox.WithHTTPClient(&insecureHTTPClient),
        proxmox.WithAPIToken(tokenID, secret),
    )

    node, err := client.Node(context.Background(), "newpve")
    if err != nil {
        panic(err)
    }
    fmt.Println(node.Memory.Total / 1024 / 1024 / 1024)
    fmt.Println(node.Memory.Used / 1024 / 1024 / 1024)
    fmt.Println(node.Memory.Free / 1024 / 1024 / 1024)
}

Output:

node.Memory.Total: 62GB
node.Memory.Used: 15GB
node.Memory.Free: 46GB
chengleqi commented 8 months ago

Can you help me take a look at this problem? @mcbenjemaa