-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add configurable API Timeout #515
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ import ( | |
// KeystoneAPIDefaults - | ||
type KeystoneAPIDefaults struct { | ||
ContainerImageURL string | ||
APITimeout int | ||
} | ||
|
||
var keystoneAPIDefaults KeystoneAPIDefaults | ||
|
@@ -48,6 +49,7 @@ var keystoneapilog = logf.Log.WithName("keystoneapi-resource") | |
// SetupKeystoneAPIDefaults - initialize KeystoneAPI spec defaults for use with either internal or external webhooks | ||
func SetupKeystoneAPIDefaults(defaults KeystoneAPIDefaults) { | ||
keystoneAPIDefaults = defaults | ||
|
||
keystoneapilog.Info("KeystoneAPI defaults initialized", "defaults", defaults) | ||
} | ||
|
||
|
@@ -81,7 +83,9 @@ func (spec *KeystoneAPISpec) Default() { | |
// Default - set defaults for this KeystoneAPI core spec | ||
// NOTE: only this version is used by OpenStackOperators webhook | ||
func (spec *KeystoneAPISpecCore) Default() { | ||
// no defaults to set yet | ||
if spec.APITimeout == 0 { | ||
spec.APITimeout = keystoneAPIDefaults.APITimeout | ||
} | ||
} | ||
|
||
// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation. | ||
|
@@ -167,3 +171,25 @@ func (r *KeystoneAPI) ValidateDelete() (admission.Warnings, error) { | |
// TODO(user): fill in your validation logic upon object deletion. | ||
return nil, nil | ||
} | ||
|
||
// SetDefaultRouteAnnotations sets HAProxy timeout values of the route | ||
func (spec *KeystoneAPISpecCore) SetDefaultRouteAnnotations(annotations map[string]string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What calls this function? I don't see it being called explicitly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's being called from the openstack-operator - https://github.com/openstack-k8s-operators/openstack-operator/pull/1223/files#diff-fcb2ae5fc2510a906947042c693c1d054971fa6a901ef6013b4d4c91138a9839R775 |
||
const haProxyAnno = "haproxy.router.openshift.io/timeout" | ||
// Use a custom annotation to flag when the operator has set the default HAProxy timeout | ||
// With the annotation func determines when to overwrite existing HAProxy timeout with the APITimeout | ||
const keystoneAnno = "api.keystone.openstack.org/timeout" | ||
valKeystoneAPI, okKeystoneAPI := annotations[keystoneAnno] | ||
valHAProxy, okHAProxy := annotations[haProxyAnno] | ||
// Human operator set the HAProxy timeout manually | ||
if !okKeystoneAPI && okHAProxy { | ||
return | ||
} | ||
// Human operator modified the HAProxy timeout manually without removing the Keystone flag | ||
if okKeystoneAPI && okHAProxy && valKeystoneAPI != valHAProxy { | ||
delete(annotations, keystoneAnno) | ||
return | ||
} | ||
timeout := fmt.Sprintf("%ds", spec.APITimeout) | ||
annotations[keystoneAnno] = timeout | ||
annotations[haProxyAnno] = 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.
also need to handle 0 ApiTimeout in webhook https://github.com/search?q=org%3Aopenstack-k8s-operators%20%22spec.APITimeout%20%3D%3D%200%22&type=code