fix(ufm): betterer error metric label (#6535)
* fix(ufm): betterer error metric label * remove commented code
This commit is contained in:
parent
b5417cdb7d
commit
39bf1de860
@ -94,7 +94,8 @@ func RecordError(provider string, errorLabel string) {
|
|||||||
func RecordErrorDetails(provider string, label string, err error) {
|
func RecordErrorDetails(provider string, label string, err error) {
|
||||||
errClean := nonAlphanumericRegex.ReplaceAllString(err.Error(), "")
|
errClean := nonAlphanumericRegex.ReplaceAllString(err.Error(), "")
|
||||||
errClean = strings.ReplaceAll(errClean, " ", "_")
|
errClean = strings.ReplaceAll(errClean, " ", "_")
|
||||||
label = fmt.Sprintf("%s.%s", label)
|
errClean = strings.ReplaceAll(errClean, "__", "_")
|
||||||
|
label = fmt.Sprintf("%s.%s", label, errClean)
|
||||||
RecordError(provider, label)
|
RecordError(provider, label)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,11 @@ func resolveAddr(ctx context.Context, client *kms.KeyManagementClient, keyName s
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Address{}, fmt.Errorf("google kms public key %q lookup: %w", keyName, err)
|
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 {
|
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 {
|
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)
|
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
|
return pubKeyAddr(info.Key.Bytes), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user