Skip to content
Merged
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
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ helm-chart-publish: helm-chart-package ## Publish helm chart for the operator.
##@ Chainsaw E2E

CHAINSAW ?= $(LOCALBIN)/chainsaw
CHAINSAW_VERSION ?= v0.2.13
CHAINSAW_VERSION ?= v0.2.14
CHAINSAW_CLUSTER ?= chainsaw-${PROJECT_NAME}
CHAINSAW_KUBECONFIG ?= .kubeconfig
# KIND_K8S_VERSION refers to the version of Kubernetes to be used by kind node image.
Expand Down Expand Up @@ -335,11 +335,11 @@ chart-e2e: setup-chainsaw-cluster chainsaw docker-build helm-chart-package ## Ru
"$(HELM)" upgrade --install --create-namespace --namespace $(PROJECT_NAME) \
--kubeconfig $(CHAINSAW_KUBECONFIG) --wait $(PROJECT_NAME) \
target/charts/$(PROJECT_NAME)-$(VERSION).tgz
KUBECONFIG=$(CHAINSAW_KUBECONFIG) $(CHAINSAW) test --config ./test/e2e/.chainsaw.yaml --test-dir ./test/e2e/
KUBECONFIG=$(CHAINSAW_KUBECONFIG) $(CHAINSAW) test --config ./test/e2e/.chainsaw.yaml --test-dir ./test/e2e/ --set product_version=$(PRODUCT_VERSION)

.PHONY: chainsaw-e2e
chainsaw-e2e: ## Run the chainsaw e2e tests
KUBECONFIG=$(CHAINSAW_KUBECONFIG) $(CHAINSAW) test --config ./test/e2e/.chainsaw.yaml --test-dir ./test/e2e/
KUBECONFIG=$(CHAINSAW_KUBECONFIG) $(CHAINSAW) test --config ./test/e2e/.chainsaw.yaml --test-dir ./test/e2e/ --set product_version=$(PRODUCT_VERSION)

