diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2fbd422d0..2ff32e6ed 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,4 +1,4 @@ -# Copyright 2019, 2022 Oracle Corporation and/or its affiliates. All rights reserved. +# Copyright 2019, 2022, Oracle Corporation and/or its affiliates. All rights reserved. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. @@ -95,7 +95,8 @@ jobs: kubectl version kubectl get nodes docker pull gcr.io/distroless/java - docker pull gcr.io/distroless/java:11 + docker pull gcr.io/distroless/java11 + docker pull gcr.io/distroless/java17 - name: Code Review shell: bash diff --git a/.github/workflows/coherence-matrix.yaml b/.github/workflows/coherence-matrix.yaml index 1ff8eb797..a698f66a4 100644 --- a/.github/workflows/coherence-matrix.yaml +++ b/.github/workflows/coherence-matrix.yaml @@ -127,7 +127,8 @@ jobs: docker login container-registry.oracle.com -u "${{ secrets.OCR_DOCKER_USERNAME }}" -p "${{ secrets.OCR_DOCKER_PASSWORD }}" docker login "${{ secrets.OCI_REGISTRY }}" -u "${{ secrets.OCI_USERNAME }}" -p "${{ secrets.OCI_PASSWORD }}" docker pull gcr.io/distroless/java - docker pull gcr.io/distroless/java:11 + docker pull gcr.io/distroless/java11 + docker pull gcr.io/distroless/java17 docker pull ${{ matrix.coherence-image }} - name: Coherence Certification Tests diff --git a/.github/workflows/compatibility-tests.yaml b/.github/workflows/compatibility-tests.yaml index abf06445c..da0ca044e 100644 --- a/.github/workflows/compatibility-tests.yaml +++ b/.github/workflows/compatibility-tests.yaml @@ -120,7 +120,8 @@ jobs: kubectl version kubectl get nodes docker pull gcr.io/distroless/java - docker pull gcr.io/distroless/java:11 + docker pull gcr.io/distroless/java11 + docker pull gcr.io/distroless/java17 - name: Build shell: bash diff --git a/.github/workflows/istio-tests.yaml b/.github/workflows/istio-tests.yaml index 9a90bc5c4..08f6efd17 100644 --- a/.github/workflows/istio-tests.yaml +++ b/.github/workflows/istio-tests.yaml @@ -102,7 +102,8 @@ jobs: kubectl version kubectl get nodes docker pull gcr.io/distroless/java - docker pull gcr.io/distroless/java:11 + docker pull gcr.io/distroless/java11 + docker pull gcr.io/distroless/java17 - name: Build shell: bash diff --git a/.github/workflows/k8s-matrix.yaml b/.github/workflows/k8s-matrix.yaml index 45f56f563..d3b56ee05 100644 --- a/.github/workflows/k8s-matrix.yaml +++ b/.github/workflows/k8s-matrix.yaml @@ -108,7 +108,8 @@ jobs: kubectl version kubectl get nodes docker pull gcr.io/distroless/java - docker pull gcr.io/distroless/java:11 + docker pull gcr.io/distroless/java11 + docker pull gcr.io/distroless/java17 - name: Certification Tests shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d9386c18..b976d6a21 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2020, 2021, Oracle and/or its affiliates. +# Copyright (c) 2020, 2022, Oracle and/or its affiliates. # Licensed under the Universal Permissive License v 1.0 as shown at # http://oss.oracle.com/licenses/upl. @@ -52,7 +52,8 @@ jobs: kubectl version kubectl get nodes docker pull gcr.io/distroless/java - docker pull gcr.io/distroless/java:11 + docker pull gcr.io/distroless/java11 + docker pull gcr.io/distroless/java17 - name: Release shell: bash diff --git a/Makefile b/Makefile index 5d520dfd2..0d90ed8b9 100644 --- a/Makefile +++ b/Makefile @@ -29,11 +29,14 @@ COMPATIBLE_VERSION = 3.2.4 # The selector to use to find Operator Pods of the COMPATIBLE_VERSION (do not put in double quotes!!) COMPATIBLE_SELECTOR = control-plane=coherence +# The GitHub project URL +PROJECT_URL = https://github.com/oracle/coherence-operator + # ---------------------------------------------------------------------------------------------------------------------- # The Coherence image to use for deployments that do not specify an image # ---------------------------------------------------------------------------------------------------------------------- -COHERENCE_VERSION ?= 21.12 -COHERENCE_IMAGE ?= ghcr.io/oracle/coherence-ce:21.12 +COHERENCE_VERSION ?= 21.12.1 +COHERENCE_IMAGE ?= ghcr.io/oracle/coherence-ce:21.12.1 # This is the Coherence image that will be used in tests. # Changing this variable will allow test builds to be run against different Coherence versions # without altering the default image name. @@ -76,11 +79,13 @@ OPERATOR_IMAGE := $(OPERATOR_IMAGE_REPO):$(VERSION) OPERATOR_IMAGE_DELVE := $(OPERATOR_IMAGE_REPO):delve OPERATOR_IMAGE_DEBUG := $(OPERATOR_IMAGE_REPO):debug UTILS_IMAGE ?= $(OPERATOR_IMAGE_REPO):$(VERSION)-utils +TEST_BASE_IMAGE ?= $(OPERATOR_IMAGE_REPO)-test-base:$(VERSION) # The Operator images to push -OPERATOR_RELEASE_REPO ?= $(OPERATOR_IMAGE_REPO) -OPERATOR_RELEASE_IMAGE := $(OPERATOR_RELEASE_REPO):$(VERSION) -UTILS_RELEASE_IMAGE := $(OPERATOR_RELEASE_REPO):$(VERSION)-utils -BUNDLE_RELEASE_IMAGE := $(OPERATOR_RELEASE_REPO):$(VERSION)-bundle +OPERATOR_RELEASE_REPO ?= $(OPERATOR_IMAGE_REPO) +OPERATOR_RELEASE_IMAGE := $(OPERATOR_RELEASE_REPO):$(VERSION) +UTILS_RELEASE_IMAGE := $(OPERATOR_RELEASE_REPO):$(VERSION)-utils +TEST_BASE_RELEASE_IMAGE := $(OPERATOR_RELEASE_REPO)-test-base:$(VERSION) +BUNDLE_RELEASE_IMAGE := $(OPERATOR_RELEASE_REPO):$(VERSION)-bundle GPG_PASSPHRASE := @@ -88,7 +93,6 @@ GPG_PASSPHRASE := # The test application images used in integration tests # ---------------------------------------------------------------------------------------------------------------------- TEST_APPLICATION_IMAGE := $(RELEASE_IMAGE_PREFIX)operator-test:1.0.0 -TEST_APPLICATION_IMAGE_WITH_UTILS := $(RELEASE_IMAGE_PREFIX)operator-test-with-utils:1.0.0 TEST_COMPATIBILITY_IMAGE := $(RELEASE_IMAGE_PREFIX)operator-test-compatibility:1.0.0 TEST_APPLICATION_IMAGE_CLIENT := $(RELEASE_IMAGE_PREFIX)operator-test-client:1.0.0 TEST_APPLICATION_IMAGE_HELIDON := $(RELEASE_IMAGE_PREFIX)operator-test-helidon:1.0.0 @@ -404,11 +408,27 @@ build-utils: build-mvn $(BUILD_BIN)/runner ## Build the Coherence Operator util docker build --no-cache --build-arg target=arm64 -t $(UTILS_IMAGE)-arm64 java/coherence-operator/target/docker docker tag $(UTILS_IMAGE)-$(IMAGE_ARCH) $(UTILS_IMAGE) +# ---------------------------------------------------------------------------------------------------------------------- +# Build the Operator base test image +# ---------------------------------------------------------------------------------------------------------------------- +.PHONY: build-test-base +build-test-base: export ARTIFACT_DIR := $(CURRDIR)/java/coherence-operator +build-test-base: export VERSION := $(VERSION) +build-test-base: export IMAGE_NAME := $(TEST_BASE_IMAGE) +build-test-base: export AMD_BASE_IMAGE := gcr.io/distroless/java11 +build-test-base: export ARM_BASE_IMAGE := gcr.io/distroless/java11 +build-test-base: export PROJECT_URL := $(PROJECT_URL) +build-test-base: export PROJECT_VENDOR := Oracle +build-test-base: export PROJECT_DESCRIPTION := Oracle Coherence bease test image +build-test-base: build-mvn $(BUILD_BIN)/runner ## Build the Coherence test base image + cp -R $(BUILD_BIN)/linux java/coherence-operator/target/docker + $(CURRDIR)/java/coherence-operator/run-buildah.sh BUILD + # ---------------------------------------------------------------------------------------------------------------------- # Build the Operator images without the test images # ---------------------------------------------------------------------------------------------------------------------- .PHONY: build-operator-images -build-operator-images: $(BUILD_TARGETS)/build-operator build-utils ## Build all operator images +build-operator-images: $(BUILD_TARGETS)/build-operator build-utils build-test-base ## Build all operator images # ---------------------------------------------------------------------------------------------------------------------- # Build the Operator Test images @@ -430,7 +450,6 @@ build-test-images: build-mvn build-client-image build-basic-test-image ## Build .PHONY: build-basic-test-image build-basic-test-image: build-mvn ## Build the basic Operator test image ./mvnw -B -f java/operator-test package jib:dockerBuild -DskipTests -Djib.to.image=$(TEST_APPLICATION_IMAGE) $(MAVEN_BUILD_OPTS) - ./mvnw -B -f java/operator-test-with-utils package jib:dockerBuild -am -nsu -DskipTests -Djib.to.image=$(TEST_APPLICATION_IMAGE_WITH_UTILS) $(MAVEN_BUILD_OPTS) .PHONY: build-client-image build-client-image: ## Build the test client image @@ -440,7 +459,7 @@ build-client-image: ## Build the test client image # Build all of the Docker images # ---------------------------------------------------------------------------------------------------------------------- .PHONY: build-all-images -build-all-images: $(BUILD_TARGETS)/build-operator build-utils build-test-images ## Build all images (including tests) +build-all-images: $(BUILD_TARGETS)/build-operator build-utils build-test-base build-test-images ## Build all images (including tests) # ---------------------------------------------------------------------------------------------------------------------- # Build the operator linux binary @@ -1568,6 +1587,24 @@ else docker manifest push $(UTILS_RELEASE_IMAGE) endif +# ---------------------------------------------------------------------------------------------------------------------- +# Push the test base images +# ---------------------------------------------------------------------------------------------------------------------- +.PHONY: push-test-base-images +push-test-base-images: +ifeq ($(TEST_BASE_RELEASE_IMAGE), $(TEST_BASE_IMAGE)) + @echo "Pushing $(TEST_BASE_IMAGE)" + ./mvnw -B -f java/coherence-operator package -P push-test-base-image -pl coherence-operator \ + -DskipTests -Dimage.name=$(TEST_BASE_IMAGE) +else + @echo "Tagging $(TEST_BASE_IMAGE)-amd64 as $(TEST_BASE_RELEASE_IMAGE)-amd64" + docker tag $(TEST_BASE_IMAGE)-amd64 $(TEST_BASE_RELEASE_IMAGE)-amd64 + @echo "Tagging $(TEST_BASE_IMAGE)-arm64 as $(TEST_BASE_RELEASE_IMAGE)-arm64" + docker tag $(TEST_BASE_IMAGE)-arm64 $(TEST_BASE_RELEASE_IMAGE)-arm64 + ./mvnw -B -f java/coherence-operator package -P push-test-base-image -pl coherence-operator \ + -DskipTests -Dimage.name=$(TEST_BASE_RELEASE_IMAGE) +endif + # ---------------------------------------------------------------------------------------------------------------------- # Push the Operator JIB Test Docker images # ---------------------------------------------------------------------------------------------------------------------- @@ -1603,13 +1640,13 @@ push-compatibility-image: # Push all of the Docker images # ---------------------------------------------------------------------------------------------------------------------- .PHONY: push-all-images -push-all-images: push-test-images push-utils-image push-operator-image +push-all-images: push-test-images push-test-base-images push-utils-image push-operator-image # ---------------------------------------------------------------------------------------------------------------------- # Push all of the Docker images that are released # ---------------------------------------------------------------------------------------------------------------------- .PHONY: push-release-images -push-release-images: push-utils-image push-operator-image +push-release-images: push-test-base-images push-utils-image push-operator-image # ---------------------------------------------------------------------------------------------------------------------- # Install Prometheus diff --git a/docs/about/04_coherence_spec.adoc b/docs/about/04_coherence_spec.adoc index 344afe4bc..5a6b15caf 100644 --- a/docs/about/04_coherence_spec.adoc +++ b/docs/about/04_coherence_spec.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2020, 2021, Oracle and/or its affiliates. + Copyright (c) 2020, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. diff --git a/docs/management/100_tmb_test.adoc b/docs/management/100_tmb_test.adoc index 9d626aaf4..2cb271c33 100644 --- a/docs/management/100_tmb_test.adoc +++ b/docs/management/100_tmb_test.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2020, Oracle and/or its affiliates. + Copyright (c) 2020, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. @@ -54,7 +54,7 @@ spec: restartPolicy: Never containers: - name: coherence - image: ghcr.io/oracle/coherence-ce:21.06.2 # <1> + image: ghcr.io/oracle/coherence-ce:21.12.1 # <1> ports: - name: mbus containerPort: 8000 @@ -101,7 +101,7 @@ spec: restartPolicy: Never containers: - name: coherence - image: ghcr.io/oracle/coherence-ce:21.06.2 + image: ghcr.io/oracle/coherence-ce:21.12.1 command: - java # <1> - -cp diff --git a/docs/metrics/020_metrics.adoc b/docs/metrics/020_metrics.adoc index 7e98127b5..076f7bdb5 100644 --- a/docs/metrics/020_metrics.adoc +++ b/docs/metrics/020_metrics.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2020, 2021, Oracle and/or its affiliates. + Copyright (c) 2020, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. @@ -15,7 +15,7 @@ This would typically be used to expose metrics to something like Prometheus. NOTE: The default metrics endpoint is *disabled* by default in Coherence clusters but can be enabled and configured by setting the relevant fields in the `Coherence` CRD. -If your Coherence version is before CE 21.06.2 this example assumes that your application has included the +If your Coherence version is before CE 21.12.1 this example assumes that your application has included the `coherence-metrics` module as a dependency. See the Coherence product documentation for more details on enabling metrics in your application. diff --git a/examples/015_simple_image/README.adoc b/examples/015_simple_image/README.adoc index 222f3da06..8a9c49378 100644 --- a/examples/015_simple_image/README.adoc +++ b/examples/015_simple_image/README.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2021, Oracle and/or its affiliates. + Copyright (c) 2021, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. @@ -52,7 +52,7 @@ In the `build.gradle` file we add the bom as a platform dependency. .build.gradle ---- dependencies { - implementation platform("com.oracle.coherence.ce:coherence-bom:21.06.2") + implementation platform("com.oracle.coherence.ce:coherence-bom:21.12.1") ---- We can then add the `coherence` and `coherence-management` modules as dependencies @@ -77,7 +77,7 @@ In the `build.gradle` file we add the bom as a platform dependency. .build.gradle ---- dependencies { - implementation platform("com.oracle.coherence.ce:coherence-bom:21.06.2") + implementation platform("com.oracle.coherence.ce:coherence-bom:21.12.1") implementation "com.oracle.coherence.ce:coherence" implementation "com.oracle.coherence.ce:coherence-management" @@ -136,7 +136,7 @@ In the `pom.xml` file we configure the plugin where it is declared in the `plugi ${version.plugin.jib} - gcr.io/distroless/java:11 <1> + gcr.io/distroless/java11 <1> ${project.artifactId} <2> @@ -152,7 +152,7 @@ In the `pom.xml` file we configure the plugin where it is declared in the `plugi ---- -<1> The base image will be `gcr.io/distroless/java:11` +<1> The base image will be `gcr.io/distroless/java11` <2> The image name is set to the Maven module name using the property `${project.artifactId}` <3> There will be two tags for the image, `latest` and the project version taken from the `${project.version}` property. <4> The main class to use when the image is run is set to `com.tangosol.net.Coherence` @@ -166,7 +166,7 @@ In the `build.gradle` file we configure JIB in the `jib` section: ---- jib { from { - image = 'gcr.io/distroless/java:11' // <1> + image = 'gcr.io/distroless/java11' // <1> } to { image = "${project.name}" // <2> @@ -178,7 +178,7 @@ jib { } } ---- -<1> The base image will be `gcr.io/distroless/java:11` +<1> The base image will be `gcr.io/distroless/java11` <2> The image name is set to the Maven module name using the property `${project.artifactId}` <3> There will be two tags for the image, `latest` and the project version taken from the `${project.version}` property. <4> The main class to use when the image is run is set to `com.tangosol.net.Coherence` diff --git a/examples/015_simple_image/build.gradle b/examples/015_simple_image/build.gradle index d7b84a790..b74eeab65 100644 --- a/examples/015_simple_image/build.gradle +++ b/examples/015_simple_image/build.gradle @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -19,7 +19,7 @@ repositories { } dependencies { - implementation platform("com.oracle.coherence.ce:coherence-bom:21.06.2") + implementation platform("com.oracle.coherence.ce:coherence-bom:21.12.1") implementation "com.oracle.coherence.ce:coherence" implementation "com.oracle.coherence.ce:coherence-management" @@ -27,7 +27,7 @@ dependencies { jib { from { - image = 'gcr.io/distroless/java:11' + image = 'gcr.io/distroless/java11' } to { image = "${project.name}" diff --git a/examples/015_simple_image/pom.xml b/examples/015_simple_image/pom.xml index 89c9b2ee9..031155674 100644 --- a/examples/015_simple_image/pom.xml +++ b/examples/015_simple_image/pom.xml @@ -1,7 +1,7 @@ @@ -24,7 +24,7 @@ 8 8 - 21.06.2 + 21.12.1 3.1.4 @@ -60,7 +60,7 @@ ${version.plugin.jib} - gcr.io/distroless/java:11 + gcr.io/distroless/java11 ${project.artifactId} diff --git a/examples/021_deployment/pom.xml b/examples/021_deployment/pom.xml index 851af6fac..6422f4c47 100644 --- a/examples/021_deployment/pom.xml +++ b/examples/021_deployment/pom.xml @@ -1,6 +1,6 @@ @@ -16,7 +16,7 @@ com.oracle.coherence.ce - 21.06.2 + 21.12.1 1.3.1 @@ -62,7 +62,7 @@ ${jib.version} - gcr.io/distroless/java:11 + gcr.io/distroless/java11 ${project.artifactId} diff --git a/examples/090_tls/README.adoc b/examples/090_tls/README.adoc index 086cdf769..b2a02a0bb 100644 --- a/examples/090_tls/README.adoc +++ b/examples/090_tls/README.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2021, Oracle and/or its affiliates. + Copyright (c) 2021, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. @@ -623,7 +623,7 @@ We will see json something like this: "refreshTime": "2021-03-07T12:27:20.193Z", "licenseMode": "Development", "localMemberId": 1, - "version": "21.06", + "version": "21.12.1", "running": true, "clusterName": "test-cluster", "membersDepartureCount": 0, @@ -901,7 +901,7 @@ kubectl -n coherence-test logs client [source] ---- -2021-03-07 12:53:13.481/1.992 Oracle Coherence CE 21.06 (thread=main, member=n/a): Error while starting service "Proxy": com.tangosol.net.messaging.ConnectionException: could not establish a connection to one of the following addresses: [] +2021-03-07 12:53:13.481/1.992 Oracle Coherence CE 21.12.1 (thread=main, member=n/a): Error while starting service "Proxy": com.tangosol.net.messaging.ConnectionException: could not establish a connection to one of the following addresses: [] ---- This tells us that the client failed to connect to the cluster, because the client is not using TLS. diff --git a/examples/090_tls/client/pom.xml b/examples/090_tls/client/pom.xml index 885531d27..1a1ce4617 100644 --- a/examples/090_tls/client/pom.xml +++ b/examples/090_tls/client/pom.xml @@ -1,6 +1,6 @@ @@ -35,7 +35,7 @@ ${jib.version} - gcr.io/distroless/java:11 + gcr.io/distroless/java11 ${project.artifactId} diff --git a/examples/090_tls/pom.xml b/examples/090_tls/pom.xml index 819da424c..b7092ecf4 100644 --- a/examples/090_tls/pom.xml +++ b/examples/090_tls/pom.xml @@ -1,6 +1,6 @@ @@ -26,7 +26,7 @@ 11 com.oracle.coherence.ce - 21.06.2 + 21.12.1 3.1.4 diff --git a/examples/090_tls/server/pom.xml b/examples/090_tls/server/pom.xml index ddd6e7bdf..b3c41fa61 100644 --- a/examples/090_tls/server/pom.xml +++ b/examples/090_tls/server/pom.xml @@ -1,6 +1,6 @@ @@ -42,7 +42,7 @@ ${jib.version} - gcr.io/distroless/java:11 + gcr.io/distroless/java11 ${project.artifactId} diff --git a/examples/200_autoscaler/pom.xml b/examples/200_autoscaler/pom.xml index 484fdabd3..12457b192 100644 --- a/examples/200_autoscaler/pom.xml +++ b/examples/200_autoscaler/pom.xml @@ -1,6 +1,6 @@ @@ -20,7 +20,7 @@ 11 com.oracle.coherence.ce - 21.06.2 + 21.12.1 3.1.4 @@ -52,7 +52,7 @@ ${jib.version} - gcr.io/distroless/java:11 + gcr.io/distroless/java11 ${project.artifactId} diff --git a/examples/no-operator/01_simple_server/README.adoc b/examples/no-operator/01_simple_server/README.adoc index 6cd7049fa..770131ada 100644 --- a/examples/no-operator/01_simple_server/README.adoc +++ b/examples/no-operator/01_simple_server/README.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2021, Oracle and/or its affiliates. + Copyright (c) 2021, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. @@ -267,8 +267,8 @@ Map (?): cache test We should see output something like this: [source] ---- -2021-09-17 12:25:12.143/14.600 Oracle Coherence CE 21.06.2 (thread=com.tangosol.net.CacheFactory.main(), member=1): Loaded cache configuration from "file:/Users/jonathanknight/dev/Projects/GitOracle/coherence-operator-3.0/examples/no-operator/test-client/target/classes/client-cache-config.xml" -2021-09-17 12:25:12.207/14.664 Oracle Coherence CE 21.06.2 (thread=com.tangosol.net.CacheFactory.main(), member=1): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory +2021-09-17 12:25:12.143/14.600 Oracle Coherence CE 21.12.1 (thread=com.tangosol.net.CacheFactory.main(), member=1): Loaded cache configuration from "file:/Users/jonathanknight/dev/Projects/GitOracle/coherence-operator-3.0/examples/no-operator/test-client/target/classes/client-cache-config.xml" +2021-09-17 12:25:12.207/14.664 Oracle Coherence CE 21.12.1 (thread=com.tangosol.net.CacheFactory.main(), member=1): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory Cache Configuration: test SchemeName: remote diff --git a/examples/no-operator/02_metrics/README.adoc b/examples/no-operator/02_metrics/README.adoc index c26e16c92..2de8bbd4c 100644 --- a/examples/no-operator/02_metrics/README.adoc +++ b/examples/no-operator/02_metrics/README.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2021, Oracle and/or its affiliates. + Copyright (c) 2021, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. @@ -145,9 +145,9 @@ curl -X GET http://127.0.0.1:9612/metrics/Coherence.Cluster.Size which will display something like this: [source,bash] ---- -vendor:coherence_cluster_size{cluster="storage", version="21.06.2"} 3 +vendor:coherence_cluster_size{cluster="storage", version="21.12.1"} 3 ---- -This displays the metric name in Prometheus format `vendor:coherence_cluster_size`, the metric labels `cluster="storage", version="21.06.2"` and the metric value, in this case `3` as there are three cluster members because we specified a replicas value of 3 in the `StatefulSet`. +This displays the metric name in Prometheus format `vendor:coherence_cluster_size`, the metric labels `cluster="storage", version="21.12.1"` and the metric value, in this case `3` as there are three cluster members because we specified a replicas value of 3 in the `StatefulSet`. We can also receive the same response as `json` by using either the accepted media type header `"Accept: application/json"`: [source,bash] @@ -163,7 +163,7 @@ curl -X GET http://127.0.0.1:9612/metrics/Coherence.Cluster.Size.json Both requests will display something like this: [source,bash] ---- -[{"name":"Coherence.Cluster.Size","tags":{"cluster":"storage","version":"21.06.2"},"scope":"VENDOR","value":3}] +[{"name":"Coherence.Cluster.Size","tags":{"cluster":"storage","version":"21.12.1"},"scope":"VENDOR","value":3}] ---- We have now verified that the `Pods` in the cluster are producing metrics. diff --git a/examples/no-operator/03_extend_tls/README.adoc b/examples/no-operator/03_extend_tls/README.adoc index 2e04d260a..98181fcb2 100644 --- a/examples/no-operator/03_extend_tls/README.adoc +++ b/examples/no-operator/03_extend_tls/README.adoc @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// - Copyright (c) 2021, Oracle and/or its affiliates. + Copyright (c) 2021, 2022, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. @@ -347,7 +347,7 @@ Map (?): cache test This will not throw an exception because the client is not using TLS so the server rejected the connection. [source] ---- -2021-09-17 18:19:39.182/12.090 Oracle Coherence CE 21.06.2 (thread=com.tangosol.net.CacheFactory.main(), member=1): Error while starting service "RemoteCache": com.tangosol.net.messaging.ConnectionException: could not establish a connection to one of the following addresses: [127.0.0.1:20000] +2021-09-17 18:19:39.182/12.090 Oracle Coherence CE 21.12.1 (thread=com.tangosol.net.CacheFactory.main(), member=1): Error while starting service "RemoteCache": com.tangosol.net.messaging.ConnectionException: could not establish a connection to one of the following addresses: [127.0.0.1:20000] at com.tangosol.coherence.component.util.daemon.queueProcessor.service.peer.initiator.TcpInitiator.openConnection(TcpInitiator.CDB:139) at com.tangosol.coherence.component.util.daemon.queueProcessor.service.peer.Initiator.ensureConnection(Initiator.CDB:11) at com.tangosol.coherence.component.net.extend.remoteService.RemoteCacheService.openChannel(RemoteCacheService.CDB:7) diff --git a/examples/no-operator/test-client/pom.xml b/examples/no-operator/test-client/pom.xml index 0a051b0a7..135d02c27 100644 --- a/examples/no-operator/test-client/pom.xml +++ b/examples/no-operator/test-client/pom.xml @@ -1,7 +1,7 @@ @@ -25,7 +25,7 @@ 8 - 21.06.2 + 21.12.1 ${project.basedir} diff --git a/java/coherence-operator/build-images.sh b/java/coherence-operator/build-images.sh new file mode 100755 index 000000000..91c5b9276 --- /dev/null +++ b/java/coherence-operator/build-images.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2022, Oracle and/or its affiliates. +# +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# + +# --------------------------------------------------------------------------- +# This script uses Buildah to build a multi-architecture Coherence image. +# The architectures built are linux/amd64 and linux/arm64. +# The images are pushed to the local Docker daemon unless NO_DAEMON=true. +# --------------------------------------------------------------------------- +set -x + +BASEDIR=$(dirname "$0") + +# Ensure the ARTIFACT_DIR has been set - this is the root directory of the artifacts to copy to the image +if [ "${ARTIFACT_DIR}" == "" ] +then + echo "ERROR: No ARTIFACT_DIR environment variable has been set" + exit 1 +fi +# Ensure the IMAGE_NAME has been set - this is the name of the image to build +if [ "${IMAGE_NAME}" == "" ] +then + echo "ERROR: No IMAGE_NAME environment variable has been set" + exit 1 +fi +# Ensure the AMD_BASE_IMAGE has been set - this is the name of the base image for amd64 +if [ "${AMD_BASE_IMAGE}" == "" ] +then + echo "ERROR: No AMD_BASE_IMAGE environment variable has been set" + exit 1 +fi +# Ensure the ARM_BASE_IMAGE has been set - this is the name of the base image for arm64 +if [ "${ARM_BASE_IMAGE}" == "" ] +then + echo "ERROR: No ARM_BASE_IMAGE environment variable has been set" + exit 1 +fi + +# Ensure there is a default architecture - if not set we assume amd64 +if [ "${IMAGE_ARCH}" == "" ] +then + IMAGE_ARCH="amd64" +fi + +# we must use docker format to use health checks +export BUILDAH_FORMAT=docker + +# Build the entrypoint command line. +ENTRY_POINT="/coherence-operator/utils/runner" + +# The command line +CMD="server" + +# The health check command line +HEALTH_CMD="ready" + +# The image creation date +CREATED=$(date) + +# Common image builder function +# param 1: the image architecture, e.g. amd64 or arm64 +# param 2: the image o/s e.g. linux +# param 3: the base image +# param 4: the image name +common_image(){ + # Create the container from the base image, setting the architecture and O/S + buildah from --arch "${1}" --os "${2}" --name "container-${1}" ${3} + + # Add the configuration, entrypoint, etc... + buildah config --healthcheck-start-period 10s --healthcheck-interval 10s --healthcheck "CMD ${ENTRY_POINT} ${HEALTH_CMD}" container-${1} + + buildah config --arch "${1}" --os "${2}" \ + --entrypoint "[\"${ENTRY_POINT}\"]" --cmd "${CMD}" \ + --annotation "org.opencontainers.image.created=${CREATED}" \ + --annotation "org.opencontainers.image.url=${PROJECT_URL}" \ + --annotation "org.opencontainers.image.version=${VERSION}" \ + --annotation "org.opencontainers.image.source=http://github.com/oracle/coherence-operator" \ + --annotation "org.opencontainers.image.vendor=${PROJECT_VENDOR}" \ + --annotation "org.opencontainers.image.title=${PROJECT_DESCRIPTION} ${VERSION}" \ + --label "org.opencontainers.image.url=${PROJECT_URL}" \ + --label "org.opencontainers.image.version=${VERSION}" \ + --label "org.opencontainers.image.source=http://github.com/oracle/coherence-operator" \ + --label "org.opencontainers.image.vendor=${PROJECT_VENDOR}" \ + --label "org.opencontainers.image.title=Oracle Coherence ${VERSION}" \ + "container-${1}" + + # Copy files into the container + buildah copy "container-${1}" "${ARTIFACT_DIR}/target/docker/linux/${1}/runner" /coherence-operator/utils/runner + buildah copy "container-${1}" "${ARTIFACT_DIR}/target/docker/lib" /app/libs + + echo + buildah inspect container-${1} + echo + + # Commit the container to an image + buildah commit "container-${1}" "coherence-operator:${1}" + + # Export the image to the Docker daemon unless NO_DAEMON is true + if [ "${NO_DAEMON}" != "true" ] + then + buildah push -f v2s2 "coherence-operator:${1}" "docker-daemon:${4}" + echo "Pushed ${2}/${1} image ${4} to Docker daemon" + fi +} + +buildah version + +if [ "${DOCKER_HUB_USERNAME}" != "" ] && [ "${DOCKER_HUB_PASSWORD}" != "" ] +then + buildah login -u "${DOCKER_HUB_USERNAME}" -p "${DOCKER_HUB_PASSWORD}" "docker.io" +fi + +if [ "${DOCKER_REGISTRY}" != "" ] && [ "${DOCKER_USERNAME}" != "" ] && [ "${DOCKER_PASSWORD}" != "" ] +then + buildah login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY}" +fi + +# Build the amd64 image +common_image amd64 linux "${AMD_BASE_IMAGE}" "${IMAGE_NAME}-amd64" + +# Build the arm64 image +common_image arm64 linux "${ARM_BASE_IMAGE}" "${IMAGE_NAME}-arm64" + +# Push the relevant image to the docker daemon base on the build machine's o/s architecture +if [ "${NO_DAEMON}" != "true" ] +then + buildah push -f v2s2 "coherence-operator:${IMAGE_ARCH}" "docker-daemon:${IMAGE_NAME}" + echo "Pushed linux/${IMAGE_ARCH} image ${IMAGE_NAME} to Docker daemon" +fi + +# Clean-up +buildah rm container-amd64 +buildah rm container-arm64 + + diff --git a/java/coherence-operator/pom.xml b/java/coherence-operator/pom.xml index 4de81ddbd..3d785b688 100644 --- a/java/coherence-operator/pom.xml +++ b/java/coherence-operator/pom.xml @@ -2,7 +2,7 @@ @@ -231,5 +239,119 @@ + + + test-base-image + + + + + org.codehaus.mojo + exec-maven-plugin + ${version.plugin.maven.exec} + + + build-images + + exec + + package + + sh + + ${project.basedir}/run-buildah.sh + BUILD + + + ${project.version} + ${image.name} + ${image.arch} + ${base.image.name.amd} + ${base.image.name.arm} + ${env.DOCKER_REGISTRY} + ${env.DOCKER_USERNAME} + ${env.DOCKER_PASSWORD} + ${env.DOCKER_HUB_USERNAME} + ${env.DOCKER_HUB_PASSWORD} + ${project.url} + ${project.organization.name} + ${project.description} + + + + + + + + + + + push-test-base-image + + false + + + + + org.codehaus.mojo + exec-maven-plugin + + + push-image + + exec + + install + + sh + + ${project.basedir}/run-buildah.sh + PUSH + + + ${project.version} + ${image.name} + ${env.DOCKER_REGISTRY} + ${env.DOCKER_USERNAME} + ${env.DOCKER_PASSWORD} + + + + + + + + + + + + arch-amd64 + + + os.arch + x86_64 + + + + amd64 + + + + + + arch-arm64 + + + os.arch + aarch64 + + + + arm64 + + diff --git a/java/coherence-operator/push-images.sh b/java/coherence-operator/push-images.sh new file mode 100755 index 000000000..0cf280985 --- /dev/null +++ b/java/coherence-operator/push-images.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2022, Oracle and/or its affiliates. +# +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# +set -x + +buildah version + +if [ "${DOCKER_REGISTRY}" != "" ] && [ "${DOCKER_USERNAME}" != "" ] && [ "${DOCKER_PASSWORD}" != "" ] +then + buildah login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY}" +fi + +if [ "${NO_DAEMON}" != "true" ] +then + buildah pull "docker-daemon:${IMAGE_NAME}-amd64" + buildah pull "docker-daemon:${IMAGE_NAME}-arm64" +fi + +# If the registry is docker.io then cut the registry from the front of the image name +# e.g. docker.io/foo/bar:1.0 becomes foo/bar:1.0 +# This is because Buildah's local name of an image cuts docker.io from the name +REGISTRY=$(echo "${IMAGE_NAME}" | cut -d"/" -f1) +if [ "${REGISTRY}" == "docker.io" ] +then + IMAGE_SUFFIX=$(echo "${IMAGE_NAME}" | cut -d"/" -f2-10) +else + IMAGE_SUFFIX="${IMAGE_NAME}" +fi +LOCAL_NAME="localhost/${IMAGE_SUFFIX}" + +buildah images + +buildah manifest create "${IMAGE_NAME}" +buildah manifest add --arch amd64 --os linux "${IMAGE_NAME}" "${LOCAL_NAME}-amd64" +buildah manifest add --arch arm64 --os linux "${IMAGE_NAME}" "${LOCAL_NAME}-arm64" +buildah manifest inspect "${IMAGE_NAME}" + +buildah manifest push --all -f v2s2 "${IMAGE_NAME}" "docker://${IMAGE_NAME}" + + + diff --git a/java/coherence-operator/run-buildah.sh b/java/coherence-operator/run-buildah.sh new file mode 100755 index 000000000..2967314af --- /dev/null +++ b/java/coherence-operator/run-buildah.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2022, Oracle and/or its affiliates. +# +# Licensed under the Universal Permissive License v 1.0 as shown at +# http://oss.oracle.com/licenses/upl. +# + +# --------------------------------------------------------------------------- +# This script determines whether Buildah is available locally and if it is +# runs the image builder script otherwise it starts Buildah inside a +# container and exports the images to the local Docker daemon. +# --------------------------------------------------------------------------- +set -x + +BASEDIR=$(dirname "$0") + +# Ensure the ARTIFACT_DIR has been set - this is the root directory of the artifacts to copy to the image +if [ "${ARTIFACT_DIR}" == "" ] +then + echo "ERROR: No ARTIFACT_DIR environment variable has been set" + exit 1 +fi + +# Ensure the IMAGE_NAME has been set - this is the name of the image to build +if [ "${IMAGE_NAME}" == "" ] +then + echo "ERROR: No IMAGE_NAME environment variable has been set" + exit 1 +fi + +if [ "$1" == "PUSH" ] +then + SCRIPT_NAME="${BASEDIR}/push-images.sh" +else + SCRIPT_NAME="${BASEDIR}/build-images.sh" + # Ensure the AMD_BASE_IMAGE has been set - this is the name of the base image for amd64 + if [ "${AMD_BASE_IMAGE}" == "" ] + then + echo "ERROR: No AMD_BASE_IMAGE environment variable has been set" + exit 1 + fi + # Ensure the ARM_BASE_IMAGE has been set - this is the name of the base image for arm64 + if [ "${ARM_BASE_IMAGE}" == "" ] + then + echo "ERROR: No ARM_BASE_IMAGE environment variable has been set" + exit 1 + fi +fi + +chmod +x ${SCRIPT_NAME} + +which buildah +if [ "$?" == "0" ] +then + echo "Running Buildah locally" + if [ "${NO_DAEMON}" == "" ] + then + export NO_DAEMON=true + fi + sh "${SCRIPT_NAME}" +else + echo "Buildah not found locally - running in container" + if [ "${NO_DAEMON}" == "" ] + then + NO_DAEMON=false + fi + docker rm -f buildah || true + docker run --rm -v "${BASEDIR}:${BASEDIR}" \ + -v "${ARTIFACT_DIR}:${ARTIFACT_DIR}" \ + -v /var/run/docker.sock:/var/run/docker.sock \ + --privileged --network host \ + -e ARTIFACT_DIR="${ARTIFACT_DIR}" \ + -e IMAGE_NAME="${IMAGE_NAME}" \ + -e IMAGE_ARCH="${IMAGE_ARCH}" \ + -e AMD_BASE_IMAGE="${AMD_BASE_IMAGE}" \ + -e ARM_BASE_IMAGE="${ARM_BASE_IMAGE}" \ + -e NO_DAEMON="${NO_DAEMON}" \ + -e VERSION="${VERSION}" \ + -e DOCKER_REGISTRY="${DOCKER_REGISTRY}" \ + -e DOCKER_USERNAME="${DOCKER_USERNAME}" \ + -e DOCKER_PASSWORD="${DOCKER_PASSWORD}" \ + -e DOCKER_HUB_USERNAME="${DOCKER_HUB_USERNAME}" \ + -e DOCKER_HUB_PASSWORD="${DOCKER_HUB_PASSWORD}" \ + -e PROJECT_URL="${PROJECT_URL}" \ + -e PROJECT_VENDOR="${PROJECT_VENDOR}" \ + -e PROJECT_DESCRIPTION="${PROJECT_DESCRIPTION}" \ + -e HTTP_PROXY="${HTTP_PROXY}" -e HTTPS_PROXY="${HTTPS_PROXY}" -e NO_PROXY="${NO_PROXY}" \ + -e http_proxy="${http_proxy}" -e https_proxy="${https_proxy}" -e no_proxy="${no_proxy}" \ + --name buildah \ + quay.io/buildah/stable:v1.23.0 "${SCRIPT_NAME}" +fi + diff --git a/java/operator-test-with-utils/pom.xml b/java/operator-test-with-utils/pom.xml deleted file mode 100644 index 8630d581a..000000000 --- a/java/operator-test-with-utils/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - 4.0.0 - - - com.oracle.coherence.kubernetes - operator-parent - ${revision} - ../pom.xml - - - operator-test-with-utils - - Oracle Coherence Kubernetes Operator Test (with utils) - operator-test-with-utils - - - - com.oracle.coherence.kubernetes - coherence-operator - ${project.version} - - - com.oracle.coherence.kubernetes - operator-test - ${project.version} - - - - - - - com.google.cloud.tools - jib-maven-plugin - ${version.plugin.jib} - - - docker://${coherence.test.base.image} - - - OCI - com.tangosol.net.Coherence - - packaged - - - - - diff --git a/java/pom.xml b/java/pom.xml index 375bf2398..f88d75602 100644 --- a/java/pom.xml +++ b/java/pom.xml @@ -26,7 +26,6 @@ coherence-operator-client operator-compatibility operator-test - operator-test-with-utils operator-test-helidon operator-test-spring operator-test-client @@ -46,7 +45,7 @@ com.oracle.coherence.ce ${coherence.version} - gcr.io/distroless/java:11 + gcr.io/distroless/java11 oraclecoherence/coherence-ce:${coherence.version} ghcr.io/oracle/${project.artifactId}:${project.version} diff --git a/pkg/runner/cmd_http.go b/pkg/runner/cmd_http.go new file mode 100644 index 000000000..5a6f3d1dd --- /dev/null +++ b/pkg/runner/cmd_http.go @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +package runner + +import ( + "crypto/tls" + "crypto/x509" + "fmt" + "github.com/pkg/errors" + "github.com/spf13/cobra" + "io/ioutil" + "net/http" +) + +const ( + // ArgURL is the Operator URL status command argument. + ArgURL = "url" + // ArgTimeout is the timeout status command argument. + ArgTimeout = "timeout" + // ArgInterval is the retry interval status command argument. + ArgInterval = "interval" + // ArgSkipInsecure is the skip insecure https checks status command argument. + ArgSkipInsecure = "insecure-skip-tls-verify" + // ArgCertAuthority is the location of the CA file status command argument. + ArgCertAuthority = "certificate-authority" + // ArgCert is the location of the cert file status command argument. + ArgCert = "client-certificate" + // ArgKey is the location of the key file status command argument. + ArgKey = "client-key" +) + +func createHTTPClient(cmd *cobra.Command) (http.Client, error) { + client := http.Client{} + flagSet := cmd.Flags() + + i, err := flagSet.GetBool(ArgSkipInsecure) + if err != nil { + return client, err + } + clientCertFile, err := flagSet.GetString(ArgCert) + if err != nil { + return client, err + } + clientKeyFile, err := flagSet.GetString(ArgKey) + if err != nil { + return client, err + } + caCertFile, err := flagSet.GetString(ArgCertAuthority) + if err != nil { + return client, err + } + + var certs []tls.Certificate + var caCertPool *x509.CertPool + + if clientCertFile != "" && clientKeyFile != "" { + cert, err := tls.LoadX509KeyPair(clientCertFile, clientKeyFile) + if err != nil { + return client, errors.Wrapf(err, "creating x509 keypair from client cert file '%s' and client key file '%s'", clientCertFile, clientKeyFile) + } + certs = []tls.Certificate{cert} + } + + if caCertFile != "" { + caCert, err := ioutil.ReadFile(caCertFile) + if err != nil { + return client, errors.Wrapf(err, "opening cert file %s", caCertFile) + } + caCertPool := x509.NewCertPool() + caCertPool.AppendCertsFromPEM(caCert) + } + + tr := &http.Transport{ + TLSClientConfig: &tls.Config{ + Certificates: certs, + RootCAs: caCertPool, + }, + } + + tr.TLSClientConfig.InsecureSkipVerify = i + client.Transport = tr + + return client, nil +} + +// executeQuery performs a http on a URL +func executeQuery(cmd *cobra.Command) error { + var err error + + flagSet := cmd.Flags() + url, err := flagSet.GetString(ArgURL) + if err != nil { + return err + } + + client, err := createHTTPClient(cmd) + if err != nil { + return err + } + + _, status, err := httpGet(url, client) + if err == nil && status == http.StatusOK { + return nil + } + + return fmt.Errorf("failed to receive a 200 response from %s", url) +} diff --git a/pkg/runner/cmd_ready.go b/pkg/runner/cmd_ready.go new file mode 100644 index 000000000..d625cbd34 --- /dev/null +++ b/pkg/runner/cmd_ready.go @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. + * Licensed under the Universal Permissive License v 1.0 as shown at + * http://oss.oracle.com/licenses/upl. + */ + +package runner + +import ( + "fmt" + v1 "github.com/oracle/coherence-operator/api/v1" + "github.com/spf13/cobra" + "os" + "strconv" +) + +const ( + // CommandReady is the argument to execute ready check. + CommandReady = "ready" +) + +// statusCommand creates the Corba "status" sub-command +func readyCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: CommandReady, + Short: "Run a Coherence ready check", + Long: "Run a Coherence ready check", + RunE: func(cmd *cobra.Command, args []string) error { + return executeQuery(cmd) + }, + } + + port := strconv.Itoa(int(v1.DefaultHealthPort)) + if p, found := os.LookupEnv(v1.EnvVarCohHealthPort); found { + port = p + } + + url := fmt.Sprintf("http://localhost:%s/ready", port) + + flagSet := cmd.Flags() + flagSet.String(ArgURL, url, "The URL of the Coherence ready endpoint") + flagSet.Bool(ArgSkipInsecure, false, "If true, the server's certificate will not be checked for validity") + flagSet.String(ArgCertAuthority, "", "Path to a cert file for the certificate authority") + flagSet.String(ArgCert, "", "Path to a client certificate file for TLS") + flagSet.String(ArgKey, "", "Path to a client key file for TLS") + + return cmd +} diff --git a/pkg/runner/cmd_status_query.go b/pkg/runner/cmd_status_query.go index 6cee150d8..e68cd3cc6 100644 --- a/pkg/runner/cmd_status_query.go +++ b/pkg/runner/cmd_status_query.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. + * Copyright (c) 2021, 2022, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -7,13 +7,9 @@ package runner import ( - "crypto/tls" - "crypto/x509" "fmt" v1 "github.com/oracle/coherence-operator/api/v1" - "github.com/pkg/errors" "github.com/spf13/cobra" - "io/ioutil" "net/http" "strconv" "time" @@ -31,18 +27,6 @@ const ( ArgName = "name" // ArgCondition is the required condition status command argument. ArgCondition = "condition" - // ArgTimeout is the timeout status command argument. - ArgTimeout = "timeout" - // ArgInterval is the retry interval status command argument. - ArgInterval = "interval" - // ArgSkipInsecure is the skip insecure https checks status command argument. - ArgSkipInsecure = "insecure-skip-tls-verify" - // ArgCertAuthority is the location of the CA file status command argument. - ArgCertAuthority = "certificate-authority" - // ArgCert is the location of the cert file status command argument. - ArgCert = "client-certificate" - // ArgKey is the location of the key file status command argument. - ArgKey = "client-key" ) // statusCommand creates the Corba "status" sub-command @@ -100,53 +84,12 @@ func statusQuery(cmd *cobra.Command) error { if err != nil { return err } - i, err := flagSet.GetBool(ArgSkipInsecure) - if err != nil { - return err - } - clientCertFile, err := flagSet.GetString(ArgCert) - if err != nil { - return err - } - clientKeyFile, err := flagSet.GetString(ArgKey) - if err != nil { - return err - } - caCertFile, err := flagSet.GetString(ArgCertAuthority) + + client, err := createHTTPClient(cmd) if err != nil { return err } - var certs []tls.Certificate - var caCertPool *x509.CertPool - - if clientCertFile != "" && clientKeyFile != "" { - cert, err := tls.LoadX509KeyPair(clientCertFile, clientKeyFile) - if err != nil { - return errors.Wrapf(err, "creating x509 keypair from client cert file '%s' and client key file '%s'", clientCertFile, clientKeyFile) - } - certs = []tls.Certificate{cert} - } - - if caCertFile != "" { - caCert, err := ioutil.ReadFile(caCertFile) - if err != nil { - return errors.Wrapf(err, "opening cert file %s", caCertFile) - } - caCertPool := x509.NewCertPool() - caCertPool.AppendCertsFromPEM(caCert) - } - - tr := &http.Transport{ - TLSClientConfig: &tls.Config{ - Certificates: certs, - RootCAs: caCertPool, - }, - } - - tr.TLSClientConfig.InsecureSkipVerify = i - - client := http.Client{Transport: tr} request := fmt.Sprintf("%s/status/%s/%s?phase=%s", url, ns, n, condition) maxTime := time.Now().Add(timeout) diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 88002ba3d..51f54a41b 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. + * Copyright (c) 2020, 2022, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -119,6 +119,7 @@ func NewRootCommand(env map[string]string) (*cobra.Command, *viper.Viper) { rootCmd.AddCommand(queryPlusCommand()) rootCmd.AddCommand(mbeanServerCommand()) rootCmd.AddCommand(statusCommand()) + rootCmd.AddCommand(readyCommand()) return rootCmd, v }