Skip to content

Commit 9065079

Browse files
committed
Enable OKP by default
* OKP is now enabled by default. * Drop the okp-configuration kuttl test and include OKP as part of the assertion of the other existing tests. Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
1 parent 967e602 commit 9065079

30 files changed

Lines changed: 161 additions & 574 deletions

api/v1beta1/openstacklightspeed_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const (
5454
// May change at any time without backward compatibility.
5555
//
5656
// Supported fields:
57-
// - featureFlags: list of experimental feature flags to enable (e.g. ["okp"])
57+
// - featureFlags: list of experimental feature flags to enable
5858
// - okpChunkFilterQuery: Solr filter query for OKP searches (default: version-aware query combining detected OpenStack and OCP versions)
5959
// - okpRagOnly: when true, only OKP is used as a RAG source (default: false)
6060
type DevSpec struct {

internal/controller/common.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"encoding/json"
2323
"errors"
2424
"fmt"
25-
"slices"
2625
"strings"
2726

2827
common_helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
@@ -142,12 +141,6 @@ func parseDevConfig(instance *apiv1beta1.OpenStackLightspeed) (apiv1beta1.DevSpe
142141
return config, nil
143142
}
144143

145-
// isOKPEnabled returns true if the "okp" feature flag is present in the dev config.
146-
func isOKPEnabled(instance *apiv1beta1.OpenStackLightspeed) bool {
147-
config, _ := parseDevConfig(instance)
148-
return slices.Contains(config.FeatureFlags, "okp")
149-
}
150-
151144
// getOKPChunkFilterQuery returns the chunk filter query from the dev config, or a version-aware default.
152145
func getOKPChunkFilterQuery(ctx context.Context, h *common_helper.Helper, instance *apiv1beta1.OpenStackLightspeed) string {
153146
config, _ := parseDevConfig(instance)

internal/controller/errors.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ var (
5555
// OKP Errors
5656
ErrCreateOKPDeployment = errors.New("failed to create OKP deployment")
5757
ErrCreateOKPService = errors.New("failed to create OKP service")
58-
ErrDeleteOKPDeployment = errors.New("failed to delete OKP deployment")
59-
ErrDeleteOKPService = errors.New("failed to delete OKP service")
6058

6159
// Postgres Errors
6260
ErrCreatePostgresDeployment = errors.New("failed to create Postgres deployment")

internal/controller/lcore_config.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,8 @@ func buildOKPConfig(ctx context.Context, h *common_helper.Helper, instance *apiv
220220
// buildLCoreConfigYAML assembles the complete Lightspeed Core Service configuration and converts to YAML.
221221
// NOTE: MCP servers, quota handlers, and tools approval features are disabled for OpenStack Lightspeed.
222222
func buildLCoreConfigYAML(ctx context.Context, h *common_helper.Helper, instance *apiv1beta1.OpenStackLightspeed) (string, error) {
223-
okpEnabled := isOKPEnabled(instance)
224223

225-
ragInline := []interface{}{}
226-
if okpEnabled {
227-
ragInline = append(ragInline, "okp")
228-
}
224+
ragInline := []interface{}{"okp"}
229225
ragConfig := map[string]interface{}{
230226
"inline": ragInline,
231227
}
@@ -245,9 +241,7 @@ func buildLCoreConfigYAML(ctx context.Context, h *common_helper.Helper, instance
245241
"rag": ragConfig,
246242
}
247243

248-
if okpEnabled {
249-
config["okp"] = buildOKPConfig(ctx, h, instance)
250-
}
244+
config["okp"] = buildOKPConfig(ctx, h, instance)
251245

252246
// Convert to YAML
253247
yamlBytes, err := yaml.Marshal(config)

internal/controller/lcore_deployment.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,7 @@ func buildInitContainers(
277277
"--enable-ocp-rag", strconv.FormatBool(instance.Spec.EnableOCPRAG),
278278
"--ocp-version", ocp_version,
279279
}
280-
if isOKPEnabled(instance) {
281-
cmd = append(cmd, "--enable-okp")
282-
}
280+
cmd = append(cmd, "--enable-okp")
283281
return cmd
284282
}(),
285283
SecurityContext: securityContext,
@@ -609,12 +607,10 @@ func buildLlamaStackEnvVars(h *common_helper.Helper, ctx context.Context, instan
609607
Value: VectorDBVolumeMountPath,
610608
})
611609

612-
if isOKPEnabled(instance) {
613-
envVars = append(envVars, corev1.EnvVar{
614-
Name: "RH_SERVER_OKP",
615-
Value: fmt.Sprintf("http://%s.%s.svc:%d", OKPServiceName, instance.GetNamespace(), OKPServicePort),
616-
})
617-
}
610+
envVars = append(envVars, corev1.EnvVar{
611+
Name: "RH_SERVER_OKP",
612+
Value: fmt.Sprintf("http://%s.%s.svc:%d", OKPServiceName, instance.GetNamespace(), OKPServicePort),
613+
})
618614

619615
return envVars, nil
620616
}
@@ -643,12 +639,10 @@ func buildLightspeedStackEnvVars(instance *apiv1beta1.OpenStackLightspeed) []cor
643639
},
644640
buildPostgresPasswordEnvVar(),
645641
}
646-
if isOKPEnabled(instance) {
647-
envVars = append(envVars, corev1.EnvVar{
648-
Name: "RH_SERVER_OKP",
649-
Value: fmt.Sprintf("http://%s.%s.svc:%d", OKPServiceName, instance.GetNamespace(), OKPServicePort),
650-
})
651-
}
642+
envVars = append(envVars, corev1.EnvVar{
643+
Name: "RH_SERVER_OKP",
644+
Value: fmt.Sprintf("http://%s.%s.svc:%d", OKPServiceName, instance.GetNamespace(), OKPServicePort),
645+
})
652646
return envVars
653647
}
654648