.PHONY: cleanup-chainsaw-e2e
cleanup-chainsaw-e2e: ## Run the chainsaw cleanup
Expand Down
33 changes: 22 additions & 11 deletions internal/controller/common/image_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,33 @@ import (

// GetImage returns the image for the given component.
//
// When imageSpec is nil (no image configured in the CR), it falls back to the
// official apache/doris per-component images (e.g. apache/doris:fe-2.1.8).
// Unless imageSpec.Custom is set, it resolves to the official apache/doris
// per-component images (e.g. apache/doris:fe-2.1.8), honoring
// imageSpec.ProductVersion when provided.
//
// When imageSpec is provided, it delegates to TransformImage which builds the
// unified quay.io/zncdatadev/doris:<version>-kubedoop<kubedoop-version> image.
// When imageSpec.Custom is set, it delegates to TransformImage so the custom
// image is used as-is.
//
// TODO: Once the custom unified image is production-ready, remove the nil
// fallback and always use TransformImage.
// TODO: Once the unified quay.io/zncdatadev/doris:<version>-kubedoop<version>
// image is published and production-ready, always use TransformImage instead
// of the official per-component images.
func GetImage(imageSpec *dorisv1alpha1.ImageSpec, componentType constants.ComponentType) *opgoutil.Image {
if imageSpec == nil {
return &opgoutil.Image{
Custom: fmt.Sprintf("%s:%s-%s", constants.OfficialImageRepository, componentType, constants.DefaultProductVersion),
PullPolicy: corev1.PullIfNotPresent,
if imageSpec != nil && imageSpec.Custom != "" {
return dorisv1alpha1.TransformImage(imageSpec)
}
productVersion := constants.DefaultProductVersion
pullSecretName := ""
if imageSpec != nil {
if imageSpec.ProductVersion != "" {
productVersion = imageSpec.ProductVersion
}
pullSecretName = imageSpec.PullSecretName
}
return &opgoutil.Image{
Custom: fmt.Sprintf("%s:%s-%s", constants.OfficialImageRepository, componentType, productVersion),
PullPolicy: GetPullPolicy(imageSpec),
PullSecretName: pullSecretName,
}
return dorisv1alpha1.TransformImage(imageSpec)
}

// GetInitContainerImage returns the image to use for init containers
Expand Down
102 changes: 102 additions & 0 deletions internal/controller/common/image_helper_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
Copyright 2025 zncdatadev.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package common

import (
"testing"

corev1 "k8s.io/api/core/v1"

dorisv1alpha1 "github.com/zncdatadev/doris-operator/api/v1alpha1"
"github.com/zncdatadev/doris-operator/internal/controller/constants"
)

func TestGetImage(t *testing.T) {
pullAlways := corev1.PullAlways

tests := []struct {
name string
imageSpec *dorisv1alpha1.ImageSpec
componentType constants.ComponentType
wantImage string
wantPullPolicy corev1.PullPolicy
}{
{
name: "nil spec falls back to official image with default version",
imageSpec: nil,
componentType: constants.ComponentTypeFE,
wantImage: "apache/doris:fe-" + constants.DefaultProductVersion,
wantPullPolicy: corev1.PullIfNotPresent,
},
{
name: "productVersion overrides default in official image",
imageSpec: &dorisv1alpha1.ImageSpec{ProductVersion: "3.0.3"},
componentType: constants.ComponentTypeBE,
wantImage: "apache/doris:be-3.0.3",
wantPullPolicy: corev1.PullIfNotPresent,
},
{
name: "defaulted spec without explicit productVersion uses default version",
imageSpec: &dorisv1alpha1.ImageSpec{
Repo: dorisv1alpha1.DefaultRepository,
KubedoopVersion: dorisv1alpha1.DefaultKubedoopVersion,
},
componentType: constants.ComponentTypeBroker,
wantImage: "apache/doris:broker-" + constants.DefaultProductVersion,
wantPullPolicy: corev1.PullIfNotPresent,
},
{
name: "pull policy from spec is honored on official image path",
imageSpec: &dorisv1alpha1.ImageSpec{
ProductVersion: "2.1.8",
PullPolicy: &pullAlways,
},
componentType: constants.ComponentTypeFE,
wantImage: "apache/doris:fe-2.1.8",
wantPullPolicy: corev1.PullAlways,
},
{
name: "custom image bypasses official image path",
imageSpec: &dorisv1alpha1.ImageSpec{Custom: "my.repo.org/doris:custom"},
componentType: constants.ComponentTypeFE,
wantImage: "my.repo.org/doris:custom",
wantPullPolicy: corev1.PullIfNotPresent,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
img := GetImage(tt.imageSpec, tt.componentType)
if got := img.String(); got != tt.wantImage {
t.Errorf("GetImage() image = %q, want %q", got, tt.wantImage)
}
if img.PullPolicy != tt.wantPullPolicy {
t.Errorf("GetImage() pull policy = %q, want %q", img.PullPolicy, tt.wantPullPolicy)
}
})
}
}

func TestGetImagePullSecret(t *testing.T) {
img := GetImage(&dorisv1alpha1.ImageSpec{
ProductVersion: "3.0.3",
PullSecretName: "my-pull-secret",
}, constants.ComponentTypeFE)
if img.PullSecretName != "my-pull-secret" {
t.Errorf("GetImage() pull secret = %q, want %q", img.PullSecretName, "my-pull-secret")
}
}
3 changes: 3 additions & 0 deletions test/e2e/auth-secret/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Test
metadata:
name: auth-secret
spec:
bindings:
- name: doris_version
value: ($values.product_version)
steps:
- name: create admin secret
try:
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/auth-secret/doris.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
app.kubernetes.io/name: doris-operator
name: doriscluster-sample
spec:
image:
productVersion: ($values.product_version)
clusterConfig: {}
authSecret:
secretName: doris-admin-secret
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/authentication/ldap/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: ldap
spec:
bindings:
- name: doris_version
value: ($values.product_version)
- name: LDAP_ADMIN_USERNAME
value: admin
- name: LDAP_ADMIN_PASSWORD
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/authentication/ldap/doris.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
app.kubernetes.io/managed-by: kustomize
name: doriscluster-sample
spec:
image:
productVersion: ($values.product_version)
clusterConfig:
authentication:
- authenticationClass: ldap
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/scale-config/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Test
metadata:
name: multi-rolegroup
spec:
bindings:
- name: doris_version
value: ($values.product_version)
steps:
- name: install doris cluster
try:
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/scale-config/doris.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
app.kubernetes.io/name: doris-operator
name: doriscluster-sample
spec:
image:
productVersion: ($values.product_version)
clusterConfig:
scaleDownPolicy:
backendStrategy: decommission
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/scale/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Test
metadata:
name: scale
spec:
bindings:
- name: doris_version
value: ($values.product_version)
steps:
- name: install doris cluster with 1 BE replica
try:
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/scale/doris-scaled-up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
app.kubernetes.io/name: doris-operator
name: doriscluster-sample
spec:
image:
productVersion: ($values.product_version)
clusterConfig: {}
frontend:
roleGroups:
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/scale/doris.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
app.kubernetes.io/name: doris-operator
name: doriscluster-sample
spec:
image:
productVersion: ($values.product_version)
clusterConfig: {}
frontend:
roleGroups:
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/smoke/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ metadata:
name: logging
spec:
bindings:
- name: doris_version
value: ($values.product_version)
steps:
- name: install doris cluster
try:
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/smoke/doris.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ metadata:
app.kubernetes.io/managed-by: kustomize
name: doriscluster-sample
spec:
image:
productVersion: ($values.product_version)
clusterConfig:
vectorAggregatorConfigMapName: vector-aggregator-discovery
frontend:
Expand Down
Loading