Skip to content

Commit 9724ceb

Browse files
committed
Fix issues where v3.1.0 is not backwards compatible with 3.0.2
1 parent 5e042e2 commit 9724ceb

33 files changed

+968
-119
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
# Start a KinD K8s cluster with single worker node
6666
shell: bash
6767
run: |
68-
sh ./hack/kind.sh --image kindest/node:v1.16.9@sha256:7175872357bc85847ec4b1aba46ed1d12fa054c83ac7a8a11f5c268957fd5765
68+
sh ./hack/kind.sh --image kindest/node:v1.18.8@sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
6969
kubectl version
7070
kubectl get nodes
7171
docker pull gcr.io/distroless/java
@@ -113,10 +113,6 @@ jobs:
113113
run: |
114114
make e2e-helm-test
115115
116-
# - name: Compatibility Tests
117-
# shell: bash
118-
# run: make compatibility-test
119-
120116
- uses: actions/upload-artifact@v1
121117
if: failure()
122118
with:
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright 2019 Oracle Corporation and/or its affiliates. All rights reserved.
2+
# Licensed under the Universal Permissive License v 1.0 as shown at
3+
# http://oss.oracle.com/licenses/upl.
4+
5+
# ---------------------------------------------------------------------------
6+
# Coherence Operator GitHub Actions Backwards Compatibility Tests.
7+
# ---------------------------------------------------------------------------
8+
name: Backwards Compatibility Tests
9+
10+
on:
11+
push:
12+
branches-ignore:
13+
- gh-pages
14+
- 1.0.0
15+
- 2.x
16+
pull_request:
17+
types:
18+
- opened
19+
- committed
20+
branches-ignore:
21+
- gh-pages
22+
- 1.0.0
23+
- 2.x
24+
25+
env:
26+
RELEASE_IMAGE_PREFIX: "localhost:5000/"
27+
28+
jobs:
29+
build:
30+
runs-on: ubuntu-latest
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
compatibilityVersion:
36+
- 3.0.2
37+
include:
38+
- compatibilityVersion: 3.0.2
39+
compatibilitySelector: component=coherence-operator
40+
41+
steps:
42+
- uses: actions/checkout@v2
43+
with:
44+
fetch-depth: 0
45+
46+
- name: Set up JDK
47+
uses: actions/setup-java@v1
48+
with:
49+
java-version: '1.8'
50+
51+
- name: Cache Go Modules
52+
uses: actions/cache@v1
53+
with:
54+
path: ~/go/pkg/mod
55+
key: ${{ runner.os }}-go-mods-${{ hashFiles('**/go.sum') }}
56+
restore-keys: |
57+
${{ runner.os }}-go-mods-
58+
59+
- name: Cache Maven packages
60+
uses: actions/cache@v1
61+
with:
62+
path: ~/.m2
63+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
64+
restore-keys: ${{ runner.os }}-m2
65+
66+
- name: Set up Go
67+
uses: actions/setup-go@v2-beta
68+
with:
69+
go-version: 1.14.x
70+
71+
- name: Start KinD Cluster
72+
# Start a KinD K8s cluster with single worker node
73+
shell: bash
74+
run: |
75+
sh ./hack/kind.sh --image kindest/node:v1.18.8@sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
76+
kubectl version
77+
kubectl get nodes
78+
docker pull gcr.io/distroless/java
79+
80+
- name: Code Review
81+
shell: bash
82+
run: |
83+
make code-review
84+
85+
- name: Build
86+
shell: bash
87+
run: make all
88+
89+
- name: Push Images
90+
# Push the images just built to the local Docker registry localhost:5000 started with the KinD cluster
91+
shell: bash
92+
run: |
93+
make push-all-images
94+
make kind-load
95+
96+
- name: Compatibility Tests
97+
shell: bash
98+
run: |
99+
make compatibility-test COMPATIBLE_VERSION=${{ matrix.compatibilityVersion }} COMPATIBLE_SELECTOR=${{ matrix.compatibilitySelector }}
100+
101+
- uses: actions/upload-artifact@v1
102+
if: failure()
103+
with:
104+
name: test-output
105+
path: build/_output/test-logs