internal/controller/llama_stack_config.go

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,7 @@ func buildLlamaStackVectorDB(_ *common_helper.Helper, _ *apiv1beta1.OpenStackLig
256256

257257
func buildLlamaStackVectorIO(h *common_helper.Helper, instance *apiv1beta1.OpenStackLightspeed, chunkFilterQuery string) []interface{} {
258258
providers := buildLlamaStackVectorDB(h, instance)
259-
if isOKPEnabled(instance) {
260-
providers = append(providers, buildOKPVectorIOProvider(chunkFilterQuery))
261-
}
259+
providers = append(providers, buildOKPVectorIOProvider(chunkFilterQuery))
262260
return providers
263261
}
264262

@@ -378,32 +376,28 @@ func buildLlamaStackModels(_ *common_helper.Helper, instance *apiv1beta1.OpenSta
378376
}
379377
}
380378

381-
if isOKPEnabled(instance) {
382-
models = append(models, map[string]interface{}{
383-
"model_id": "solr_embedding",
384-
"model_type": "embedding",
385-
"provider_id": "sentence-transformers",
386-
"provider_model_id": OKPEmbeddingModelMountPath,
387-
"metadata": map[string]interface{}{
388-
"embedding_dimension": 384,
389-
},
390-
})
391-
}
379+
models = append(models, map[string]interface{}{
380+
"model_id": "solr_embedding",
381+
"model_type": "embedding",
382+
"provider_id": "sentence-transformers",
383+
"provider_model_id": OKPEmbeddingModelMountPath,
384+
"metadata": map[string]interface{}{
385+
"embedding_dimension": 384,
386+
},
387+
})
392388

393389
return models
394390
}
395391

