Skip to content

Commit 991ba5e

Browse files
authored
Fix broken tests (#768)
1 parent 368e6d0 commit 991ba5e

File tree

8 files changed

+55
-49
lines changed

8 files changed

+55
-49
lines changed

.github/workflows/coherence-matrix.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ jobs:
220220
echo "COHERENCE_IMAGE=${COHERENCE_IMAGE}"
221221
export BUILD_JAVA_VERSION=${{ matrix.javaVersion }}
222222
echo "BUILD_JAVA_VERSION=${BUILD_JAVA_VERSION}"
223-
export COHERENCE_TEST_BASE_IMAGE=${{ matrix.baseImage }}
224-
echo "COHERENCE_TEST_BASE_IMAGE=${COHERENCE_TEST_BASE_IMAGE}"
223+
export COHERENCE_TEST_BASE_IMAGE_17=${{ matrix.baseImage }}
224+
echo "COHERENCE_TEST_BASE_IMAGE_17=${COHERENCE_TEST_BASE_IMAGE_17}"
225+
export COHERENCE_TEST_BASE_IMAGE_21=${{ matrix.baseImage }}
226+
echo "COHERENCE_TEST_BASE_IMAGE_21=${COHERENCE_TEST_BASE_IMAGE_17}"
225227
export OPERATOR_COHERENCE_JAVA_8=${{ matrix.coherenceIsJava8 }}
226228
make clean
227229
echo "Building Operator Image"

.github/workflows/compatibility-tests.yaml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,37 @@ jobs:
4545
- 3.3.5
4646
- 3.3.4
4747
- 3.3.3
48-
- 3.3.2
4948
include:
5049
- compatibilityVersion: 3.5.0
51-
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1"
50+
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2"
5251
compatibilitySelector: control-plane=coherence
53-
k8s: kindest/node:v1.33.0@sha256:91e9ed777db80279c22d1d1068c091b899b2078506e4a0f797fbf6e397c0b0b2
52+
k8s: kindest/node:v1.33.1@sha256:050072256b9a903bd914c0b2866828150cb229cea0efe5892e2b644d5dd3b34f
5453
- compatibilityVersion: 3.4.3
55-
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1"
54+
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2"
5655
compatibilitySelector: control-plane=coherence
5756
k8s: kindest/node:v1.32.2@sha256:f226345927d7e348497136874b6d207e0b32cc52154ad8323129352923a3142f
5857
- compatibilityVersion: 3.4.2
59-
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1"
58+
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2"
6059
compatibilitySelector: control-plane=coherence
6160
k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245
6261
- compatibilityVersion: 3.4.1
63-
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1"
62+
coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2"
6463
compatibilitySelector: control-plane=coherence
6564
k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245
6665
- compatibilityVersion: 3.4.0
67-
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10"
66+
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12"
6867
compatibilitySelector: control-plane=coherence
6968
k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245
7069
- compatibilityVersion: 3.3.5
71-
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10"
70+
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12"
7271
compatibilitySelector: control-plane=coherence
7372
k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245
7473
- compatibilityVersion: 3.3.4
75-
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10"
74+
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12"
7675
compatibilitySelector: control-plane=coherence
7776
k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245
7877
- compatibilityVersion: 3.3.3
79-
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10"
80-
compatibilitySelector: control-plane=coherence
81-
k8s: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
82-
- compatibilityVersion: 3.3.2
83-
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10"
78+
coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12"
8479
compatibilitySelector: control-plane=coherence
8580
k8s: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
8681

controllers/coherence_controller.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
9696
// request for the same resource is already in progress so requeue this one.
9797
if ok := in.Lock(request); !ok {
9898
log.Info("Coherence resource " + request.Namespace + "/" + request.Name + " is already locked, requeue request")
99-
return reconcile.Result{Requeue: true, RequeueAfter: 0}, nil
99+
return reconcile.Result{RequeueAfter: time.Minute}, nil
100100
}
101101
// Make sure that the request is unlocked when this method exits
102102
defer in.Unlock(request)
@@ -134,7 +134,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
134134
msg := fmt.Sprintf("failed to finalize Coherence resource, %s", err.Error())
135135
in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonDeleted, msg)
136136
log.Error(err, "Failed to remove finalizer")
137-
return ctrl.Result{Requeue: true}, nil
137+
return ctrl.Result{RequeueAfter: time.Minute}, nil
138138
}
139139
// Remove the finalizer. Once all finalizers have been
140140
// removed, the object will be deleted.
@@ -164,7 +164,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
164164
if controllerutil.ContainsFinalizer(deployment, coh.CoherenceFinalizer) {
165165
err := in.finalizerManager.EnsureFinalizerRemoved(ctx, deployment)
166166
if err != nil && !apierrors.IsNotFound(err) {
167-
return ctrl.Result{Requeue: true}, errorhandling.NewOperationError("remove_finalizer", err).
167+
return ctrl.Result{}, errorhandling.NewOperationError("remove_finalizer", err).
168168
WithContext("resource", deployment.GetName()).
169169
WithContext("namespace", deployment.GetNamespace()).
170170
WithContext("reason", "allow_unsafe_delete")
@@ -238,7 +238,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
238238
}
239239

240240
// create the result
241-
result := ctrl.Result{Requeue: false}
241+
result := ctrl.Result{}
242242

243243
hash := deployment.GetGenerationString()
244244
storeHash, _ := storage.GetHash()
@@ -253,6 +253,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque
253253
if err = in.statusManager.UpdateDeploymentStatusHash(ctx, request.NamespacedName, hashNew); err != nil {
254254
return result, errors.Wrap(err, "error updating deployment status hash")
255255
}
256+
log.Info("Updated pre-3.5.0 Coherence resource status hash", "From", hash, "To", hashNew)
256257
return result, nil
257258
}
258259

