Skip to content

Commit

Permalink
Fixing backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
thegridman committed Nov 17, 2023
1 parent b944a66 commit f27ba9e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 35 deletions.
50 changes: 25 additions & 25 deletions .github/workflows/compatibility-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:
compatibilityVersion:
- 3.3.1
- 3.3.0
# - 3.2.11
# - 3.2.10
# - 3.2.9
# - 3.2.7
# - 3.2.6
- 3.2.11
- 3.2.10
- 3.2.9
- 3.2.7
- 3.2.6
include:
- compatibilityVersion: 3.3.1
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
Expand All @@ -53,26 +53,26 @@ jobs:
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
compatibilitySelector: control-plane=coherence
k8s: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
# - compatibilityVersion: 3.2.11
# coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
# compatibilitySelector: control-plane=coherence
# k8s: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
# - compatibilityVersion: 3.2.10
# coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
# compatibilitySelector: control-plane=coherence
# k8s: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
# - compatibilityVersion: 3.2.9
# coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
# compatibilitySelector: control-plane=coherence
# k8s: kindest/node:v1.24.12@sha256:1e12918b8bc3d4253bc08f640a231bb0d3b2c5a9b28aa3f2ca1aee93e1e8db16
# - compatibilityVersion: 3.2.7
# coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
# compatibilitySelector: control-plane=coherence
# k8s: kindest/node:v1.24.12@sha256:1e12918b8bc3d4253bc08f640a231bb0d3b2c5a9b28aa3f2ca1aee93e1e8db16
# - compatibilityVersion: 3.2.6
# coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
# compatibilitySelector: control-plane=coherence
# k8s: kindest/node:v1.24.12@sha256:1e12918b8bc3d4253bc08f640a231bb0d3b2c5a9b28aa3f2ca1aee93e1e8db16
- compatibilityVersion: 3.2.11
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
compatibilitySelector: control-plane=coherence
k8s: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
- compatibilityVersion: 3.2.10
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
compatibilitySelector: control-plane=coherence
k8s: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
- compatibilityVersion: 3.2.9
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
compatibilitySelector: control-plane=coherence
k8s: kindest/node:v1.24.12@sha256:1e12918b8bc3d4253bc08f640a231bb0d3b2c5a9b28aa3f2ca1aee93e1e8db16
- compatibilityVersion: 3.2.7
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
compatibilitySelector: control-plane=coherence
k8s: kindest/node:v1.24.12@sha256:1e12918b8bc3d4253bc08f640a231bb0d3b2c5a9b28aa3f2ca1aee93e1e8db16
- compatibilityVersion: 3.2.6
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.6"
compatibilitySelector: control-plane=coherence
k8s: kindest/node:v1.24.12@sha256:1e12918b8bc3d4253bc08f640a231bb0d3b2c5a9b28aa3f2ca1aee93e1e8db16

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ CERTIFICATION_VERSION ?= $(VERSION)
# The previous Operator version used to run the compatibility tests.
COMPATIBLE_VERSION ?= 3.3.1
# The selector to use to find Operator Pods of the COMPATIBLE_VERSION (do not put in double quotes!!)
COMPATIBLE_SELECTOR = control-plane=coherence
COMPATIBLE_SELECTOR ?= control-plane=coherence

