From 1a1e18696416c2be44e79d2b4e69b5c2c0b506b6 Mon Sep 17 00:00:00 2001 From: Yaron Bar Date: Tue, 17 Dec 2024 11:30:45 +0200 Subject: [PATCH] logging --- README.md | 2 +- .../code/functions/weka_api/weka_api.go | 18 ++++++------------ variables.tf | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 385b43a7..255e2c04 100644 --- a/README.md +++ b/README.md @@ -466,7 +466,7 @@ proxy_url = VALUE | [function\_app\_storage\_account\_prefix](#input\_function\_app\_storage\_account\_prefix) | Weka storage account name prefix | `string` | `"weka"` | no | | [function\_app\_subnet\_delegation\_cidr](#input\_function\_app\_subnet\_delegation\_cidr) | Subnet delegation enables you to designate a specific subnet for an Azure PaaS service. | `string` | `"10.0.1.0/25"` | no | | [function\_app\_subnet\_delegation\_id](#input\_function\_app\_subnet\_delegation\_id) | Required to specify if subnet\_name were used to specify pre-defined subnets for weka. Function subnet delegation requires an additional subnet, and in the case of pre-defined networking this one also should be pre-defined | `string` | `""` | no | -| [function\_app\_version](#input\_function\_app\_version) | Function app code version (hash) | `string` | `"b56165536773bf1224121c8529b6de2a"` | no | +| [function\_app\_version](#input\_function\_app\_version) | Function app code version (hash) | `string` | `"406c7ac689e24b839bf61ce25fb976e8"` | no | | [get\_weka\_io\_token](#input\_get\_weka\_io\_token) | The token to download the Weka release from get.weka.io. | `string` | `""` | no | | [hotspare](#input\_hotspare) | Number of hotspares to set on weka cluster. Refer to https://docs.weka.io/overview/ssd-capacity-management#hot-spare | `number` | `1` | no | | [install\_cluster\_dpdk](#input\_install\_cluster\_dpdk) | Install weka cluster with DPDK | `bool` | `true` | no | diff --git a/function-app/code/functions/weka_api/weka_api.go b/function-app/code/functions/weka_api/weka_api.go index 792c195a..19d147b6 100644 --- a/function-app/code/functions/weka_api/weka_api.go +++ b/function-app/code/functions/weka_api/weka_api.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/rs/zerolog/log" "math/rand" "net/http" "os" @@ -43,11 +42,11 @@ func (wr *WekaApiRequest) MakeRequest(ctx context.Context) (*json.RawMessage, er func CallJRPC(ctx context.Context, wekaApi *WekaApiRequest) (message *json.RawMessage, err error) { logger := logging.LoggerFromCtx(ctx) - logger.Info().Msg("fetching cluster status...") credentials, err := common.GetWekaClusterCredentials(ctx, wekaApi.keyvaultURI) if err != nil { - return + logger.Error().Msgf("failed to get cluster credentials: %v", err) + return nil, err } jrpcBuilder := func(ip string) *jrpc.BaseClient { @@ -56,6 +55,7 @@ func CallJRPC(ctx context.Context, wekaApi *WekaApiRequest) (message *json.RawMe vmIps, err := common.GetVmsPrivateIps(ctx, wekaApi.vmssParams) if err != nil { + logger.Error().Msgf("failed to get vms ips: %v", err) return nil, err } ips := make([]string, 0, len(vmIps)) @@ -77,6 +77,7 @@ func CallJRPC(ctx context.Context, wekaApi *WekaApiRequest) (message *json.RawMe err = jpool.Call(wekaApi.Method, struct{}{}, &rawWekaStatus) if err != nil { + logger.Error().Msgf("jrpc call failed: %v", err) return nil, err } @@ -84,10 +85,8 @@ func CallJRPC(ctx context.Context, wekaApi *WekaApiRequest) (message *json.RawMe } func Handler(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - //logger := logging.LoggerFromCtx(ctx) - log.Info().Msg("this is weka api") + logger := logging.LoggerFromCtx(ctx) var err error var wekaApi WekaApiRequest @@ -96,15 +95,10 @@ func Handler(w http.ResponseWriter, r *http.Request) { common.WriteErrorResponse(w, fmt.Errorf("bad method")) return } - result, err := wekaApi.MakeRequest(ctx) - //var result *json.RawMessage - //if wekaApi.Method == "" || wekaApi.Method == "status" { - // result, err = CallJRPC(ctx, wekaApi) - //} - if err != nil { + logger.Error().Msgf("weka-api failed: %v", err) common.WriteErrorResponse(w, err) return } diff --git a/variables.tf b/variables.tf index 3c9197cf..7a15dfe8 100644 --- a/variables.tf +++ b/variables.tf @@ -404,7 +404,7 @@ variable "function_app_storage_account_container_prefix" { variable "function_app_version" { type = string description = "Function app code version (hash)" - default = "b56165536773bf1224121c8529b6de2a" + default = "406c7ac689e24b839bf61ce25fb976e8" } variable "function_app_dist" {