Repository navigation
Support custom Lightspeed Stack configuration #145
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
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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ import ( | |
| "context" | ||
| _ "embed" // Required for go:embed directives in this package | ||
| "fmt" | ||
| "math" | ||
|
|
||
| common_helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper" | ||
| apiv1beta1 "github.com/openstack-k8s-operators/lightspeed-operator/api/v1beta1" | ||
|
|
@@ -155,8 +156,7 @@ func buildLCoreDatabaseConfig(h *common_helper.Helper, _ *apiv1beta1.OpenStackLi | |
| } | ||
| } | ||
|
|
||
| // buildLCoreCustomizationConfig configures system prompt customization | ||
| // Uses config field if set, otherwise falls back to default | ||
| // buildLCoreCustomizationConfig configures the system prompt. | ||
| func buildLCoreCustomizationConfig() map[string]interface{} { | ||
| return map[string]interface{}{ | ||
| "system_prompt": getSystemPrompt(), | ||
|
|
@@ -348,6 +348,25 @@ func buildLCoreConfigYAML(ctx context.Context, h *common_helper.Helper, instance | |
| config["quota_handlers"] = quotaHandlers | ||
| } | ||
|
|
||
| if instance.Spec.LCore != nil && instance.Spec.LCore.CustomServiceConfig != "" { | ||
| var customConfig map[string]interface{} | ||
| if err := yaml.UnmarshalStrict([]byte(instance.Spec.LCore.CustomServiceConfig), &customConfig); err != nil { | ||
| return "", fmt.Errorf("failed to parse spec.lcore.customServiceConfig as a YAML mapping: %w", err) | ||
| } | ||
| if customConfig == nil { | ||
| return "", fmt.Errorf("spec.lcore.customServiceConfig must be a YAML mapping") | ||
| } | ||
| if customization, ok := customConfig["customization"].(map[string]interface{}); ok { | ||
| if requestSize, exists := customization["responses_request_max_size"]; exists { | ||
| value, ok := requestSize.(float64) | ||
| if !ok || value < 1 || math.Trunc(value) != value { | ||
|
Collaborator
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. non-blocking: I'm wondering whether this is the right place to do the checking. It opens up a question of what to do with other config options we are overwriting ... Should we be checking their values as well? IMO when somebody touches the |
||
| return "", fmt.Errorf("spec.lcore.customServiceConfig customization.responses_request_max_size must be a positive integer") | ||
| } | ||
| } | ||
| } | ||
| mergeLCoreConfig(config, customConfig) | ||
|
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. Keep the configured listener port aligned with managed networking. When
|
||
| } | ||
|
|
||
| // Convert to YAML | ||
| yamlBytes, err := yaml.Marshal(config) | ||
| if err != nil { | ||
|
|
@@ -356,3 +375,16 @@ func buildLCoreConfigYAML(ctx context.Context, h *common_helper.Helper, instance | |
|
|
||
| return string(yamlBytes), nil | ||
| } | ||
|
|
||
| // mergeLCoreConfig recursively merges mappings, replacing other values with overrides. | ||
| func mergeLCoreConfig(config, overrides map[string]interface{}) { | ||
| for key, value := range overrides { | ||
| if customMap, ok := value.(map[string]interface{}); ok { | ||
| if generatedMap, ok := config[key].(map[string]interface{}); ok { | ||
| mergeLCoreConfig(generatedMap, customMap) | ||
| continue | ||
| } | ||
| } | ||
| config[key] = value | ||
|
Comment on lines
+380
to
+388
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. Protect the generated authentication setting from overrides. If
|
||
| } | ||
| } | ||
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.
nit (non-blocking): Commit message says:
When actually it introduces
spec.lcore.customServiceConfig(spec.lcore.customization.responsesRequestMaxSizewas never part of the code).