Skip to content

Commit

Permalink
Merge pull request #261 from 3scale-ops/feat/sphinx-batch-size
Browse files Browse the repository at this point in the history
Feat/Add sphinx/searchd batch size field
  • Loading branch information
3scale-robot authored May 22, 2023
2 parents 4b9f6e6 + 7425819 commit 0516d62
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# To re-generate a bundle for another specific version without changing the standard setup, you can:
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
VERSION ?= 0.19.7
VERSION ?= 0.19.8-alpha.2

# CHANNELS define the bundle channels used in the bundle.
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
Expand Down
26 changes: 19 additions & 7 deletions api/v1alpha1/system_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ var (
SelectorKey: pointer.String("monitoring-key"),
SelectorValue: pointer.String("middleware"),
}
systemDefaultTerminationGracePeriodSeconds *int64 = pointer.Int64(60)
systemDefaultSearchServerAddress AddressSpec = AddressSpec{
Host: pointer.String("system-sphinx"),
Port: pointer.Int32(9306),
systemDefaultTerminationGracePeriodSeconds *int64 = pointer.Int64(60)
systemDefaultSearchServer SearchServerSpec = SearchServerSpec{
AddressSpec: AddressSpec{
Host: pointer.String("system-sphinx"),
Port: pointer.Int32(9306),
},
BatchSize: pointer.Int32(100),
}

// App
Expand Down Expand Up @@ -335,6 +338,14 @@ func (spec *SystemSpec) Default() {

}

type SearchServerSpec struct {
AddressSpec `json:",inline"`
// Defines the batch size
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
BatchSize *int32 `json:"batchSize,omitempty"`
}

// SystemConfig holds configuration for SystemApp component
type SystemConfig struct {
// Rails configuration options for system components
Expand All @@ -356,7 +367,7 @@ type SystemConfig struct {
// Search service options
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
SearchServer AddressSpec `json:"searchServer,omitempty"`
SearchServer SearchServerSpec `json:"searchServer,omitempty"`
// 3scale provider plan
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
Expand Down Expand Up @@ -453,8 +464,9 @@ func (sc *SystemConfig) Default() {
sc.ExternalSecret.SecretStoreRef = InitializeExternalSecretSecretStoreReferenceSpec(sc.ExternalSecret.SecretStoreRef, defaultExternalSecretSecretStoreReference)
sc.ExternalSecret.RefreshInterval = durationOrDefault(sc.ExternalSecret.RefreshInterval, &defaultExternalSecretRefreshInterval)

sc.SearchServer.Host = stringOrDefault(sc.SearchServer.Host, systemDefaultSearchServerAddress.Host)
sc.SearchServer.Port = intOrDefault(sc.SearchServer.Port, systemDefaultSearchServerAddress.Port)
sc.SearchServer.Host = stringOrDefault(sc.SearchServer.Host, systemDefaultSearchServer.Host)
sc.SearchServer.Port = intOrDefault(sc.SearchServer.Port, systemDefaultSearchServer.Port)
sc.SearchServer.BatchSize = intOrDefault(sc.SearchServer.BatchSize, systemDefaultSearchServer.BatchSize)

}

Expand Down
21 changes: 21 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=saas-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha,stable
LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.27.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
Expand Down
11 changes: 7 additions & 4 deletions bundle/manifests/saas-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,15 @@ metadata:
capabilities: Basic Install
categories: Integration & Delivery
containerImage: quay.io/3scale/saas-operator
createdAt: "2023-05-09T08:16:49Z"
createdAt: "2023-05-22T11:05:17Z"
description: |-
The 3scale SaaS Operator creates and maintains a SaaS-ready deployment
of the Red Hat 3scale API Management on OpenShift.
operators.operatorframework.io/builder: operator-sdk-v1.27.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/3scale/saas-operator
support: Red Hat
name: saas-operator.v0.19.7
name: saas-operator.v0.19.8-alpha.2
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -3096,6 +3096,9 @@ spec:
- description: Search service options
displayName: Search Server
path: config.searchServer
- description: Defines the batch size
displayName: Batch Size
path: config.searchServer.batchSize
- description: Defines the address host
displayName: Host
path: config.searchServer.host
Expand Down Expand Up @@ -4453,7 +4456,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']
image: quay.io/3scale/saas-operator:v0.19.7
image: quay.io/3scale/saas-operator:v0.19.8-alpha.2
livenessProbe:
httpGet:
path: /healthz
Expand Down Expand Up @@ -4967,4 +4970,4 @@ spec:
provider:
name: Red Hat
url: https://www.3scale.net/
version: 0.19.7
version: 0.19.8-alpha.2
4 changes: 4 additions & 0 deletions bundle/manifests/saas.3scale.net_systems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,10 @@ spec:
searchServer:
description: Search service options
properties:
batchSize:
description: Defines the batch size
format: int32
type: integer
host:
description: Defines the address host
type: string
Expand Down
3 changes: 1 addition & 2 deletions bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ annotations:
operators.operatorframework.io.bundle.manifests.v1: manifests/
operators.operatorframework.io.bundle.metadata.v1: metadata/
operators.operatorframework.io.bundle.package.v1: saas-operator
operators.operatorframework.io.bundle.channels.v1: alpha,stable
operators.operatorframework.io.bundle.channel.default.v1: alpha
operators.operatorframework.io.bundle.channels.v1: alpha
operators.operatorframework.io.metrics.builder: operator-sdk-v1.27.0
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/saas.3scale.net_systems.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,10 @@ spec:
searchServer:
description: Search service options
properties:
batchSize:
description: Defines the batch size
format: int32
type: integer
host:
description: Defines the address host
type: string
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/3scale/saas-operator
newTag: v0.19.7
newTag: v0.19.8-alpha.2
Original file line number Diff line number Diff line change
Expand Up @@ -2608,6 +2608,9 @@ spec:
- description: Search service options
displayName: Search Server
path: config.searchServer
- description: Defines the batch size
displayName: Batch Size
path: config.searchServer.batchSize
- description: Defines the address host
displayName: Host
path: config.searchServer.host
Expand Down
11 changes: 8 additions & 3 deletions controllers/system_controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ var _ = Describe("System controller", func() {
k8sClient, &appsv1.Deployment{}, "system-app", namespace, timeout, poll)

patch := client.MergeFrom(system.DeepCopy())
system.Spec.Config.SearchServer = saasv1alpha1.AddressSpec{
Host: pointer.String("system-searchd"),
Port: pointer.Int32(1234),
system.Spec.Config.SearchServer = saasv1alpha1.SearchServerSpec{
AddressSpec: saasv1alpha1.AddressSpec{
Host: pointer.String("system-searchd"),
Port: pointer.Int32(1234),
},
BatchSize: pointer.Int32(222),
}

system.Spec.Searchd = &saasv1alpha1.SystemSearchdSpec{
Expand Down Expand Up @@ -433,6 +436,8 @@ var _ = Describe("System controller", func() {
Expect(env.Value).To(Equal("system-searchd"))
case "THINKING_SPHINX_PORT":
Expect(env.Value).To(Equal("1234"))
case "THINKING_SPHINX_BATCH_SIZE":
Expect(env.Value).To(Equal("222"))
}
}

Expand Down
22 changes: 20 additions & 2 deletions docs/api-reference/reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ AddressSpec allows the definition of an address

.Appears In:
****
- xref:{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-systemconfig[$$SystemConfig$$]
- xref:{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-searchserverspec[$$SearchServerSpec$$]
****

[cols="25a,75a", options="header"]
Expand Down Expand Up @@ -1323,6 +1323,24 @@ SMTPSpec has options to configure system's SMTP
|===


[id="{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-searchserverspec"]
==== SearchServerSpec



.Appears In:
****
- xref:{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-systemconfig[$$SystemConfig$$]
****

[cols="25a,75a", options="header"]
|===
| Field | Description
| *`AddressSpec`* __xref:{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-addressspec[$$AddressSpec$$]__ |
| *`batchSize`* __integer__ | Defines the batch size
|===


[id="{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-searchdconfig"]
==== SearchdConfig

Expand Down Expand Up @@ -1633,7 +1651,7 @@ SystemConfig holds configuration for SystemApp component
| *`sandboxProxyOpensslVerifyMode`* __string__ | OpenSSL verification mode for sandbox proxy
| *`forceSSL`* __boolean__ | Enable (true) or disable (false) enforcing SSL
| *`sslCertsDir`* __string__ | SSL certificates path
| *`searchServer`* __xref:{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-addressspec[$$AddressSpec$$]__ | Search service options
| *`searchServer`* __xref:{anchor_prefix}-github-com-3scale-saas-operator-api-v1alpha1-searchserverspec[$$SearchServerSpec$$]__ | Search service options
| *`threescaleProviderPlan`* __string__ | 3scale provider plan
| *`threescaleSuperdomain`* __string__ | 3scale superdomain
| *`configFilesSecret`* __string__ | Secret containging system configuration files to be mounted in the pods
Expand Down
10 changes: 6 additions & 4 deletions pkg/generators/system/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type Options struct {
RailsLogLevel pod.EnvVarValue `env:"RAILS_LOG_LEVEL"`
RailsLogToStdout pod.EnvVarValue `env:"RAILS_LOG_TO_STDOUT"`

SearchServerAddress pod.EnvVarValue `env:"THINKING_SPHINX_ADDRESS"`
SearchServerPort pod.EnvVarValue `env:"THINKING_SPHINX_PORT"`
SearchServerAddress pod.EnvVarValue `env:"THINKING_SPHINX_ADDRESS"`
SearchServerPort pod.EnvVarValue `env:"THINKING_SPHINX_PORT"`
SearchServerBatchSize pod.EnvVarValue `env:"THINKING_SPHINX_BATCH_SIZE"`

DatabaseURL pod.EnvVarValue `env:"DATABASE_URL" secret:"system-database"`

Expand Down Expand Up @@ -94,8 +95,9 @@ func NewOptions(spec saasv1alpha1.SystemSpec) Options {
RailsLogLevel: &pod.ClearTextValue{Value: *spec.Config.Rails.LogLevel},
RailsLogToStdout: &pod.ClearTextValue{Value: "true"},

SearchServerAddress: &pod.ClearTextValue{Value: *spec.Config.SearchServer.Host},
SearchServerPort: &pod.ClearTextValue{Value: fmt.Sprintf("%d", *spec.Config.SearchServer.Port)},
SearchServerAddress: &pod.ClearTextValue{Value: *spec.Config.SearchServer.Host},
SearchServerPort: &pod.ClearTextValue{Value: fmt.Sprintf("%d", *spec.Config.SearchServer.Port)},
SearchServerBatchSize: &pod.ClearTextValue{Value: fmt.Sprintf("%d", *spec.Config.SearchServer.BatchSize)},

DatabaseURL: &pod.SecretValue{Value: spec.Config.DatabaseDSN},

Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package version

const (
version string = "v0.19.7"
version string = "v0.19.8-alpha.2"
)

// Current returns the current marin3r operator version
Expand Down

0 comments on commit 0516d62

Please sign in to comment.