@@ -369,8 +370,9 @@ func (in *CoherenceReconciler) SetupWithManager(mgr ctrl.Manager, cs clients.Cli
369370
}
370371

371372
in.statusManager = &status.StatusManager{
372-
Client: mgr.GetClient(),
373-
Log: in.Log.WithName("status"),
373+
Client: mgr.GetClient(),
374+
Log: in.Log.WithName("status"),
375+
Patcher: in.GetPatcher(),
374376
}
375377

376378
in.resourcesManager = &resources.OperatorSecretManager{

controllers/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func checkHash(deployment coh.CoherenceResource, phase coh.ConditionType, storag
3838
if hashFound {
3939
// The "storeHash" is not "", so it must have been previously processed by the Operator (could have been a previous version).
4040
// The operator now uses the Coherence resource's generation instead of calculating a hash, so if the version is
41-
// 3.4.3 or earlier and hash difference is ignored.
41+
// 3.4.3 or earlier the hash difference is ignored.
4242
if deployment.IsBeforeOrSameVersion("3.4.3") {
4343
// There is an edge case where the Coherence resource could have legitimately been updated whilst
4444
// the Operator and web-hooks were uninstalled. In that case we would ignore the update until another

controllers/status/status_manager.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ import (
1111
"github.com/go-logr/logr"
1212
coh "github.com/oracle/coherence-operator/api/v1"
1313
"github.com/oracle/coherence-operator/pkg/operator"
14+
"github.com/oracle/coherence-operator/pkg/patching"
1415
"github.com/pkg/errors"
1516
"k8s.io/apimachinery/pkg/types"
1617
"sigs.k8s.io/controller-runtime/pkg/client"
1718
)
1819

1920
// StatusManager manages the status of Coherence resources
2021
type StatusManager struct {
21-
Client client.Client
22-
Log logr.Logger
22+
Client client.Client
23+
Log logr.Logger
24+
Patcher patching.ResourcePatcher
2325
}
2426

2527
// UpdateCoherenceStatusPhase updates the phase of a Coherence resource
@@ -36,12 +38,7 @@ func (sm *StatusManager) UpdateCoherenceStatusPhase(ctx context.Context, namespa
3638
updated.Status.Phase = phase
3739

3840
// Update the resource
39-
err = sm.Client.Status().Patch(ctx, deployment, client.MergeFrom(updated))
40-
if err != nil {
41-
return errors.Wrapf(err, "updating status phase for Coherence resource %s/%s", namespacedName.Namespace, namespacedName.Name)
42-
}
43-
44-
return nil
41+
return sm.patchStatus(ctx, deployment, updated)
4542
}
4643

4744
// UpdateDeploymentStatusHash updates the hash in the status of a Coherence resource
@@ -59,10 +56,21 @@ func (sm *StatusManager) UpdateDeploymentStatusHash(ctx context.Context, namespa
5956
updated.Status.SetVersion(operator.GetVersion())
6057

6158
// Update the resource
62-
err = sm.Client.Status().Patch(ctx, deployment, client.MergeFrom(updated))
59+
return sm.patchStatus(ctx, deployment, updated)
60+
}
61+
62+
func (sm *StatusManager) patchStatus(ctx context.Context, original, updated *coh.Coherence) error {
63+
patch, err := sm.Patcher.CreateTwoWayPatchOfType(types.MergePatchType, original.Name, updated, original)
6364
if err != nil {
64-
return errors.Wrapf(err, "updating status hash for Coherence resource %s/%s", namespacedName.Namespace, namespacedName.Name)
65+
return errors.Wrapf(err, "creating status patch for Coherence resource %s/%s", original.Namespace, original.Name)
66+
}
67+
if patch != nil {
68+
sm.Log.Info("Patching status", "Namespace", original.Namespace, "Name", original.Name, "Patch", patch)
69+
err = sm.Client.Status().Patch(ctx, original, patch)
70+
if err != nil {
71+
return errors.Wrapf(err, "updating status for Coherence resource %s/%s", original.Namespace, original.Name)
72+
}
73+
sm.Log.Info("Patched status", "Namespace", original.Namespace, "Name", original.Name, "Patch", patch)
6574
}
66-
6775
return nil
6876
}

hack/github/github-pages.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fi
1414

1515
if [ "${OPERATOR_VERSION}" == "" ]
1616
then
17-
OPERATOR_VERSION=$(cat "${BUILD_OUTPUT}/OPERATOR_VERSION.txt")
17+
OPERATOR_VERSION=$(make version)
1818
fi
1919

2020
GITHUB_REPO=https://github.com/oracle/coherence-operator.git
@@ -41,18 +41,12 @@ rm -rf ${BUILD_GH_PAGES}/dashboards/latest || true
4141
cp -R ${BUILD_GH_PAGES}/dashboards/${OPERATOR_VERSION} ${BUILD_GH_PAGES}/dashboards/latest
4242
git add -A dashboards/latest/*
4343
44-
mkdir ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION} || true
45-
rm -rf ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION}/ || true
46-
cp -R ${BUILD_OUTPUT}/docs ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION}/
47-
rm -rf ${BUILD_GH_PAGES}/docs/latest
48-
cp -R ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION} ${BUILD_GH_PAGES}/docs/latest
49-
git add -A docs/*
50-
5144
mkdir -p ${BUILD_GH_PAGES}/charts || true
5245
cp ${BUILD_OUTPUT}/helm-charts/coherence-operator-${OPERATOR_VERSION}.tgz ${BUILD_GH_PAGES}/charts/
53-
helm repo index charts --url https://oracle.github.io/coherence-operator/charts
54-
git add charts/coherence-operator-${OPERATOR_VERSION}.tgz
55-
git add charts/index.yaml
46+
ls -al ${BUILD_GH_PAGES}/charts
47+
helm repo index ${BUILD_GH_PAGES}/charts --url https://oracle.github.io/coherence-operator/charts
48+
git add ${BUILD_GH_PAGES}/charts/coherence-operator-${OPERATOR_VERSION}.tgz
49+
git add ${BUILD_GH_PAGES}/charts/index.yaml
5650
5751
git clean -d -f
5852

java/operator-compatibility/src/main/java/com/oracle/coherence/k8s/testing/Setup.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2021, 2025, Oracle and/or its affiliates.
33
* Licensed under the Universal Permissive License v 1.0 as shown at
44
* http://oss.oracle.com/licenses/upl.
55
*/
@@ -10,6 +10,7 @@
1010
import java.nio.file.Path;
1111
import java.nio.file.Paths;
1212
import java.nio.file.StandardCopyOption;
13+
import java.nio.file.attribute.PosixFilePermissions;
1314

1415
/**
1516
* Set-up class run by the compatibility image build.
@@ -44,6 +45,10 @@ private static void copy(Path source, Path targetDir) throws Exception {
4445
if (source.toFile().exists()) {
4546
Path target = targetDir.resolve(source.getFileName());
4647
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
48+
Files.setPosixFilePermissions(target, PosixFilePermissions.fromString("rw-r--r--"));
49+
}
50+
else {
51+
System.out.println("Nothing to copy, source does not exist: " + source);
4752
}
4853
}
4954
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM ${coherence.compatibility.coherence.image}
1+
FROM ${coherence.compatibility.coherence.image} AS builder
22

33
USER root
44
COPY target/classes/build.sh build.sh
5-
COPY target/operator-compatibility-*.jar /app/libs/operator-compatibility.jar
5+
COPY --chmod=544 target/operator-compatibility-*.jar /app/libs/operator-compatibility.jar
66
RUN ["java", "-cp", "/app/libs/operator-compatibility.jar", "com.oracle.coherence.k8s.testing.Setup"]
77

88
FROM ${coherence.test.base.image}
99

10-
COPY --from=0 /app/ /app/
10+
COPY --from=builder /app/ /app/
1111

1212
ENTRYPOINT ["java", "-XshowSettings:all", "-XX:+PrintCommandLineFlags", "-XX:+PrintFlagsFinal", "-Dcoherence.ttl=0", "-cp", "/coherence/ext/conf:/coherence/ext/lib/*:/app/resources:/app/classes:/app/libs/*", "com.oracle.coherence.k8s.testing.RestServer"]

0 commit comments

Comments
 (0)