.github/workflows/k8s-matrix.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535
matrix:
3636
k8s:
3737
- kindest/node:v1.19.1@sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600
38-
- kindest/node:v1.18.2@sha256:7b27a6d0f2517ff88ba444025beae41491b016bc6af573ba467b70c5e8e0d85f
39-
- kindest/node:v1.17.5@sha256:ab3f9e6ec5ad8840eeb1f76c89bb7948c77bbf76bcebe1a8b59790b8ae9a283a
40-
- kindest/node:v1.16.9@sha256:7175872357bc85847ec4b1aba46ed1d12fa054c83ac7a8a11f5c268957fd5765
41-
- kindest/node:v1.15.11@sha256:6cc31f3533deb138792db2c7d1ffc36f7456a06f1db5556ad3b6927641016f50
38+
- kindest/node:v1.18.8@sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
39+
- kindest/node:v1.17.11@sha256:5240a7a2c34bf241afb54ac05669f8a46661912eab05705d660971eeb12f6555
40+
- kindest/node:v1.16.15@sha256:a89c771f7de234e6547d43695c7ab047809ffc71a0c3b65aa54eda051c45ed20
41+
- kindest/node:v1.15.12@sha256:d9b939055c1e852fe3d86955ee24976cab46cba518abcb8b13ba70917e6547a6
4242
- kindest/node:v1.14.10@sha256:6cd43ff41ae9f02bb46c8f455d5323819aec858b99534a290517ebc181b443c6
4343
- kindest/node:v1.13.12@sha256:214476f1514e47fe3f6f54d0f9e24cfb1e4cda449529791286c7161b7f9c08e7
4444

Makefile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ VERSION ?= 3.1.1
1313
# The operator version to use to run certification tests against
1414
CERTIFICATION_VERSION ?= $(VERSION)
1515

16-
# A SPACE delimited list of previous Operator versions that are used to run the compatibility tests.
17-
COMPATIBLE_VERSIONS = 3.0.0
16+
# The previous Operator version used to run the compatibility tests.
17+
COMPATIBLE_VERSION = 3.0.2
18+
# The selector to use to find Operator Pods of the COMPATIBLE_VERSION (do not put in double quotes!!)
19+
COMPATIBLE_SELECTOR = component=coherence-operator
1820

1921
# Capture the Git commit to add to the build information
2022
GITCOMMIT ?= $(shell git rev-list -1 HEAD)
@@ -466,14 +468,17 @@ compatibility-test: export TEST_SSL_SECRET := $(TEST_SSL_SECRET)
466468
compatibility-test: export TEST_IMAGE_PULL_POLICY := $(IMAGE_PULL_POLICY)
467469
compatibility-test: export TEST_STORAGE_CLASS := $(TEST_STORAGE_CLASS)
468470
compatibility-test: export VERSION := $(VERSION)
469-
compatibility-test: export COMPATIBLE_VERSIONS := $(COMPATIBLE_VERSIONS)
471+
compatibility-test: export COMPATIBLE_VERSION := $(COMPATIBLE_VERSION)
472+
compatibility-test: export COMPATIBLE_SELECTOR := $(COMPATIBLE_SELECTOR)
470473
compatibility-test: export OPERATOR_IMAGE := $(OPERATOR_IMAGE)
471474
compatibility-test: export COHERENCE_IMAGE := $(COHERENCE_IMAGE)
472475
compatibility-test: export UTILS_IMAGE := $(UTILS_IMAGE)
473476
compatibility-test: export GO_TEST_FLAGS_E2E := $(strip $(GO_TEST_FLAGS_E2E))
474-
compatibility-test: $(BUILD_TARGETS)/build-operator clean-namespace reset-namespace create-ssl-secrets gotestsum
477+
compatibility-test: $(BUILD_TARGETS)/build-operator undeploy clean-namespace reset-namespace gotestsum
478+
helm repo add coherence https://oracle.github.io/coherence-operator/charts
479+
helm repo update
475480
$(GOTESTSUM) --format standard-verbose --junitfile $(TEST_LOGS_DIR)/operator-e2e-compatibility-test.xml \
476-
-- $(GO_TEST_FLAGS_E2E) ./test/compatibility/...
481+
-- $(GO_TEST_FLAGS_E2E) ./test/e2e/compatibility/...
477482

478483

