From 25ccdbe44534868bfd6ec1fe0a111e638de8e4c6 Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Tue, 8 Oct 2024 13:44:33 +0200 Subject: [PATCH 1/2] feat: add leader election configuration, disable max reconcilation interval --- ...onecx-data-orchestrator-operator-docs.adoc | 11 ++- ...data-orchestrator-operator-extensions.adoc | 38 ++++---- .../onecx-data-orchestrator-operator.adoc | 90 +++++++++++-------- .../orchestrator/operator/DataConfig.java | 19 ++++ .../orchestrator/operator/DataController.java | 2 +- .../operator/LeaderConfiguration.java | 13 +++ 6 files changed, 114 insertions(+), 59 deletions(-) create mode 100644 src/main/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfiguration.java diff --git a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc index b189960..ae39a21 100644 --- a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc +++ b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc @@ -49,16 +49,21 @@ app: fieldPath: metadata.namespace serviceAccount: enabled: true - operator: keycloak: client: enabled: true spec: kcConfig: - defaultClientScopes: [ ocx-ws:write, ocx-pm-assignment:write, ocx-tn:write, ocx-th:write ] + defaultClientScopes: [ ocx-ws:write, ocx-pm:write, ocx-pm-assignment:write, ocx-tn:write, ocx-th:write, ocx-hp:write ] + +---- + +x-th:write, ocx-hp:write ] + +---- -# Values: JOSDK_WATCH_CURRENT, JOSDK_ALL_NAMESPACES or comma separated list of namespaces +ted list of namespaces watchNamespaces: "JOSDK_WATCH_CURRENT" ---- diff --git a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc index 24c1e33..aa20dc1 100644 --- a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc +++ b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc @@ -11,38 +11,38 @@ h| Version | tkit-quarkus-log-cdi | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link] +| 2.33.0 | tkit-quarkus-log-rs | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link] +| 2.33.0 | tkit-quarkus-log-json | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link] +| 2.33.0 | quarkus-arc | https://quarkus.io/guides/cdi-reference[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-arc.adoc[Link] -| 3.13.2 +| 3.15.1 | quarkus-micrometer-registry-prometheus | https://quarkus.io/guides/telemetry-micrometer[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-micrometer-registry-prometheus.adoc[Link] -| 3.13.2 +| 3.15.1 | quarkus-opentelemetry | https://quarkus.io/guides/opentelemetry[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-opentelemetry.adoc[Link] -| 3.13.2 +| 3.15.1 | quarkus-openapi-generator @@ -54,43 +54,43 @@ h| Version | https://quarkus.io/guides/rest-client[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-rest-client.adoc[Link] -| 3.13.2 +| 3.15.1 | quarkus-rest-client-jackson | https://quarkus.io/guides/rest-client[Link] | -| 3.13.2 +| 3.15.1 | quarkus-oidc | https://quarkus.io/guides/security-oidc-bearer-token-authentication-tutorial[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-oidc.adoc[Link] -| 3.13.2 +| 3.15.1 | tkit-quarkus-security | https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-security.html[Link] -| https://github.com/1000kit/tkit-quarkus/blob/2.31.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] -| 2.31.0 +| https://github.com/1000kit/tkit-quarkus/blob/2.33.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-security.adoc[Link] +| 2.33.0 | onecx-core | https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link] | -| 0.26.0 +| 0.31.0 | quarkus-smallrye-health | https://quarkus.io/guides/smallrye-health[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-smallrye-health.adoc[Link] -| 3.13.2 +| 3.15.1 | quarkus-container-image-docker | https://quarkus.io/guides/container-image[Link] | https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link] -| 3.13.2 +| 3.15.1 | quarkus-operator-sdk-bundle-generator @@ -109,13 +109,13 @@ h| Version | | -| 3.13.2 +| 3.15.1 | quarkus-rest-client-oidc-filter | | -| 3.13.2 +| 3.15.1 |=== \ No newline at end of file diff --git a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc index 9ef14dd..f83224b 100644 --- a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc +++ b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc @@ -1,149 +1,167 @@ - :summaryTableId: onecx-data-orchestrator-operator [.configuration-legend] icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime [.configuration-reference.searchable, cols="80,.^10,.^10"] |=== -h|[[onecx-data-orchestrator-operator_configuration]]link:#onecx-data-orchestrator-operator_configuration[Configuration property] - +h|[.header-title]##Configuration property## h|Type h|Default -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-digest]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-digest[onecx.data-orchestrator.digest]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-digest]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-digest[`onecx.data-orchestrator.digest`]## [.description] -- Digest algorithms. + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_DIGEST+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_DIGEST+++` endif::add-copy-button-to-env-var[] ---|string +-- +|string |`MD5` - -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-user-name]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-user-name[onecx.data-orchestrator.token.user-name]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-user-name]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-user-name[`onecx.data-orchestrator.token.user-name`]## [.description] -- Username for rest call. + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_TOKEN_USER_NAME+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_TOKEN_USER_NAME+++` endif::add-copy-button-to-env-var[] ---|string +-- +|string |`data-orchestrator-operator` - -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-header-param]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-header-param[onecx.data-orchestrator.token.header-param]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-header-param]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-header-param[`onecx.data-orchestrator.token.header-param`]## [.description] -- Token header parameter. + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_TOKEN_HEADER_PARAM+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_TOKEN_HEADER_PARAM+++` endif::add-copy-button-to-env-var[] ---|string +-- +|string |`apm-principal-token` - -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param[onecx.data-orchestrator.token.claim-organization-param]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param[`onecx.data-orchestrator.token.claim-organization-param`]## [.description] -- Token claim organization parameter. + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_TOKEN_CLAIM_ORGANIZATION_PARAM+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_TOKEN_CLAIM_ORGANIZATION_PARAM+++` endif::add-copy-button-to-env-var[] ---|string +-- +|string |`orgId` - -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param-array]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param-array[onecx.data-orchestrator.token.claim-organization-param-array]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param-array]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param-array[`onecx.data-orchestrator.token.claim-organization-param-array`]## [.description] -- Token claim organization parameter array. + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_TOKEN_CLAIM_ORGANIZATION_PARAM_ARRAY+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_TOKEN_CLAIM_ORGANIZATION_PARAM_ARRAY+++` endif::add-copy-button-to-env-var[] ---|boolean +-- +|boolean |`false` - -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-client-shared]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-client-shared[onecx.data-orchestrator.client.shared]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-client-shared]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-client-shared[`onecx.data-orchestrator.client.shared`]## [.description] -- Set to true to share the HTTP client between REST clients. + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_CLIENT_SHARED+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_CLIENT_SHARED+++` endif::add-copy-button-to-env-var[] ---|boolean +-- +|boolean |`true` - -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-client-connection-pool-size]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-client-connection-pool-size[onecx.data-orchestrator.client.connection-pool-size]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-client-connection-pool-size]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-client-connection-pool-size[`onecx.data-orchestrator.client.connection-pool-size`]## [.description] -- The size of the rest client connection pool. + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_CLIENT_CONNECTION_POOL_SIZE+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_CLIENT_CONNECTION_POOL_SIZE+++` endif::add-copy-button-to-env-var[] ---|int +-- +|int |`30` - -a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-client-key-keys]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-client-key-keys[onecx.data-orchestrator.client.key."keys"]` - +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-client-key-keys]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-client-key-keys[`onecx.data-orchestrator.client.key."keys"`]## [.description] -- Clients key configuration + ifdef::add-copy-button-to-env-var[] Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_CLIENT_KEY__KEYS_+++[] endif::add-copy-button-to-env-var[] ifndef::add-copy-button-to-env-var[] Environment variable: `+++ONECX_DATA_ORCHESTRATOR_CLIENT_KEY__KEYS_+++` endif::add-copy-button-to-env-var[] ---|link:https://docs.oracle.com/javase/8/docs/api/java/lang/String.html[String] - +-- +|Map | -|=== \ No newline at end of file +a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-leader-election-lease-name]] [.property-path]##link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-leader-election-lease-name[`onecx.data-orchestrator.leader-election.lease-name`]## + +[.description] +-- +Lease name + + +ifdef::add-copy-button-to-env-var[] +Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_LEADER_ELECTION_LEASE_NAME+++[] +endif::add-copy-button-to-env-var[] +ifndef::add-copy-button-to-env-var[] +Environment variable: `+++ONECX_DATA_ORCHESTRATOR_LEADER_ELECTION_LEASE_NAME+++` +endif::add-copy-button-to-env-var[] +-- +|string +|`onecx-data-orchestrator-operator-lease` + +|=== + + +:!summaryTableId: \ No newline at end of file diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java index 202033b..013ef45 100644 --- a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java +++ b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java @@ -32,6 +32,12 @@ public interface DataConfig { @WithDefault("client") ConfigClient client(); + /** + * Leader election configuration + */ + @WithName("leader-election") + LeaderElectionConfig leaderElectionConfig(); + /** * Client configuration. */ @@ -92,4 +98,17 @@ interface TokenConfig { boolean claimOrganizationParamArray(); } + + /** + * Leader election config + */ + interface LeaderElectionConfig { + + /** + * Lease name + */ + @WithName("lease-name") + @WithDefault("onecx-data-orchestrator-operator-lease") + String leaseName(); + } } diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataController.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataController.java index fc31a0f..9e5be75 100644 --- a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataController.java +++ b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataController.java @@ -20,7 +20,7 @@ import io.javaoperatorsdk.operator.processing.event.source.filter.OnUpdateFilter; import io.smallrye.config.SmallRyeConfig; -@ControllerConfiguration(name = "data", namespaces = WATCH_CURRENT_NAMESPACE, onAddFilter = DataController.SlotAddFilter.class, onUpdateFilter = DataController.SlotUpdateFilter.class) +@ControllerConfiguration(name = "data", maxReconciliationInterval = @MaxReconciliationInterval(interval = Constants.NO_MAX_RECONCILIATION_INTERVAL), namespaces = WATCH_CURRENT_NAMESPACE, onAddFilter = DataController.SlotAddFilter.class, onUpdateFilter = DataController.SlotUpdateFilter.class) public class DataController implements Reconciler, ErrorStatusHandler { private static final Logger log = LoggerFactory.getLogger(DataController.class); diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfiguration.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfiguration.java new file mode 100644 index 0000000..d7de345 --- /dev/null +++ b/src/main/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfiguration.java @@ -0,0 +1,13 @@ +package org.tkit.onecx.data.orchestrator.operator; + +import jakarta.inject.Singleton; + +import io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration; + +@Singleton +public class LeaderConfiguration extends LeaderElectionConfiguration { + + public LeaderConfiguration(DataConfig config) { + super(config.leaderElectionConfig().leaseName()); + } +} From daa01857c9bc7b81d7ee6a82c4fe1b1ac7447a65 Mon Sep 17 00:00:00 2001 From: Andrej Petras Date: Tue, 8 Oct 2024 14:39:37 +0200 Subject: [PATCH 2/2] feat: add leader election configuration, disable max reconcilation interval --- src/main/resources/application.properties | 4 +-- .../operator/LeaderConfigurationTest.java | 27 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/test/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfigurationTest.java diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 87aa09a..0c2edcd 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -18,8 +18,8 @@ quarkus.kubernetes-client.devservices.override-kubeconfig=true %test.quarkus.mockserver.devservices.config-class-path=true %test.quarkus.mockserver.devservices.config-file=/mockserver.properties %test.quarkus.mockserver.devservices.config-dir=/mockserver -%test.quarkus.mockserver.devservices.log=true -%test.quarkus.mockserver.devservices.reuse=true +%test.quarkus.mockserver.devservices.log=false +%test.quarkus.mockserver.devservices.reuse=false %test.onecx.data-orchestrator.client.key.workspace=${quarkus.mockserver.endpoint}/workspace %test.onecx.data-orchestrator.client.key.theme=${quarkus.mockserver.endpoint}/theme diff --git a/src/test/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfigurationTest.java b/src/test/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfigurationTest.java new file mode 100644 index 0000000..556bebe --- /dev/null +++ b/src/test/java/org/tkit/onecx/data/orchestrator/operator/LeaderConfigurationTest.java @@ -0,0 +1,27 @@ +package org.tkit.onecx.data.orchestrator.operator; + +import static org.assertj.core.api.Assertions.assertThat; + +import jakarta.inject.Inject; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +class LeaderConfigurationTest extends AbstractTest { + + @Inject + DataConfig dataConfig; + + @Inject + LeaderConfiguration leaderConfiguration; + + @Test + void testLeaderConfiguration() { + assertThat(dataConfig).isNotNull(); + assertThat(dataConfig.leaderElectionConfig()).isNotNull(); + assertThat(leaderConfiguration).isNotNull(); + assertThat(leaderConfiguration.getLeaseName()).isNotNull().isEqualTo(dataConfig.leaderElectionConfig().leaseName()); + } +}