# The GitHub project URL
PROJECT_URL = https://github.com/oracle/coherence-operator
Expand Down
7 changes: 7 additions & 0 deletions api/v1/coherenceresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,14 @@ func (in *Coherence) GetVersionAnnotation() (string, bool) {
// before the specified version, or is not set.
// The version parameter must be a valid SemVer value.
func (in *Coherence) IsBeforeVersion(version string) bool {
if version[0] != 'v' {
version = "v" + version
}

if actual, found := in.GetVersionAnnotation(); found {
if actual[0] != 'v' {
actual = "v" + actual
}
return semver.Compare(actual, version) < 0
}
return true
Expand Down
2 changes: 0 additions & 2 deletions api/v1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ const (
AnnotationFeatureSuspend = "com.oracle.coherence.operator/feature.suspend"
// AnnotationOperatorVersion is the Operator version annotations
AnnotationOperatorVersion = "com.oracle.coherence.operator/version"
// AnnotationOperatorIgnore is an annotation to tell the Operator to ignore changes to a Coherence resource
AnnotationOperatorIgnore = "com.oracle.coherence.operator/ignore"

// DefaultServiceAccount is the default k8s service account name.
DefaultServiceAccount = "default"
Expand Down
24 changes: 18 additions & 6 deletions controllers/coherence_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"context"
"fmt"
"github.com/go-logr/logr"
coh "github.com/oracle/coherence-operator/api/v1"
"github.com/oracle/coherence-operator/controllers/predicates"
"github.com/oracle/coherence-operator/controllers/reconciler"
"github.com/oracle/coherence-operator/controllers/secret"
Expand All @@ -35,8 +36,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
"strconv"

coh "github.com/oracle/coherence-operator/api/v1"
)

const (
Expand Down Expand Up @@ -264,6 +263,16 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
return ctrl.Result{Requeue: true}, err
}

// check for the "ignore" annotation
//shouldUpdate := true
//if ignore, found := deployment.Annotations[coh.AnnotationOperatorIgnore]; found {
// if strings.ToLower(ignore) == "true" {
// // We should skip applying any updates for this Coherence resource.
// shouldUpdate = false
// }
//}
//
//if shouldUpdate {
// process the secondary resources in the order they should be created
var failures []Failure
for _, rec := range in.reconcilers {
Expand All @@ -282,6 +291,9 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
}
return reconcile.Result{}, fmt.Errorf("one or more secondary resource reconcilers failed to reconcile")
}
//} else {
// log.Info("Skipping updates for Coherence resource, annotation " + coh.AnnotationOperatorIgnore + " is set to true")
//}

// if replica count is zero update the status to Stopped
if deployment.GetReplicas() == 0 {
Expand Down Expand Up @@ -348,11 +360,11 @@ func (in *CoherenceReconciler) ensureHashApplied(ctx context.Context, c *coh.Coh
hash, _ := coh.EnsureHashLabel(latest)

if currentHash != hash {
if c.IsBeforeVersion("3.2.8") {
// Before 3.2.8 there was a bug calculating the has in the defaulting web-hook
if c.IsBeforeVersion("3.3.0") {
// Before 3.3.0 there was a bug calculating the has in the defaulting web-hook
// This would cause the hashes to be different here, when in fact they should not be
// If the Coherence resource being processes has no version annotation, or a version
// prior to 3.2.8 then we return as if the hashes matched
// prior to 3.3.0 then we return as if the hashes matched
if labels == nil {
labels = make(map[string]string)
}
Expand All @@ -378,7 +390,7 @@ func (in *CoherenceReconciler) ensureVersionAnnotationApplied(ctx context.Contex
currentVersion, _ := c.GetVersionAnnotation()
operatorVersion := operator.GetVersion()

if currentVersion != operatorVersion {
if currentVersion == "" {
// make a copy of the Coherence resource to use in the three-way patch
latest := c.DeepCopy()
latest.AddAnnotation(coh.AnnotationOperatorVersion, operatorVersion)
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/compatibility/compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ func TestCompatibility(t *testing.T) {
UpgradeToCurrentVersion(t, g, ns, name)

// wait a few minutes to allow the new Operator to reconcile the existing Coherence cluster
// usually this would be quick, but on a slow build machine it could be a few minutes
t.Logf("Upgraded to current Operator version - waiting for reconcile...\n")
time.Sleep(1 * time.Minute)
time.Sleep(5 * time.Minute)

// Get the current state of the StatefulSet
stsAfter := &appsv1.StatefulSet{}
Expand Down

0 comments on commit f27ba9e

Please sign in to comment.