479484
# ----------------------------------------------------------------------------------------------------------------------
@@ -623,8 +628,11 @@ endef
623628
.PHONY: undeploy
624629
undeploy: $(BUILD_PROPS) $(BUILD_TARGETS)/manifests $(GOBIN)/kustomize
625630
$(call prepare_deploy,$(OPERATOR_IMAGE),$(OPERATOR_NAMESPACE))
626-
$(GOBIN)/kustomize build $(BUILD_DEPLOY)/default | kubectl delete -f -
631+
$(GOBIN)/kustomize build $(BUILD_DEPLOY)/default | kubectl delete -f - || true
627632
kubectl -n $(OPERATOR_NAMESPACE) delete secret coherence-webhook-server-cert || true
633+
kubectl delete mutatingwebhookconfiguration coherence-operator-mutating-webhook-configuration || true
634+
kubectl delete validatingwebhookconfiguration coherence-operator-validating-webhook-configuration || true
635+
628636

629637
# ----------------------------------------------------------------------------------------------------------------------
630638
# Tail the deployed operator logs.
@@ -648,15 +656,15 @@ $(BUILD_MANIFESTS_PKG):
648656
cp -R config/rbac/ $(BUILD_MANIFESTS)/rbac
649657
tar -C $(BUILD_OUTPUT) -czf $(BUILD_MANIFESTS_PKG) manifests/
650658

651-
$(BUILD_TARGETS)/manifests: $(BUILD_PROPS) config/crd/bases/coherence.oracle.com_coherences.yaml config/crd-v1beta1/bases/coherence.oracle.com_coherences.yaml docs/about/04_coherence_spec.adoc
659+
$(BUILD_TARGETS)/manifests: $(BUILD_PROPS) config/crd/bases/coherence.oracle.com_coherence.yaml config/crd-v1beta1/bases/coherence.oracle.com_coherence.yaml docs/about/04_coherence_spec.adoc
652660
touch $(BUILD_TARGETS)/manifests
653661

654-
config/crd/bases/coherence.oracle.com_coherences.yaml: $(API_GO_FILES) $(GOBIN)/controller-gen
662+
config/crd/bases/coherence.oracle.com_coherence.yaml: $(API_GO_FILES) $(GOBIN)/controller-gen
655663
$(GOBIN)/controller-gen "crd:trivialVersions=true,crdVersions={v1}" \
656664
rbac:roleName=manager-role paths="{./api/...,./controllers/...}" \
657665
output:crd:artifacts:config=config/crd/bases
658666

659-
config/crd-v1beta1/bases/coherence.oracle.com_coherences.yaml: $(API_GO_FILES) $(GOBIN)/controller-gen
667+
config/crd-v1beta1/bases/coherence.oracle.com_coherence.yaml: $(API_GO_FILES) $(GOBIN)/controller-gen
660668
@echo "Generating CRD v1beta1"
661669
$(GOBIN)/controller-gen "crd:trivialVersions=true,crdVersions={v1beta1}" \
662670
rbac:roleName=manager-role paths="{./api/...,./controllers/...}" \
@@ -1028,7 +1036,9 @@ run-clean: reset-namespace run
10281036
run-debug: export COHERENCE_IMAGE := $(COHERENCE_IMAGE)
10291037
run-debug: export UTILS_IMAGE := $(UTILS_IMAGE)
10301038
run-debug:
1031-
dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient
1039+
dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient \
1040+
-- --skip-service-suspend=true --coherence-dev-mode=true \
1041+
--cert-type=self-signed --webhook-service=host.docker.internal
10321042

10331043
# ----------------------------------------------------------------------------------------------------------------------
10341044
# Run the Operator locally in debug mode after deleting and recreating

api/v1/coherence_webhook.go

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (in *Coherence) SetupWebhookWithManager(mgr ctrl.Manager) error {
2828
}
2929

3030
// The path in this annotation MUST match the const below
31-
// +kubebuilder:webhook:path=/mutate-coherence-oracle-com-v1-coherence,mutating=true,failurePolicy=fail,groups=coherence.oracle.com,resources=coherences,verbs=create;update,versions=v1,name=mcoherence.kb.io
31+
// +kubebuilder:webhook:path=/mutate-coherence-oracle-com-v1-coherence,mutating=true,failurePolicy=fail,groups=coherence.oracle.com,resources=coherence,verbs=create;update,versions=v1,name=mcoherence.kb.io
3232

3333
// This const MUST match the path in the kubebuilder annotation above
3434
const MutatingWebHookPath = "/mutate-coherence-oracle-com-v1-coherence"
@@ -39,20 +39,29 @@ var _ webhook.Defaulter = &Coherence{}
3939

