From 398b8692eb0254c3feda63ceca93cebf7dff942d Mon Sep 17 00:00:00 2001 From: dev-hippo-an Date: Mon, 19 Feb 2024 10:31:38 +0900 Subject: [PATCH] feat: GCP PriceInfoHandler stop progress when no permissions for billing account - Previously, all errors were handled with a continue without checking error codes. - Following the update, 403 error codes from the Google API are checked, and in such cases, errors are returned to prevent unnecessary resource usage. --- .../cloud-driver/drivers/gcp/resources/PriceInfoHandler.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cloud-control-manager/cloud-driver/drivers/gcp/resources/PriceInfoHandler.go b/cloud-control-manager/cloud-driver/drivers/gcp/resources/PriceInfoHandler.go index ca6e60ff3..6a72487df 100644 --- a/cloud-control-manager/cloud-driver/drivers/gcp/resources/PriceInfoHandler.go +++ b/cloud-control-manager/cloud-driver/drivers/gcp/resources/PriceInfoHandler.go @@ -166,6 +166,13 @@ func (priceInfoHandler *GCPPriceInfoHandler) GetPriceInfo(productFamily string, estimatedCostResponse, err := callEstimateCostScenario(priceInfoHandler, regionName, billingAccountId, machineType) if err != nil { cblogger.Error("error occurred when calling the EstimateCostScenario; message:", err) + + if googleApiError, ok := err.(*googleapi.Error); ok { + if googleApiError.Code == 403 { + return "", errors.New("you don't have any permission to access billing account") + } + } + continue }