diff --git a/.github/workflows/coherence-matrix.yaml b/.github/workflows/coherence-matrix.yaml index 8275ba0f2..ff6fe7bab 100644 --- a/.github/workflows/coherence-matrix.yaml +++ b/.github/workflows/coherence-matrix.yaml @@ -220,8 +220,10 @@ jobs: echo "COHERENCE_IMAGE=${COHERENCE_IMAGE}" export BUILD_JAVA_VERSION=${{ matrix.javaVersion }} echo "BUILD_JAVA_VERSION=${BUILD_JAVA_VERSION}" - export COHERENCE_TEST_BASE_IMAGE=${{ matrix.baseImage }} - echo "COHERENCE_TEST_BASE_IMAGE=${COHERENCE_TEST_BASE_IMAGE}" + export COHERENCE_TEST_BASE_IMAGE_17=${{ matrix.baseImage }} + echo "COHERENCE_TEST_BASE_IMAGE_17=${COHERENCE_TEST_BASE_IMAGE_17}" + export COHERENCE_TEST_BASE_IMAGE_21=${{ matrix.baseImage }} + echo "COHERENCE_TEST_BASE_IMAGE_21=${COHERENCE_TEST_BASE_IMAGE_17}" export OPERATOR_COHERENCE_JAVA_8=${{ matrix.coherenceIsJava8 }} make clean echo "Building Operator Image" diff --git a/.github/workflows/compatibility-tests.yaml b/.github/workflows/compatibility-tests.yaml index e60b682db..6849a7c7e 100644 --- a/.github/workflows/compatibility-tests.yaml +++ b/.github/workflows/compatibility-tests.yaml @@ -45,42 +45,37 @@ jobs: - 3.3.5 - 3.3.4 - 3.3.3 - - 3.3.2 include: - compatibilityVersion: 3.5.0 - coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1" + coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2" compatibilitySelector: control-plane=coherence - k8s: kindest/node:v1.33.0@sha256:91e9ed777db80279c22d1d1068c091b899b2078506e4a0f797fbf6e397c0b0b2 + k8s: kindest/node:v1.33.1@sha256:050072256b9a903bd914c0b2866828150cb229cea0efe5892e2b644d5dd3b34f - compatibilityVersion: 3.4.3 - coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1" + coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2" compatibilitySelector: control-plane=coherence k8s: kindest/node:v1.32.2@sha256:f226345927d7e348497136874b6d207e0b32cc52154ad8323129352923a3142f - compatibilityVersion: 3.4.2 - coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1" + coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2" compatibilitySelector: control-plane=coherence k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245 - compatibilityVersion: 3.4.1 - coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-1" + coherence-image: "ghcr.io/oracle/coherence-ce:14.1.2-0-2" compatibilitySelector: control-plane=coherence k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245 - compatibilityVersion: 3.4.0 - coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10" + coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12" compatibilitySelector: control-plane=coherence k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245 - compatibilityVersion: 3.3.5 - coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10" + coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12" compatibilitySelector: control-plane=coherence k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245 - compatibilityVersion: 3.3.4 - coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10" + coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12" compatibilitySelector: control-plane=coherence k8s: kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245 - compatibilityVersion: 3.3.3 - coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10" - compatibilitySelector: control-plane=coherence - k8s: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72 - - compatibilityVersion: 3.3.2 - coherence-image: "ghcr.io/oracle/coherence-ce:22.06.10" + coherence-image: "ghcr.io/oracle/coherence-ce:22.06.12" compatibilitySelector: control-plane=coherence k8s: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72 diff --git a/controllers/coherence_controller.go b/controllers/coherence_controller.go index ebee2779f..7e5eff4c0 100644 --- a/controllers/coherence_controller.go +++ b/controllers/coherence_controller.go @@ -96,7 +96,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque // request for the same resource is already in progress so requeue this one. if ok := in.Lock(request); !ok { log.Info("Coherence resource " + request.Namespace + "/" + request.Name + " is already locked, requeue request") - return reconcile.Result{Requeue: true, RequeueAfter: 0}, nil + return reconcile.Result{RequeueAfter: time.Minute}, nil } // Make sure that the request is unlocked when this method exits defer in.Unlock(request) @@ -134,7 +134,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque msg := fmt.Sprintf("failed to finalize Coherence resource, %s", err.Error()) in.GetEventRecorder().Event(deployment, coreV1.EventTypeWarning, reconciler.EventReasonDeleted, msg) log.Error(err, "Failed to remove finalizer") - return ctrl.Result{Requeue: true}, nil + return ctrl.Result{RequeueAfter: time.Minute}, nil } // Remove the finalizer. Once all finalizers have been // removed, the object will be deleted. @@ -164,7 +164,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque if controllerutil.ContainsFinalizer(deployment, coh.CoherenceFinalizer) { err := in.finalizerManager.EnsureFinalizerRemoved(ctx, deployment) if err != nil && !apierrors.IsNotFound(err) { - return ctrl.Result{Requeue: true}, errorhandling.NewOperationError("remove_finalizer", err). + return ctrl.Result{}, errorhandling.NewOperationError("remove_finalizer", err). WithContext("resource", deployment.GetName()). WithContext("namespace", deployment.GetNamespace()). WithContext("reason", "allow_unsafe_delete") @@ -238,7 +238,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque } // create the result - result := ctrl.Result{Requeue: false} + result := ctrl.Result{} hash := deployment.GetGenerationString() storeHash, _ := storage.GetHash() @@ -253,6 +253,7 @@ func (in *CoherenceReconciler) Reconcile(ctx context.Context, request ctrl.Reque if err = in.statusManager.UpdateDeploymentStatusHash(ctx, request.NamespacedName, hashNew); err != nil { return result, errors.Wrap(err, "error updating deployment status hash") } + log.Info("Updated pre-3.5.0 Coherence resource status hash", "From", hash, "To", hashNew) return result, nil } @@ -369,8 +370,9 @@ func (in *CoherenceReconciler) SetupWithManager(mgr ctrl.Manager, cs clients.Cli } in.statusManager = &status.StatusManager{ - Client: mgr.GetClient(), - Log: in.Log.WithName("status"), + Client: mgr.GetClient(), + Log: in.Log.WithName("status"), + Patcher: in.GetPatcher(), } in.resourcesManager = &resources.OperatorSecretManager{ diff --git a/controllers/common.go b/controllers/common.go index bd5e6682d..d4d344396 100644 --- a/controllers/common.go +++ b/controllers/common.go @@ -38,7 +38,7 @@ func checkHash(deployment coh.CoherenceResource, phase coh.ConditionType, storag if hashFound { // The "storeHash" is not "", so it must have been previously processed by the Operator (could have been a previous version). // The operator now uses the Coherence resource's generation instead of calculating a hash, so if the version is - // 3.4.3 or earlier and hash difference is ignored. + // 3.4.3 or earlier the hash difference is ignored. if deployment.IsBeforeOrSameVersion("3.4.3") { // There is an edge case where the Coherence resource could have legitimately been updated whilst // the Operator and web-hooks were uninstalled. In that case we would ignore the update until another diff --git a/controllers/status/status_manager.go b/controllers/status/status_manager.go index a48eb8820..c148c1898 100644 --- a/controllers/status/status_manager.go +++ b/controllers/status/status_manager.go @@ -11,6 +11,7 @@ import ( "github.com/go-logr/logr" coh "github.com/oracle/coherence-operator/api/v1" "github.com/oracle/coherence-operator/pkg/operator" + "github.com/oracle/coherence-operator/pkg/patching" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -18,8 +19,9 @@ import ( // StatusManager manages the status of Coherence resources type StatusManager struct { - Client client.Client - Log logr.Logger + Client client.Client + Log logr.Logger + Patcher patching.ResourcePatcher } // UpdateCoherenceStatusPhase updates the phase of a Coherence resource @@ -36,12 +38,7 @@ func (sm *StatusManager) UpdateCoherenceStatusPhase(ctx context.Context, namespa updated.Status.Phase = phase // Update the resource - err = sm.Client.Status().Patch(ctx, deployment, client.MergeFrom(updated)) - if err != nil { - return errors.Wrapf(err, "updating status phase for Coherence resource %s/%s", namespacedName.Namespace, namespacedName.Name) - } - - return nil + return sm.patchStatus(ctx, deployment, updated) } // UpdateDeploymentStatusHash updates the hash in the status of a Coherence resource @@ -59,10 +56,21 @@ func (sm *StatusManager) UpdateDeploymentStatusHash(ctx context.Context, namespa updated.Status.SetVersion(operator.GetVersion()) // Update the resource - err = sm.Client.Status().Patch(ctx, deployment, client.MergeFrom(updated)) + return sm.patchStatus(ctx, deployment, updated) +} + +func (sm *StatusManager) patchStatus(ctx context.Context, original, updated *coh.Coherence) error { + patch, err := sm.Patcher.CreateTwoWayPatchOfType(types.MergePatchType, original.Name, updated, original) if err != nil { - return errors.Wrapf(err, "updating status hash for Coherence resource %s/%s", namespacedName.Namespace, namespacedName.Name) + return errors.Wrapf(err, "creating status patch for Coherence resource %s/%s", original.Namespace, original.Name) + } + if patch != nil { + sm.Log.Info("Patching status", "Namespace", original.Namespace, "Name", original.Name, "Patch", patch) + err = sm.Client.Status().Patch(ctx, original, patch) + if err != nil { + return errors.Wrapf(err, "updating status for Coherence resource %s/%s", original.Namespace, original.Name) + } + sm.Log.Info("Patched status", "Namespace", original.Namespace, "Name", original.Name, "Patch", patch) } - return nil } diff --git a/hack/github/github-pages.sh b/hack/github/github-pages.sh index 96c1ebe73..d341f0ab7 100644 --- a/hack/github/github-pages.sh +++ b/hack/github/github-pages.sh @@ -14,7 +14,7 @@ fi if [ "${OPERATOR_VERSION}" == "" ] then - OPERATOR_VERSION=$(cat "${BUILD_OUTPUT}/OPERATOR_VERSION.txt") + OPERATOR_VERSION=$(make version) fi GITHUB_REPO=https://github.com/oracle/coherence-operator.git @@ -41,18 +41,12 @@ rm -rf ${BUILD_GH_PAGES}/dashboards/latest || true cp -R ${BUILD_GH_PAGES}/dashboards/${OPERATOR_VERSION} ${BUILD_GH_PAGES}/dashboards/latest git add -A dashboards/latest/* -mkdir ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION} || true -rm -rf ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION}/ || true -cp -R ${BUILD_OUTPUT}/docs ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION}/ -rm -rf ${BUILD_GH_PAGES}/docs/latest -cp -R ${BUILD_GH_PAGES}/docs/${OPERATOR_VERSION} ${BUILD_GH_PAGES}/docs/latest -git add -A docs/* - mkdir -p ${BUILD_GH_PAGES}/charts || true cp ${BUILD_OUTPUT}/helm-charts/coherence-operator-${OPERATOR_VERSION}.tgz ${BUILD_GH_PAGES}/charts/ -helm repo index charts --url https://oracle.github.io/coherence-operator/charts -git add charts/coherence-operator-${OPERATOR_VERSION}.tgz -git add charts/index.yaml +ls -al ${BUILD_GH_PAGES}/charts +helm repo index ${BUILD_GH_PAGES}/charts --url https://oracle.github.io/coherence-operator/charts +git add ${BUILD_GH_PAGES}/charts/coherence-operator-${OPERATOR_VERSION}.tgz +git add ${BUILD_GH_PAGES}/charts/index.yaml git clean -d -f diff --git a/java/operator-compatibility/src/main/java/com/oracle/coherence/k8s/testing/Setup.java b/java/operator-compatibility/src/main/java/com/oracle/coherence/k8s/testing/Setup.java index 5d8c95934..6df3fb6c6 100644 --- a/java/operator-compatibility/src/main/java/com/oracle/coherence/k8s/testing/Setup.java +++ b/java/operator-compatibility/src/main/java/com/oracle/coherence/k8s/testing/Setup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Oracle and/or its affiliates. + * Copyright (c) 2021, 2025, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -10,6 +10,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; +import java.nio.file.attribute.PosixFilePermissions; /** * Set-up class run by the compatibility image build. @@ -44,6 +45,10 @@ private static void copy(Path source, Path targetDir) throws Exception { if (source.toFile().exists()) { Path target = targetDir.resolve(source.getFileName()); Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING); + Files.setPosixFilePermissions(target, PosixFilePermissions.fromString("rw-r--r--")); + } + else { + System.out.println("Nothing to copy, source does not exist: " + source); } } } diff --git a/java/operator-compatibility/src/main/resources/Dockerfile b/java/operator-compatibility/src/main/resources/Dockerfile index a2265a3b2..3d9831ff5 100644 --- a/java/operator-compatibility/src/main/resources/Dockerfile +++ b/java/operator-compatibility/src/main/resources/Dockerfile @@ -1,12 +1,12 @@ -FROM ${coherence.compatibility.coherence.image} +FROM ${coherence.compatibility.coherence.image} AS builder USER root COPY target/classes/build.sh build.sh -COPY target/operator-compatibility-*.jar /app/libs/operator-compatibility.jar +COPY --chmod=544 target/operator-compatibility-*.jar /app/libs/operator-compatibility.jar RUN ["java", "-cp", "/app/libs/operator-compatibility.jar", "com.oracle.coherence.k8s.testing.Setup"] FROM ${coherence.test.base.image} -COPY --from=0 /app/ /app/ +COPY --from=builder /app/ /app/ 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"]