Commit ef3ba65f authored by felipe andrade's avatar felipe andrade Committed by GitHub

fix(ufm): betterer error metric label (#6535)

* fix(ufm): betterer error metric label

* remove commented code
parent e226b326
......@@ -94,7 +94,8 @@ func RecordError(provider string, errorLabel string) {
func RecordErrorDetails(provider string, label string, err error) {
errClean := nonAlphanumericRegex.ReplaceAllString(err.Error(), "")
errClean = strings.ReplaceAll(errClean, " ", "_")
label = fmt.Sprintf("%s.%s", label)
errClean = strings.ReplaceAll(errClean, "__", "_")
label = fmt.Sprintf("%s.%s", label, errClean)
RecordError(provider, label)
}
......
......@@ -44,10 +44,11 @@ func resolveAddr(ctx context.Context, client *kms.KeyManagementClient, keyName s
if err != nil {
return common.Address{}, fmt.Errorf("google kms public key %q lookup: %w", keyName, err)
}
keyPem := resp.Pem
block, _ := pem.Decode([]byte(resp.Pem))
block, _ := pem.Decode([]byte(keyPem))
if block == nil {
return common.Address{}, fmt.Errorf("google kms public key %q pem empty: %.130q", keyName, resp.Pem)
return common.Address{}, fmt.Errorf("google kms public key %q pem empty: %.130q", keyName, keyPem)
}
var info struct {
......@@ -59,11 +60,6 @@ func resolveAddr(ctx context.Context, client *kms.KeyManagementClient, keyName s
return common.Address{}, fmt.Errorf("google kms public key %q pem block %q: %v", keyName, block.Type, err)
}
wantAlg := asn1.ObjectIdentifier{1, 2, 840, 10045, 2, 1}
if gotAlg := info.AlgID.Algorithm; !gotAlg.Equal(wantAlg) {
return common.Address{}, fmt.Errorf("google kms public key %q asn.1 algorithm %s intead of %s", keyName, gotAlg, wantAlg)
}
return pubKeyAddr(info.Key.Bytes), nil
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment