-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure Log Analytics, Prometheus scaler: custom HTTP client timeout #6607
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Zbynek Roubalik <[email protected]>
/run-e2e prometheus |
/run-e2e azure |
@@ -49,7 +49,8 @@ type prometheusMetadata struct { | |||
CustomHeaders map[string]string `keda:"name=customHeaders, order=triggerMetadata, optional"` | |||
IgnoreNullValues bool `keda:"name=ignoreNullValues, order=triggerMetadata, default=true"` | |||
UnsafeSSL bool `keda:"name=unsafeSsl, order=triggerMetadata, optional"` | |||
AwsRegion string `keda:"name=awsRegion, order=triggerMetadata;authParams, optional"` | |||
AwsRegion string `keda:"name=awsRegion, order=triggerMetadata;authParams, optional"` | |||
Timeout int `keda:"name=timeout, order=triggerMetadata, optional"` // custom HTTP client timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense supporting time.Duration
as input type? it's more explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Jorge. Innw @wozniakjan, we can modify this existing method to support new input type
keda/pkg/scalers/scalersconfig/typed_config.go
Lines 394 to 430 in 30b6b9a
func setConfigValueHelper(params Params, valFromConfig string, field reflect.Value) error { | |
paramValue := reflect.ValueOf(valFromConfig) | |
if paramValue.Type().AssignableTo(field.Type()) { | |
field.SetString(valFromConfig) | |
return nil | |
} | |
if paramValue.Type().ConvertibleTo(field.Type()) { | |
field.Set(paramValue.Convert(field.Type())) | |
return nil | |
} | |
if field.Type() == reflect.TypeOf(url.Values{}) { | |
return setConfigValueURLParams(params, valFromConfig, field) | |
} | |
if field.Kind() == reflect.Map { | |
return setConfigValueMap(params, valFromConfig, field) | |
} | |
if field.Kind() == reflect.Slice { | |
return setConfigValueSlice(params, valFromConfig, field) | |
} | |
if field.Kind() == reflect.Bool { | |
boolVal, err := strconv.ParseBool(valFromConfig) | |
if err != nil { | |
return fmt.Errorf("unable to parse boolean value %q: %w", valFromConfig, err) | |
} | |
field.SetBool(boolVal) | |
return nil | |
} | |
if field.CanInterface() { | |
ifc := reflect.New(field.Type()).Interface() | |
if err := json.Unmarshal([]byte(valFromConfig), &ifc); err != nil { | |
return fmt.Errorf("unable to unmarshal to field type %v: %w", field.Type(), err) | |
} | |
field.Set(reflect.ValueOf(ifc).Elem()) | |
return nil | |
} | |
return fmt.Errorf("unable to find matching parser for field type %v", field.Type()) | |
} |
Timeout in miliseconds for these specific triggers. This value will override the value defined in
KEDA_HTTP_DEFAULT_TIMEOUT
Checklist
Relates to #6603