fix: instance type

The node might be down when we try to retrieve the instance property.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
This commit is contained in:
Serge Logvinov
2024-09-20 09:54:08 +03:00
committed by Serge
parent 2b6435273f
commit 10f3e365d2
3 changed files with 8 additions and 3 deletions

View File

@@ -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 FROM --platform=${BUILDPLATFORM} golang:1.23.1-alpine3.20 AS builder
RUN apk update && apk add --no-cache make RUN apk update && apk add --no-cache make
ENV GO111MODULE on ENV GO111MODULE=on
WORKDIR /src WORKDIR /src
COPY go.mod go.sum /src COPY go.mod go.sum /src

View File

@@ -21,7 +21,8 @@ TESTARGS ?= "-v"
BUILD_ARGS := --platform=$(PLATFORM) BUILD_ARGS := --platform=$(PLATFORM)
ifeq ($(PUSH),true) 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 else
BUILD_ARGS += --output type=docker BUILD_ARGS += --output type=docker
endif endif

View File

@@ -235,6 +235,10 @@ func (i *instances) getInstanceType(vmRef *pxapi.VmRef, region string) (string,
return "", err return "", err
} }
if vmInfo["maxcpu"] == nil || vmInfo["maxmem"] == nil {
return "", fmt.Errorf("instances.getInstanceType() failed to get instance type")
}
return fmt.Sprintf("%.0fVCPU-%.0fGB", return fmt.Sprintf("%.0fVCPU-%.0fGB",
vmInfo["maxcpu"].(float64), vmInfo["maxcpu"].(float64),
vmInfo["maxmem"].(float64)/1024/1024/1024), nil vmInfo["maxmem"].(float64)/1024/1024/1024), nil