Skip to content

Commit

Permalink
Merge pull request #244 from 3scale-ops/feat/add-sphinx-batch
Browse files Browse the repository at this point in the history
Feat/Add sphinx batch size field to System CR
  • Loading branch information
3scale-robot authored Jan 19, 2023
2 parents e4b75b0 + f97381e commit cb4bab9
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 16 deletions.
6 changes: 6 additions & 0 deletions api/v1alpha1/system_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ var (
systemDefaultSphinxPort int32 = 9306
systemDefaultSphinxBindAddress string = "0.0.0.0"
systemDefaultSphinxConfigFile string = "/opt/system/db/sphinx/sphinx.conf"
systemDefaultSphinxBatchSize int32 = 100
systemDefaultSphinxDBPath string = "/opt/system/db/sphinx"
systemDefaultSphinxDatabaseStorageSize string = "30Gi"
systemDefaultSphinxPIDFile string = "/opt/system/tmp/pids/searchd.pid"
Expand Down Expand Up @@ -794,6 +795,10 @@ type ThinkingSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
ConfigFile *string `json:"configFile,omitempty"`
// Sphinx batch size
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
BatchSize *int32 `json:"batchSize,omitempty"`
// Sphinx database path
// +operator-sdk:csv:customresourcedefinitions:type=spec
// +optional
Expand All @@ -817,6 +822,7 @@ func (tc *ThinkingSpec) Default() {
tc.Port = intOrDefault(tc.Port, pointer.Int32Ptr(systemDefaultSphinxPort))
tc.BindAddress = stringOrDefault(tc.BindAddress, pointer.StringPtr(systemDefaultSphinxBindAddress))
tc.ConfigFile = stringOrDefault(tc.ConfigFile, pointer.StringPtr(systemDefaultSphinxConfigFile))
tc.BatchSize = intOrDefault(tc.BatchSize, pointer.Int32Ptr(systemDefaultSphinxBatchSize))
tc.DatabasePath = stringOrDefault(tc.DatabasePath, pointer.StringPtr(systemDefaultSphinxDBPath))
tc.PIDFile = stringOrDefault(tc.PIDFile, pointer.StringPtr(systemDefaultSphinxPIDFile))
if tc.DatabaseStorageSize == nil {
Expand Down
5 changes: 5 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: 3 additions & 0 deletions bundle/manifests/saas-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3672,6 +3672,9 @@ spec:
- description: Thinking configuration for sphinx
displayName: Thinking
path: sphinx.config.thinking
- description: Sphinx batch size
displayName: Batch Size
path: sphinx.config.thinking.batchSize
- description: Allows setting the TCP host for Sphinx to a different address
displayName: Bind Address
path: sphinx.config.thinking.bindAddress
Expand Down
8 changes: 4 additions & 4 deletions bundle/manifests/saas.3scale.net_apicasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
Expand Down Expand Up @@ -1000,8 +1000,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
Expand Down
4 changes: 2 additions & 2 deletions bundle/manifests/saas.3scale.net_backends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
Expand Down
4 changes: 2 additions & 2 deletions bundle/manifests/saas.3scale.net_echoapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
Expand Down
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 @@ -2792,6 +2792,10 @@ spec:
thinking:
description: Thinking configuration for sphinx
properties:
batchSize:
description: Sphinx batch size
format: int32
type: integer
bindAddress:
description: Allows setting the TCP host for Sphinx to
a different address
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/saas.3scale.net_apicasts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
Expand Down Expand Up @@ -1001,8 +1001,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/saas.3scale.net_backends.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
Expand Down
4 changes: 2 additions & 2 deletions config/crd/bases/saas.3scale.net_echoapis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ spec:
properties:
dynamicConfigs:
additionalProperties:
maxProperties: 1
minProperties: 1
maxProperties: 2
minProperties: 2
properties:
cluster:
description: Cluster contains options for an Envoy cluster
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 @@ -2793,6 +2793,10 @@ spec:
thinking:
description: Thinking configuration for sphinx
properties:
batchSize:
description: Sphinx batch size
format: int32
type: integer
bindAddress:
description: Allows setting the TCP host for Sphinx to
a different address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3184,6 +3184,9 @@ spec:
- description: Thinking configuration for sphinx
displayName: Thinking
path: sphinx.config.thinking
- description: Sphinx batch size
displayName: Batch Size
path: sphinx.config.thinking.batchSize
- description: Allows setting the TCP host for Sphinx to a different address
displayName: Bind Address
path: sphinx.config.thinking.bindAddress
Expand Down
1 change: 1 addition & 0 deletions docs/api-reference/reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ ThinkingSpec configures the thinking library for sphinx
| *`port`* __integer__ | The TCP port Sphinx will run its daemon on
| *`bindAddress`* __string__ | Allows setting the TCP host for Sphinx to a different address
| *`configFile`* __string__ | Sphinx configuration file path
| *`batchSize`* __integer__ | Sphinx batch size
| *`databasePath`* __string__ | Sphinx database path
| *`databaseStorageSize`* __Quantity__ | Sphinx database storage size
| *`databaseStorageClass`* __string__ | Sphinx database storage type
Expand Down
2 changes: 2 additions & 0 deletions pkg/generators/system/config/sphinx_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type SphinxOptions struct {
SphinxPort pod.EnvVarValue `env:"THINKING_SPHINX_PORT"`
SphinxPIDFile pod.EnvVarValue `env:"THINKING_SPHINX_PID_FILE"`
SphinxConfigurationFile pod.EnvVarValue `env:"THINKING_SPHINX_CONFIGURATION_FILE"`
SphinxBatchSize pod.EnvVarValue `env:"THINKING_SPHINX_BATCH_SIZE"`

RailsEnvironment pod.EnvVarValue `env:"RAILS_ENV"`
SecretKeyBase pod.EnvVarValue `env:"SECRET_KEY_BASE"`
Expand All @@ -32,6 +33,7 @@ func NewSphinxOptions(spec saasv1alpha1.SystemSpec) SphinxOptions {
SphinxPort: &pod.ClearTextValue{Value: fmt.Sprintf("%d", *spec.Sphinx.Config.Thinking.Port)},
SphinxPIDFile: &pod.ClearTextValue{Value: *spec.Sphinx.Config.Thinking.PIDFile},
SphinxConfigurationFile: &pod.ClearTextValue{Value: *spec.Sphinx.Config.Thinking.ConfigFile},
SphinxBatchSize: &pod.ClearTextValue{Value: fmt.Sprintf("%d", *spec.Sphinx.Config.Thinking.BatchSize)},
RailsEnvironment: &pod.ClearTextValue{Value: *spec.Config.Rails.Environment},
SecretKeyBase: &pod.ClearTextValue{Value: "dummy"}, // https://github.com/rails/rails/issues/32947
DatabaseURL: &pod.SecretValue{Value: spec.Config.DatabaseDSN},
Expand Down

0 comments on commit cb4bab9

Please sign in to comment.