4040
// Default implements webhook.Defaulter so a webhook will be registered for the type
4141
func (in *Coherence) Default() {
42-
webhookLogger.Info("default", "name", in.Name)
42+
logger := webhookLogger.WithValues("namespace", in.Namespace, "name", in.Name)
43+
if in.Status.Phase == "" {
44+
logger.Info("setting defaults for resource")
4345

44-
if in.Spec.Replicas == nil {
45-
in.Spec.SetReplicas(3)
46-
}
46+
if in.Spec.Replicas == nil {
47+
in.Spec.SetReplicas(3)
48+
}
4749

48-
coherenceImage := operator.GetDefaultCoherenceImage()
49-
in.Spec.EnsureCoherenceImage(&coherenceImage)
50-
utilsImage := operator.GetDefaultUtilsImage()
51-
in.Spec.EnsureCoherenceUtilsImage(&utilsImage)
50+
// only set defaults for image names new Coherence instances
51+
coherenceImage := operator.GetDefaultCoherenceImage()
52+
in.Spec.EnsureCoherenceImage(&coherenceImage)
53+
utilsImage := operator.GetDefaultUtilsImage()
54+
in.Spec.EnsureCoherenceUtilsImage(&utilsImage)
55+
56+
// Set the features supported by this version
57+
in.Annotations[ANNOTATION_FEATURE_SUSPEND] = "true"
58+
} else {
59+
logger.Info("skipping defaulting for existing resource")
60+
}
5261
}
5362

5463
// The path in this annotation MUST match the const below
55-
// +kubebuilder:webhook:verbs=create;update,path=/validate-coherence-oracle-com-v1-coherence,mutating=false,failurePolicy=fail,groups=coherence.oracle.com,resources=coherences,versions=v1,name=vcoherence.kb.io
64+
// +kubebuilder:webhook:verbs=create;update,path=/validate-coherence-oracle-com-v1-coherence,mutating=false,failurePolicy=fail,groups=coherence.oracle.com,resources=coherence,versions=v1,name=vcoherence.kb.io
5665

5766
// This const MUST match the path in the kubebuilder annotation above
5867
const ValidatingWebHookPath = "/validate-coherence-oracle-com-v1-coherence"