396-
func buildLlamaStackVectorStores(_ *common_helper.Helper, instance *apiv1beta1.OpenStackLightspeed) []interface{} {
397-
stores := []interface{}{}
398-
if isOKPEnabled(instance) {
399-
stores = append(stores, map[string]interface{}{
392+
func buildLlamaStackVectorStores(_ *common_helper.Helper, _ *apiv1beta1.OpenStackLightspeed) []interface{} {
393+
return []interface{}{
394+
map[string]interface{}{
400395
"vector_store_id": "portal-rag",
401396
"provider_id": "okp_solr",
402397
"embedding_dimension": 384,
403398
"embedding_model": "sentence-transformers/" + OKPEmbeddingModelMountPath,
404-
})
399+
},
405400
}
406-
return stores
407401
}
408402

409403
func buildLlamaStackToolGroups(_ *common_helper.Helper, _ *apiv1beta1.OpenStackLightspeed) []interface{} {
@@ -426,11 +420,8 @@ func buildLlamaStackYAML(h *common_helper.Helper, ctx context.Context, instance
426420
return "", fmt.Errorf("failed to build inference providers: %w", err)
427421
}
428422

429-
okpChunkFilterQuery := ""
430-
if isOKPEnabled(instance) {
431-
config["external_providers_dir"] = ExternalProvidersDir
432-
okpChunkFilterQuery = getOKPChunkFilterQuery(ctx, h, instance)
433-
}
423+
config["external_providers_dir"] = ExternalProvidersDir
424+
okpChunkFilterQuery := getOKPChunkFilterQuery(ctx, h, instance)
434425

435426
// Build providers map - only include providers for enabled APIs
436427
config["providers"] = map[string]interface{}{

internal/controller/llama_stack_config_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,15 @@ var _ = Describe("Llama Stack config", func() {
135135
instance := getOpenStackLightspeedProvidersInstance(provider)
136136
modelsConfig := buildLlamaStackModels(nil, instance)
137137

138-
Expect(modelsConfig).To(HaveLen(1))
138+
Expect(modelsConfig).To(HaveLen(2))
139139

140140
modelConfig := modelsConfig[0].(map[string]interface{})
141141
checkModelCommonConfig(modelConfig, instance)
142+
143+
okpModel := modelsConfig[1].(map[string]interface{})
144+
Expect(okpModel["model_id"]).To(Equal("solr_embedding"))
145+
Expect(okpModel["model_type"]).To(Equal("embedding"))
146+
Expect(okpModel["provider_id"]).To(Equal("sentence-transformers"))
142147
},
143148
Entry("for openai", OpenAIProviderName),
144149
Entry("for gemini", GeminiProviderName),

internal/controller/okp_reconciler.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,21 @@ import (
2424
apiv1beta1 "github.com/openstack-k8s-operators/lightspeed-operator/api/v1beta1"
2525
appsv1 "k8s.io/api/apps/v1"
2626
corev1 "k8s.io/api/core/v1"
27-
"k8s.io/apimachinery/pkg/api/errors"
2827
"k8s.io/apimachinery/pkg/api/resource"
2928
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3029
"k8s.io/apimachinery/pkg/util/intstr"
3130
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3231
)
3332

3433
// ReconcileOKPDeployment reconciles the OKP Deployment and Service.
35-
// When OKP is disabled, it cleans up existing resources.
3634
func ReconcileOKPDeployment(h *common_helper.Helper, ctx context.Context, instance *apiv1beta1.OpenStackLightspeed) error {
37-
if !isOKPEnabled(instance) {
38-
return cleanupOKPResources(h, ctx)
39-
}
40-
4135
tasks := []ReconcileTask{
4236
{Name: "OKPDeployment", Task: reconcileOKPDeployment},
4337
{Name: "OKPService", Task: reconcileOKPService},
4438
}
4539
return ReconcileTasksFailFast(h, ctx, instance, tasks)
4640
}
4741

48-
func cleanupOKPResources(h *common_helper.Helper, ctx context.Context) error {
49-
logger := h.GetLogger()
50-
ns := h.GetBeforeObject().GetNamespace()
51-
52-
deploy := &appsv1.Deployment{}
53-
deploy.Name = OKPDeploymentName
54-
deploy.Namespace = ns
55-
if err := h.GetClient().Delete(ctx, deploy); err != nil && !errors.IsNotFound(err) {
56-
return fmt.Errorf("%w: %v", ErrDeleteOKPDeployment, err)
57-
}
58-
59-
svc := &corev1.Service{}
60-
svc.Name = OKPServiceName
61-
svc.Namespace = ns
62-
if err := h.GetClient().Delete(ctx, svc); err != nil && !errors.IsNotFound(err) {
63-
return fmt.Errorf("%w: %v", ErrDeleteOKPService, err)
64-
}
65-
66-
logger.Info("OKP resources cleaned up")
67-
return nil
68-
}
69-
7042
func reconcileOKPDeployment(h *common_helper.Helper, ctx context.Context, instance *apiv1beta1.OpenStackLightspeed) error {
7143
logger := h.GetLogger()
7244

test/kuttl/common/expected-configs/lightspeed-stack-okp.yaml

Lines changed: 0 additions & 97 deletions
This file was deleted.

test/kuttl/common/expected-configs/lightspeed-stack-update.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,13 @@ llama_stack:
7272
url: http://localhost:8321
7373
use_as_library_client: false
7474
name: Lightspeed Core Service (LCS)
75+
okp:
76+
chunk_filter_query: product:(*openstack* OR *openshift*)
77+
offline: true
78+
rhokp_url: ${env.RH_SERVER_OKP}
7579
rag:
7680
inline:
81+
- okp
7782
- vs_UUID
7883
service:
7984
access_log: true

0 commit comments

Comments
 (0)