From 10f3e365d2f471d1e3a0bd8928ee1c7643d57678 Mon Sep 17 00:00:00 2001 From: Serge Logvinov Date: Fri, 20 Sep 2024 09:54:08 +0300 Subject: [PATCH] fix: instance type The node might be down when we try to retrieve the instance property. Signed-off-by: Serge Logvinov --- Dockerfile | 4 ++-- Makefile | 3 ++- pkg/proxmox/instances.go | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1983dd..4a21e33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -# syntax = docker/dockerfile:1.5 +# syntax = docker/dockerfile:1.10 ######################################## FROM --platform=${BUILDPLATFORM} golang:1.23.1-alpine3.20 AS builder RUN apk update && apk add --no-cache make -ENV GO111MODULE on +ENV GO111MODULE=on WORKDIR /src COPY go.mod go.sum /src diff --git a/Makefile b/Makefile index 2fcc917..0ee2465 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,8 @@ TESTARGS ?= "-v" BUILD_ARGS := --platform=$(PLATFORM) ifeq ($(PUSH),true) -BUILD_ARGS += --push=$(PUSH) --output type=image,annotation-index.org.opencontainers.image.source="https://github.com/$(USERNAME)/$(PROJECT)" +BUILD_ARGS += --push=$(PUSH) +BUILD_ARGS += --output type=image,annotation-index.org.opencontainers.image.source="https://github.com/$(USERNAME)/$(PROJECT)",annotation-index.org.opencontainers.image.description="Proxmox VE CCM for Kubernetes" else BUILD_ARGS += --output type=docker endif diff --git a/pkg/proxmox/instances.go b/pkg/proxmox/instances.go index 4da6dd9..e828987 100644 --- a/pkg/proxmox/instances.go +++ b/pkg/proxmox/instances.go @@ -235,6 +235,10 @@ func (i *instances) getInstanceType(vmRef *pxapi.VmRef, region string) (string, return "", err } + if vmInfo["maxcpu"] == nil || vmInfo["maxmem"] == nil { + return "", fmt.Errorf("instances.getInstanceType() failed to get instance type") + } + return fmt.Sprintf("%.0fVCPU-%.0fGB", vmInfo["maxcpu"].(float64), vmInfo["maxmem"].(float64)/1024/1024/1024), nil