Skip to content

Commit

Permalink
logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rugggger committed Dec 17, 2024
1 parent df8598d commit 1a1e186
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ proxy_url = VALUE
| <a name="input_function_app_storage_account_prefix"></a> [function\_app\_storage\_account\_prefix](#input\_function\_app\_storage\_account\_prefix) | Weka storage account name prefix | `string` | `"weka"` | no |
| <a name="input_function_app_subnet_delegation_cidr"></a> [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 |
| <a name="input_function_app_subnet_delegation_id"></a> [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 |
| <a name="input_function_app_version"></a> [function\_app\_version](#input\_function\_app\_version) | Function app code version (hash) | `string` | `"b56165536773bf1224121c8529b6de2a"` | no |
| <a name="input_function_app_version"></a> [function\_app\_version](#input\_function\_app\_version) | Function app code version (hash) | `string` | `"406c7ac689e24b839bf61ce25fb976e8"` | no |
| <a name="input_get_weka_io_token"></a> [get\_weka\_io\_token](#input\_get\_weka\_io\_token) | The token to download the Weka release from get.weka.io. | `string` | `""` | no |
| <a name="input_hotspare"></a> [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 |
| <a name="input_install_cluster_dpdk"></a> [install\_cluster\_dpdk](#input\_install\_cluster\_dpdk) | Install weka cluster with DPDK | `bool` | `true` | no |
Expand Down
18 changes: 6 additions & 12 deletions function-app/code/functions/weka_api/weka_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/rs/zerolog/log"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -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 {
Expand All @@ -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))
Expand All @@ -77,17 +77,16 @@ 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
}

return &rawWekaStatus, nil
}

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
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 1a1e186

Please sign in to comment.