Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
uses: redhat-actions/openshift-tools-installer@v1
with:
source: github
operator-sdk: 1.38.0
operator-sdk: 1.41.1

- name: Log in to Quay
uses: docker/login-action@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-generation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: redhat-actions/openshift-tools-installer@v1
with:
source: github
operator-sdk: 1.38.0
operator-sdk: 1.41.1

- name: Verify generated files are up to date and fail if anything changed
run: |
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ go.work
*.swp
*.swo
*~

# Kuttl test files
kubeconfig
kuttl-report-openstack-lightspeed.xml
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
FROM golang:1.24 AS builder
ARG TARGETOS
ARG TARGETARCH
ARG GOMAXPROCS

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -21,7 +22,7 @@ COPY internal/controller/ internal/controller/
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go
RUN GOMAXPROCS=${GOMAXPROCS} CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
24 changes: 20 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ endif

# Set the Operator SDK version to use. By default, what is installed on the system is used.
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
OPERATOR_SDK_VERSION ?= v1.38.0-ocp
OPERATOR_SDK_VERSION ?= v1.41.1
# Image URL to use all building/pushing image targets
IMG ?= $(IMAGE_TAG_BASE):latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Expand Down Expand Up @@ -146,7 +146,7 @@ lint-fix: golangci-lint ## Run golangci-lint linter and perform fixes

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager cmd/main.go
GOMAXPROCS=$(GOMAXPROCS) go build -o bin/manager cmd/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
Expand All @@ -157,7 +157,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ${IMG} .
$(CONTAINER_TOOL) build --build-arg GOMAXPROCS=$(GOMAXPROCS) -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand Down Expand Up @@ -219,10 +219,12 @@ openstack-lightspeed-deploy: ## Deploy using a catalog image.
oc apply -f $(OUTPUT_DIR)/rhosls
bash scripts/confirm-rhosls-running.sh

# Deploy using the catalog image.
# Undeploy using the catalog image.
# Remove OpenStackLightspeds so the namespace deletion doesn't get stuck
.PHONY: openstack-lightspeed-undeploy
openstack-lightspeed-undeploy: export OUTPUT_DIR = out
openstack-lightspeed-undeploy: ## Undeploy using a catalog image.
oc delete openstacklightspeed --all -n openstack-lightspeed --ignore-not-found=true --timeout=120s
find out/{catalog,rhosls} -name "*.yaml" -printf " -f %p" | xargs oc delete --ignore-not-found=true

CATALOG_NAME ?= openstack-lightspeed-catalog
Expand Down Expand Up @@ -299,6 +301,20 @@ kuttl-test-ocp: BUNDLE_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/oper
kuttl-test-ocp: CATALOG_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-catalog:$(TAG)
kuttl-test-ocp: docker-build bundle bundle-build ocp-catalog-build ocp-registry-push kuttl-test-run

.PHONY: ocp-deploy
ocp-deploy: IMG = $(OCP_INTERNAL_REGISTRY)/$(OCP_REGISTRY_NAMESPACE)/operator:latest
ocp-deploy: BUNDLE_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-bundle:$(TAG)
ocp-deploy: CATALOG_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-catalog:$(TAG)
ocp-deploy: docker-build bundle bundle-build ocp-catalog-build ocp-registry-push openstack-lightspeed-deploy

