From 7c15f71f0e6c470cff408ecfc1688b5383309901 Mon Sep 17 00:00:00 2001 From: Ildar Valiullin Date: Tue, 6 Jul 2021 00:29:55 +0300 Subject: [PATCH] fixed node creationg flow Signed-off-by: Ildar Valiullin --- Dockerfile | 7 ++++--- go.mod | 3 +-- pkg/provider/core.go | 7 +++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9cc53a9..56d364a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,13 @@ # SPDX-License-Identifier: Apache-2.0 ############# builder ############# -FROM golang:1.13.5 AS builder +FROM golang:1.15.13 AS builder WORKDIR /go/src/github.com/flant/machine-controller-manager-provider-yandex +COPY go.mod go.sum ./ +RUN go mod download -x COPY . . - -RUN .ci/build +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o bin/rel/machine-controller cmd/machine-controller/main.go ############# base ############# FROM alpine:3.11.2 as base diff --git a/go.mod b/go.mod index 1fb7611..3653d62 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/flant/machine-controller-manager-provider-yandex go 1.15 require ( - github.com/gardener/machine-controller-manager v0.34.0 + github.com/gardener/machine-controller-manager v0.39.0 github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d github.com/golang/protobuf v1.4.2 // indirect github.com/hashicorp/go-multierror v1.1.0 // indirect @@ -28,7 +28,6 @@ require ( ) replace ( - github.com/gardener/machine-controller-manager => github.com/gardener/machine-controller-manager v0.33.1-0.20200828071210-90f8b67cc5e6 github.com/onsi/gomega => github.com/onsi/gomega v1.5.0 github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2 k8s.io/api => k8s.io/api v0.0.0-20190918155943-95b840bb6a1f // kubernetes-1.16.0 diff --git a/pkg/provider/core.go b/pkg/provider/core.go index 2cd38ce..d42ea17 100644 --- a/pkg/provider/core.go +++ b/pkg/provider/core.go @@ -165,7 +165,7 @@ func (p *Provider) CreateMachine(ctx context.Context, req *driver.CreateMachineR return nil, mcmstatus.Error(mcmcodes.Internal, fmt.Sprintf("Yandex.Cloud API returned %q instead of \"*compute.Instance\". That shouldn't happen", reflect.TypeOf(result).String())) } - return &driver.CreateMachineResponse{ProviderID: encodeMachineID(newInstance.ZoneId, newInstance.Name), NodeName: machine.Name}, nil + return &driver.CreateMachineResponse{ProviderID: encodeMachineID(newInstance.ZoneId, newInstance.Id), NodeName: machine.Name}, nil } // DeleteMachine handles a machine deletion request @@ -249,6 +249,9 @@ func (p *Provider) GetMachineStatus(ctx context.Context, req *driver.GetMachineS if err != nil { return nil, mcmstatus.Error(mcmcodes.Internal, err.Error()) } + if machine.Spec.ProviderID == "" { + return nil, mcmstatus.Error(mcmcodes.NotFound, "providerID field is empty") + } _, instanceID, err := decodeMachineID(machine.Spec.ProviderID) if err != nil { return nil, mcmstatus.Error(mcmcodes.InvalidArgument, err.Error()) @@ -261,7 +264,7 @@ func (p *Provider) GetMachineStatus(ctx context.Context, req *driver.GetMachineS } } - return nil, nil + return &driver.GetMachineStatusResponse{ProviderID: machine.Spec.ProviderID, NodeName: machine.Name}, nil } // ListMachines lists all the machines possibilly created by a providerSpec