Skip to content
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

Added a parameter 'apiTimeout' to allow customization #891

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/bases/nova.openstack.org_nova.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ spec:
type: string
type: object
type: object
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
cellTemplates:
additionalProperties:
description: NovaCellTemplate defines the input parameters specified
Expand Down
5 changes: 5 additions & 0 deletions api/bases/nova.openstack.org_novaapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ spec:
description: APIDatabaseHostname - hostname to use when accessing
the API DB
type: string
apiTimeout:
default: 600
description: APITimeout for Route and Apache
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt the route timeout be condired by the existing service override?

Copy link
Contributor

@bogdando bogdando Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is likely another timeout, or how would that help to have it shown up in templates/novametadata/config/httpd.conf ?

Copy link
Contributor

@bogdando bogdando Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however, we need to document that timouts set for APIs and haproxy configs in routes/ingress must match

minimum: 60
type: integer
cell0DatabaseAccount:
default: nova-cell0
description: APIDatabaseAccount - MariaDBAccount to use when accessing
Expand Down
5 changes: 5 additions & 0 deletions api/bases/nova.openstack.org_novacells.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ spec:
filed is Required for cell0. TODO(gibi): Add a webhook to validate
cell0 constraint'
type: string
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
cellDatabaseAccount:
default: nova
description: CellDatabaseAccount - MariaDBAccount to use when accessing
Expand Down
5 changes: 5 additions & 0 deletions api/bases/nova.openstack.org_novametadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ spec:
the API DB. This filed is Required if the CellName is not provided
TODO(gibi): Add a webhook to validate the CellName constraint'
type: string
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
cellDatabaseAccount:
default: nova
description: CellDatabaseAccount - MariaDBAccount to use when accessing
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/nova_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ type NovaSpecCore struct {
// APIDatabaseAccount - MariaDBAccount to use when accessing the API DB
APIDatabaseAccount string `json:"apiDatabaseAccount"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=600
// +kubebuilder:validation:Minimum=60
// APITimeout for Route and Apache
APITimeout int `json:"apiTimeout"`

// +kubebuilder:validation:Required
// Secret is the name of the Secret instance containing password
// information for nova like the keystone service password and DB passwords
Expand Down
27 changes: 27 additions & 0 deletions api/v1beta1/nova_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,33 @@ func (r *Nova) ValidateDelete() (admission.Warnings, error) {
return nil, nil
}

// SetDefaultRouteAnnotations sets HAProxy timeout values of the route
// NOTE: it is used by ctlplane webhook on openstack-operator
func (r *NovaSpec) SetDefaultRouteAnnotations(annotations map[string]string) {
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 novaAnno = "api.nova.openstack.org/timeout"

valNova, okNova := annotations[novaAnno]
valHAProxy, okHAProxy := annotations[haProxyAnno]

// Human operator set the HAProxy timeout manually
if !okNova && okHAProxy {
return
}

// Human operator modified the HAProxy timeout manually without removing the Heat flag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Heat/Nova?

if okNova && okHAProxy && valNova != valHAProxy {
delete(annotations, novaAnno)
return
}

timeout := fmt.Sprintf("%ds", r.APITimeout)
annotations[novaAnno] = timeout
annotations[haProxyAnno] = timeout
}

// Validate the field values
func (r *NovaCellDBPurge) Validate(basePath *field.Path) field.ErrorList {
var errors field.ErrorList
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/novaapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ type NovaAPISpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// +kubebuilder:validation:Optional
// +kubebuilder:default=600
// +kubebuilder:validation:Minimum=60
// APITimeout for Route and Apache
APITimeout int `json:"apiTimeout"`

// +kubebuilder:validation:Required
// Secret is the name of the Secret instance containing password
// information for the nova-api service. This secret is expected to be
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/novacell_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ type NovaCellSpec struct {
// the deployment.
CellName string `json:"cellName"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=600
// +kubebuilder:validation:Minimum=60
// APITimeout for Route and Apache
APITimeout int `json:"apiTimeout"`

// +kubebuilder:validation:Required
// Secret is the name of the Secret instance containing password
// information for the nova cell. This secret is expected to be
Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/novametadata_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ type NovaMetadataSpec struct {
// If not provided then the metadata serving every cells in the deployment
CellName string `json:"cellName,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=600
// +kubebuilder:validation:Minimum=60
// APITimeout for Route and Apache
APITimeout int `json:"apiTimeout"`

// +kubebuilder:validation:Required
// Secret is the name of the Secret instance containing password
// information for the nova-conductor service. This secret is expected to
Expand Down Expand Up @@ -265,6 +271,7 @@ func NewNovaMetadataSpec(
TLS: novaCell.MetadataServiceTemplate.TLS,
DefaultConfigOverwrite: novaCell.MetadataServiceTemplate.DefaultConfigOverwrite,
MemcachedInstance: novaCell.MemcachedInstance,
APITimeout: novaCell.APITimeout,
}
return metadataSpec
}
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/nova.openstack.org_nova.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ spec:
type: string
type: object
type: object
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
cellTemplates:
additionalProperties:
description: NovaCellTemplate defines the input parameters specified
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/nova.openstack.org_novaapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ spec:
description: APIDatabaseHostname - hostname to use when accessing
the API DB
type: string
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
cell0DatabaseAccount:
default: nova-cell0
description: APIDatabaseAccount - MariaDBAccount to use when accessing
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/nova.openstack.org_novacells.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ spec:
filed is Required for cell0. TODO(gibi): Add a webhook to validate
cell0 constraint'
type: string
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
cellDatabaseAccount:
default: nova
description: CellDatabaseAccount - MariaDBAccount to use when accessing
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/nova.openstack.org_novametadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ spec:
the API DB. This filed is Required if the CellName is not provided
TODO(gibi): Add a webhook to validate the CellName constraint'
type: string
apiTimeout:
default: 600
description: APITimeout for Route and Apache
minimum: 60
type: integer
cellDatabaseAccount:
default: nova
description: CellDatabaseAccount - MariaDBAccount to use when accessing
Expand Down
3 changes: 3 additions & 0 deletions controllers/nova_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ func (r *NovaReconciler) ensureCell(
ServiceUser: instance.Spec.ServiceUser,
KeystoneAuthURL: keystoneAuthURL,
ServiceAccount: instance.RbacResourceName(),
APITimeout: instance.Spec.APITimeout,
// The assumption is that the CA bundle for ironic compute in the cell
// and the conductor in the cell always the same as the NovaAPI
TLS: instance.Spec.APIServiceTemplate.TLS.Ca,
Expand Down Expand Up @@ -1279,6 +1280,7 @@ func (r *NovaReconciler) ensureAPI(
TLS: instance.Spec.APIServiceTemplate.TLS,
DefaultConfigOverwrite: instance.Spec.APIServiceTemplate.DefaultConfigOverwrite,
MemcachedInstance: getMemcachedInstance(instance, cell0Template),
APITimeout: instance.Spec.APITimeout,
}
api := &novav1.NovaAPI{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1708,6 +1710,7 @@ func (r *NovaReconciler) ensureMetadata(
TLS: instance.Spec.MetadataServiceTemplate.TLS,
DefaultConfigOverwrite: instance.Spec.MetadataServiceTemplate.DefaultConfigOverwrite,
MemcachedInstance: getMemcachedInstance(instance, cell0Template),
APITimeout: instance.Spec.APITimeout,
}
metadata = &novav1.NovaMetadata{
ObjectMeta: metav1.ObjectMeta{
Expand Down
2 changes: 2 additions & 0 deletions controllers/novaapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,15 @@ func (r *NovaAPIReconciler) generateConfigs(
endptConfig := map[string]interface{}{}
endptConfig["ServerName"] = fmt.Sprintf("nova-%s.%s.svc", endpt.String(), instance.Namespace)
endptConfig["tls"] = false // default TLS to false, and set it bellow to true if enabled
endptConfig["TimeOut"] = instance.Spec.APITimeout
if instance.Spec.TLS.API.Enabled(endpt) {
templateParameters["tls"] = true
endptConfig["tls"] = true
endptConfig["SSLCertificateFile"] = fmt.Sprintf("/etc/pki/tls/certs/%s.crt", endpt.String())
endptConfig["SSLCertificateKeyFile"] = fmt.Sprintf("/etc/pki/tls/private/%s.key", endpt.String())
}
httpdVhostConfig[endpt.String()] = endptConfig

}
templateParameters["VHosts"] = httpdVhostConfig

Expand Down
1 change: 1 addition & 0 deletions controllers/novametadata_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ func (r *NovaMetadataReconciler) generateConfigs(
"MemcachedServers": memcachedInstance.GetMemcachedServerListString(),
"MemcachedServersWithInet": memcachedInstance.GetMemcachedServerListWithInetString(),
"MemcachedTLS": memcachedInstance.GetMemcachedTLSSupport(),
"TimeOut": instance.Spec.APITimeout,
}

var db *mariadbv1.Database
Expand Down
1 change: 1 addition & 0 deletions templates/novaapi/config/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ LogLevel info
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded

ServerName {{ $vhost.ServerName }}
TimeOut {{ $vhost.TimeOut }}

## Vhost docroot
DocumentRoot "/var/www/cgi-bin"
Expand Down
1 change: 1 addition & 0 deletions templates/novametadata/config/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ LogLevel info
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded

ServerName {{ .ServerName }}
TimeOut {{ .TimeOut }}

ErrorLog /dev/stdout
CustomLog /dev/stdout combined env=!forwarded
Expand Down
2 changes: 2 additions & 0 deletions test/functional/nova_metadata_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ var _ = Describe("NovaMetadata controller", func() {
Expect(configData).Should(ContainSubstring("SSLEngine on"))
Expect(configData).Should(ContainSubstring("SSLCertificateFile \"/etc/pki/tls/certs/nova-metadata.crt\""))
Expect(configData).Should(ContainSubstring("SSLCertificateKeyFile \"/etc/pki/tls/private/nova-metadata.key\""))
Expect(configData).Should(
ContainSubstring("TimeOut 600"))

configData = string(configDataMap.Data["01-nova.conf"])
Expect(configData).Should(
Expand Down
8 changes: 8 additions & 0 deletions test/functional/nova_multicell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,14 @@ var _ = Describe("Nova multi cell", func() {
HaveKeyWithValue(controllers.MetadataSecretSelector, []byte("metadata-secret")))
Expect(cell0Secret.Data).NotTo(
HaveKeyWithValue(controllers.MetadataSecretSelector, []byte("metadata-secret-cell1")))
configDataMap := th.GetSecret(cell1.MetadataConfigDataName)
Expect(configDataMap).ShouldNot(BeNil())
Expect(configDataMap.Data).Should(HaveKey("httpd.conf"))
Expect(configDataMap.Data).Should(HaveKey("ssl.conf"))
configData := string(configDataMap.Data["httpd.conf"])
Expect(configData).Should(
ContainSubstring("TimeOut 600"))

})
})
})
2 changes: 2 additions & 0 deletions test/functional/novaapi_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ var _ = Describe("NovaAPI controller", func() {
Expect(configData).Should(ContainSubstring("SSLCertificateKeyFile \"/etc/pki/tls/private/internal.key\""))
Expect(configData).Should(ContainSubstring("SSLCertificateFile \"/etc/pki/tls/certs/public.crt\""))
Expect(configData).Should(ContainSubstring("SSLCertificateKeyFile \"/etc/pki/tls/private/public.key\""))
Expect(configData).Should(
ContainSubstring("TimeOut 600"))

configData = string(configDataMap.Data["01-nova.conf"])
Expect(configData).Should(
Expand Down
Loading