.PHONY: ocp-deploy-cleanup
ocp-deploy-cleanup: IMG = $(OCP_INTERNAL_REGISTRY)/$(OCP_REGISTRY_NAMESPACE)/operator:latest
ocp-deploy-cleanup: BUNDLE_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-bundle:$(TAG)
ocp-deploy-cleanup: CATALOG_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-catalog:$(TAG)
ocp-deploy-cleanup: openstack-lightspeed-undeploy ## Clean up everything created by ocp-deploy.
oc delete imagestreamtag operator-catalog:$(TAG) -n openshift-marketplace --ignore-not-found=true
oc delete namespace $(OCP_REGISTRY_NAMESPACE) --ignore-not-found=true --wait

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
Expand Down
22 changes: 22 additions & 0 deletions api/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const (
// operational and it can be used by OpenStack Lightspeed operator.
OpenShiftLightspeedOperatorReadyCondition condition.Type = "OpenShiftLightspeedOperatorReady"

// OpenStackLightspeedMCPServerReadyCondition is set to True when the MCP server
// deployment succeeds. False indicates a failure during MCP server deployment.
OpenStackLightspeedMCPServerReadyCondition condition.Type = "OpenStackLightspeedMCPServerReady"

// OCPRAGCondition Status=True condition which indicates the OCP RAG version resolution status
OCPRAGCondition condition.Type = "OCPRAGReady"
)
Expand Down Expand Up @@ -64,6 +68,24 @@ const (
// OCPRAGOverrideInvalidMessage
OCPRAGOverrideInvalidMessage = "Invalid OCP RAG version override"

// OpenStackLightspeedMCPServerInitMessage
OpenStackLightspeedMCPServerInitMessage = "MCP server deployment has not resolved"

// OpenStackLightspeedMCPServerDeployed
OpenStackLightspeedMCPServerDeployed = "MCP server is ready"

// OpenStackLightspeedMCPServerWaitingOpenStack
OpenStackLightspeedMCPServerWaitingOpenStack = "MCP server deployed, waiting for OpenStackControlPlane to become ready"

// OpenStackLightspeedMCPServerCreatingUser
OpenStackLightspeedMCPServerCreatingUser = "Creating OpenStack service user"

// OpenStackLightspeedMCPServerWaitingAC
OpenStackLightspeedMCPServerWaitingAC = "Waiting for application credential secret"

// OpenStackLightspeedMCPServerDisabledMessage
OpenStackLightspeedMCPServerDisabledMessage = "RHOS MCP server is disabled (rhos_mcps feature flag not set)"

// DeploymentCheckFailedMessage
DeploymentCheckFailedMessage = "Failed to check deployment status: %s"

Expand Down
108 changes: 80 additions & 28 deletions api/v1beta1/openstacklightspeed_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package v1beta1

import (
"reflect"

"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
"k8s.io/apimachinery/pkg/api/resource"
Expand Down Expand Up @@ -46,6 +48,9 @@ const (
// OKPContainerImage is the fall-back container image for OKP (Offline Knowledge Portal)
OKPContainerImage = "registry.redhat.io/offline-knowledge-portal/rhokp-rhel9:latest"

// MCPServerContainerImage is the fall-back container image for the MCP server
MCPServerContainerImage = "quay.io/openstack-lightspeed/rhos-mcps:latest"

// MaxTokensForResponseDefault is the default maximum number of tokens that should be used for response
MaxTokensForResponseDefault = 2048
)
Expand Down Expand Up @@ -96,8 +101,9 @@ type OpenStackLightspeedSpec struct {
OpenStackLightspeedCore `json:",inline"`

// +kubebuilder:validation:Optional
// ContainerImage for the OpenStack Lightspeed RAG container (will be set to environmental default if empty)
RAGImage string `json:"ragImage"`
// Images configures container images used by the operator.
// When omitted, each image defaults to its environment variable or hardcoded fallback.
Images OpenStackLightspeedImages `json:"images,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=false
Expand Down Expand Up @@ -220,6 +226,16 @@ type OpenStackLightspeedStatus struct {
// ActiveOCPRAGVersion contains the OCP version being used for RAG configuration
// Will be one of: "4.16", "4.18", "latest", or empty if OCP RAG is disabled
ActiveOCPRAGVersion string `json:"activeOCPRAGVersion,omitempty"`

// +optional
// OpenStackReady indicates whether an OpenStackControlPlane was detected and
// is ready. When true, the OpenStack MCP tools are included in lightspeed-stack config.
OpenStackReady bool `json:"openStackReady,omitempty"`

// +optional
// ApplicationCredentialSecret is the name of the current AC secret in the
// OpenStack namespace. Tracked for rotation detection.
ApplicationCredentialSecret string `json:"applicationCredentialSecret,omitempty"`
}

// +kubebuilder:object:root=true
Expand All @@ -244,6 +260,7 @@ type OpenStackLightspeedStatus struct {
// +operator-sdk:csv:customresourcedefinitions:resources={{PersistentVolumeClaim,v1,openstack-lightspeed-database}}
// +operator-sdk:csv:customresourcedefinitions:resources={{ClusterRole,v1,lightspeed-app-server-sar-role}}
// +operator-sdk:csv:customresourcedefinitions:resources={{ClusterRoleBinding,v1,lightspeed-app-server-sar-role-binding}}
// +operator-sdk:csv:customresourcedefinitions:resources={{ConfigMap,v1,mcp-config}}
// +operator-sdk:csv:customresourcedefinitions:resources={{Subscription,v1alpha1}}
// +operator-sdk:csv:customresourcedefinitions:resources={{ClusterServiceVersion,v1alpha1}}
// +operator-sdk:csv:customresourcedefinitions:resources={{InstallPlan,v1alpha1}}
Expand Down Expand Up @@ -275,39 +292,74 @@ func (instance OpenStackLightspeed) IsReady() bool {
return instance.Status.Conditions.IsTrue(OpenStackLightspeedReadyCondition)
}

// OpenStackLightspeedImages groups container image URLs used by the operator.
type OpenStackLightspeedImages struct {
RAGImageURL string `json:"ragImage,omitempty"`
LCoreImageURL string `json:"lcoreImage,omitempty"`
ExporterImageURL string `json:"exporterImage,omitempty"`
PostgresImageURL string `json:"postgresImage,omitempty"`
ConsoleImageURL string `json:"consoleImage,omitempty"`
ConsoleImagePF5URL string `json:"consoleImagePF5,omitempty"`
OKPImageURL string `json:"okpImage,omitempty"`
MCPServerImageURL string `json:"mcpServerImage,omitempty"`
}

type OpenStackLightspeedDefaults struct {
RAGImageURL string
LCoreImageURL string
ExporterImageURL string
PostgresImageURL string
ConsoleImageURL string
ConsoleImagePF5URL string
OKPImageURL string
MaxTokensForResponse int
OpenStackLightspeedImages `json:",inline"`
MaxTokensForResponse int `json:"maxTokensForResponse,omitempty"`
}

var OpenStackLightspeedDefaultValues OpenStackLightspeedDefaults

// SetupDefaults - initializes OpenStackLightspeedDefaultValues with default values from env vars
// envVarDefaults holds the pristine env-var defaults set once by SetupDefaults.
// MergeDefaults copies from this so that removing dev overrides correctly
// reverts to the original values (the exported global gets overwritten each reconcile).
var envVarDefaults OpenStackLightspeedDefaults

// mergeImages applies non-zero fields from src onto dst.
func mergeImages(dst, src *OpenStackLightspeedImages) {
dstVal := reflect.ValueOf(dst).Elem()
srcVal := reflect.ValueOf(src).Elem()
for i := 0; i < srcVal.NumField(); i++ {
if !srcVal.Field(i).IsZero() {
dstVal.Field(i).Set(srcVal.Field(i))
}
}
}

// SetupDefaults initializes OpenStackLightspeedDefaultValues from env vars.
// Call once at startup; the values never change inside a container.
func SetupDefaults() {
// Acquire environmental defaults and initialize OpenStackLightspeed defaults with them
openStackLightspeedDefaults := OpenStackLightspeedDefaults{
RAGImageURL: util.GetEnvVar(
"RELATED_IMAGE_OPENSTACK_LIGHTSPEED_IMAGE_URL_DEFAULT", OpenStackLightspeedContainerImage),
LCoreImageURL: util.GetEnvVar(
"RELATED_IMAGE_LCORE_IMAGE_URL_DEFAULT", LCoreContainerImage),
ExporterImageURL: util.GetEnvVar(
"RELATED_IMAGE_EXPORTER_IMAGE_URL_DEFAULT", ExporterContainerImage),
PostgresImageURL: util.GetEnvVar(
"RELATED_IMAGE_POSTGRES_IMAGE_URL_DEFAULT", PostgresContainerImage),
ConsoleImageURL: util.GetEnvVar(
"RELATED_IMAGE_CONSOLE_IMAGE_URL_DEFAULT", ConsoleContainerImage),
ConsoleImagePF5URL: util.GetEnvVar(
"RELATED_IMAGE_CONSOLE_PF5_IMAGE_URL_DEFAULT", ConsoleContainerImagePF5),
OKPImageURL: util.GetEnvVar(
"RELATED_IMAGE_OKP_IMAGE_URL_DEFAULT", OKPContainerImage),
envVarDefaults = OpenStackLightspeedDefaults{
OpenStackLightspeedImages: OpenStackLightspeedImages{
RAGImageURL: util.GetEnvVar(
"RELATED_IMAGE_OPENSTACK_LIGHTSPEED_IMAGE_URL_DEFAULT", OpenStackLightspeedContainerImage),
LCoreImageURL: util.GetEnvVar(
"RELATED_IMAGE_LCORE_IMAGE_URL_DEFAULT", LCoreContainerImage),
ExporterImageURL: util.GetEnvVar(
"RELATED_IMAGE_EXPORTER_IMAGE_URL_DEFAULT", ExporterContainerImage),
PostgresImageURL: util.GetEnvVar(
"RELATED_IMAGE_POSTGRES_IMAGE_URL_DEFAULT", PostgresContainerImage),
ConsoleImageURL: util.GetEnvVar(
"RELATED_IMAGE_CONSOLE_IMAGE_URL_DEFAULT", ConsoleContainerImage),
ConsoleImagePF5URL: util.GetEnvVar(
"RELATED_IMAGE_CONSOLE_PF5_IMAGE_URL_DEFAULT", ConsoleContainerImagePF5),
OKPImageURL: util.GetEnvVar(
"RELATED_IMAGE_OKP_IMAGE_URL_DEFAULT", OKPContainerImage),
MCPServerImageURL: util.GetEnvVar(
"RELATED_IMAGE_MCP_SERVER_IMAGE_URL_DEFAULT", MCPServerContainerImage),
},
MaxTokensForResponse: MaxTokensForResponseDefault,
}
OpenStackLightspeedDefaultValues = envVarDefaults
}

OpenStackLightspeedDefaultValues = openStackLightspeedDefaults
// MergeDefaults returns a copy of the env-var defaults with the spec image
// overrides (if any) applied on top.
func MergeDefaults(specImages *OpenStackLightspeedImages) OpenStackLightspeedDefaults {
merged := envVarDefaults
if specImages != nil {
mergeImages(&merged.OpenStackLightspeedImages, specImages)
}
return merged
}
Loading
Loading