api/v1/coherenceresource_types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ const (
261261
// +kubebuilder:object:root=true
262262
// +kubebuilder:subresource:status
263263
// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector
264-
// +kubebuilder:resource:path=coherences,scope=Namespaced,shortName=coh,categories=coherence
264+
// +kubebuilder:resource:path=coherence,scope=Namespaced,shortName=coh,categories=coherence
265265
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".status.coherenceCluster",description="The name of the Coherence cluster that this deployment belongs to"
266266
// +kubebuilder:printcolumn:name="Role",type="string",JSONPath=".status.role",description="The role of this deployment in a Coherence cluster"
267267
// +kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".status.replicas",description="The number of Coherence deployments for this deployment"
@@ -418,13 +418,13 @@ func ensureV1CRDs(logger logr.Logger, crdClient v1client.CustomResourceDefinitio
418418
func ensureV1CRD(logger logr.Logger, crdClient v1client.CustomResourceDefinitionInterface, fileName string) error {
419419
f, err := data.Assets.Open(fileName)
420420
if err != nil {
421-
return errors.Wrap(err, "opening embedded CRD asset " + fileName)
421+
return errors.Wrap(err, "opening embedded CRD asset "+fileName)
422422
}
423423
defer f.Close()
424424

425425
yml, err := ioutil.ReadAll(f)
426426
if err != nil {
427-
return errors.Wrap(err, "reading embedded CRD asset " + fileName)
427+
return errors.Wrap(err, "reading embedded CRD asset "+fileName)
428428
}
429429

430430
u := unstructured.Unstructured{}
@@ -488,13 +488,13 @@ func ensureV1Beta1CRDs(logger logr.Logger, crdClient v1beta1client.CustomResourc
488488
func ensureV1Beta1CRD(logger logr.Logger, crdClient v1beta1client.CustomResourceDefinitionInterface, fileName string) error {
489489
f, err := data.Assets.Open(fileName)
490490
if err != nil {
491-
return errors.Wrap(err, "opening embedded CRD asset " + fileName)
491+
return errors.Wrap(err, "opening embedded CRD asset "+fileName)
492492
}
493493
defer f.Close()
494494

495495
yml, err := ioutil.ReadAll(f)
496496
if err != nil {
497-
return errors.Wrap(err, "reading embedded CRD asset " + fileName)
497+
return errors.Wrap(err, "reading embedded CRD asset "+fileName)
498498
}
499499

500500
u := unstructured.Unstructured{}

api/v1/coherenceresourcespec_types.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ func (in *CoherenceResourceSpec) CreateCommonEnv(deployment *Coherence) []corev1
755755

756756
// Create the default environment variables for the Coherence container.
757757
func (in *CoherenceResourceSpec) CreateDefaultEnv(deployment *Coherence) []corev1.EnvVar {
758-
return append(in.CreateCommonEnv(deployment),
758+
env := append(in.CreateCommonEnv(deployment),
759759
corev1.EnvVar{Name: EnvVarCohWka, Value: deployment.Spec.Coherence.GetWKA(deployment)},
760760
corev1.EnvVar{
761761
Name: EnvVarOperatorHost, ValueFrom: &corev1.EnvVarSource{
@@ -771,8 +771,13 @@ func (in *CoherenceResourceSpec) CreateDefaultEnv(deployment *Coherence) []corev
771771
corev1.EnvVar{Name: EnvVarCohUtilDir, Value: VolumeMountPathUtils},
772772
corev1.EnvVar{Name: EnvVarOperatorTimeout, Value: Int32PtrToStringWithDefault(in.OperatorRequestTimeout, 120)},
773773
corev1.EnvVar{Name: EnvVarCohHealthPort, Value: Int32ToString(in.GetHealthPort())},
774-
corev1.EnvVar{Name: EnvVarCohIdentity, Value: deployment.Name + "@" + deployment.Namespace},
775774
)
775+
776+
if deployment.Annotations[ANNOTATION_FEATURE_SUSPEND] == "true" {
777+
env = append(env, corev1.EnvVar{Name: EnvVarCohIdentity, Value: deployment.Name + "@" + deployment.Namespace})
778+
}
779+
780+
return env
776781
}
777782

778783
// Create the default Container resources.

api/v1/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const (
3838

3939
StatusSelectorTemplate = LabelCoherenceCluster + "=%s," + LabelCoherenceDeployment + "=%s"
4040

41+
// Feature annotations
42+
ANNOTATION_FEATURE_SUSPEND = "com.oracle.coherence.operator/feature.suspend"
43+
4144
// The default k8s service account name.
4245
DefaultServiceAccount = "default"
4346

config/crd-v1beta1/bases/coherence.oracle.com_coherences.yaml renamed to config/crd-v1beta1/bases/coherence.oracle.com_coherence.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ metadata:
66
annotations:
77
controller-gen.kubebuilder.io/version: v0.3.0
88
creationTimestamp: null
9-
name: coherences.coherence.oracle.com
9+
name: coherence.coherence.oracle.com
1010
spec:
1111
additionalPrinterColumns:
1212
- JSONPath: .status.coherenceCluster
@@ -35,7 +35,7 @@ spec:
3535
- coherence
3636
kind: Coherence
3737
listKind: CoherenceList
38-
plural: coherences
38+
plural: coherence
3939
shortNames:
4040
- coh
4141
singular: coherence

config/crd-v1beta1/kustomization.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
# since it depends on service name and namespace that are out of this kustomize package.
33
# It should be run by config/default
44
resources:
5-
- bases/coherence.oracle.com_coherences.yaml
5+
- bases/coherence.oracle.com_coherence.yaml
66
# +kubebuilder:scaffold:crdkustomizeresource
77

88
patchesStrategicMerge:
99
# patches here are for enabling the conversion webhook for each CRD
10-
#- patches/webhook_in_coherences.yaml
10+
#- patches/webhook_in_coherence.yaml
1111
# +kubebuilder:scaffold:crdkustomizewebhookpatch
1212

1313
# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
1414
# patches here are for enabling the CA injection for each CRD
15-
#- patches/cainjection_in_coherences.yaml
15+
#- patches/cainjection_in_coherence.yaml
1616
# +kubebuilder:scaffold:crdkustomizecainjectionpatch
1717

1818
# the following config is for teaching kustomize how to do kustomization for CRDs.

0 commit comments

Comments
 (0)