From 33e63600a82b42522cdcf3a9abb8a329b5337488 Mon Sep 17 00:00:00 2001 From: bmg13 Date: Tue, 13 Aug 2024 12:05:59 +0100 Subject: [PATCH] Feat: Backport Add Persistence for dataplaneselector. --- .../templates/deployment-controlplane.yaml | 10 ++++++ .../templates/deployment-controlplane.yaml | 10 ++++++ ...eInstancePostgresqlMigrationExtension.java | 28 +++++++++++++++ ...rg.eclipse.edc.spi.system.ServiceExtension | 1 + .../V0_0_1__Init_Dataplaneinstance.sql | 34 +++++++++++++++++++ .../tests/runtimes/PgRuntimeExtension.java | 2 +- .../cloud-transfer-tests/build.gradle.kts | 2 +- gradle/libs.versions.toml | 3 +- 8 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 edc-extensions/migrations/control-plane-migration/src/main/java/org/eclipse/tractusx/edc/postgresql/migration/DataPlaneInstancePostgresqlMigrationExtension.java create mode 100644 edc-extensions/migrations/control-plane-migration/src/main/resources/org/eclipse/tractusx/edc/postgresql/migration/dataplaneinstance/V0_0_1__Init_Dataplaneinstance.sql diff --git a/charts/tractusx-connector-azure-vault/templates/deployment-controlplane.yaml b/charts/tractusx-connector-azure-vault/templates/deployment-controlplane.yaml index 17d3dbdec..db59e2991 100644 --- a/charts/tractusx-connector-azure-vault/templates/deployment-controlplane.yaml +++ b/charts/tractusx-connector-azure-vault/templates/deployment-controlplane.yaml @@ -268,6 +268,16 @@ spec: - name: "EDC_DATASOURCE_EDR_URL" value: {{ tpl .Values.postgresql.jdbcUrl . | quote }} + # see extension https://github.com/eclipse-edc/Connector/tree/main/extensions/data-plane-selector/store/sql/data-plane-instance-store-sql + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_NAME" + value: "dataplaneinstance" + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_USER" + value: { { .Values.postgresql.auth.username | required ".Values.postgresql.auth.username is required" | quote } } + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_PASSWORD" + value: { { .Values.postgresql.auth.password | required ".Values.postgresql.auth.password is required" | quote } } + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_URL" + value: { { tpl .Values.postgresql.jdbcUrl . | quote } } + ############################# ## IATP / STS / DIM CONFIG ## ############################# diff --git a/charts/tractusx-connector/templates/deployment-controlplane.yaml b/charts/tractusx-connector/templates/deployment-controlplane.yaml index 9cf9e6c4b..55ff452c9 100644 --- a/charts/tractusx-connector/templates/deployment-controlplane.yaml +++ b/charts/tractusx-connector/templates/deployment-controlplane.yaml @@ -269,6 +269,16 @@ spec: - name: "EDC_DATASOURCE_EDR_URL" value: {{ tpl .Values.postgresql.jdbcUrl . | quote }} + # see extension https://github.com/eclipse-edc/Connector/tree/main/extensions/data-plane-selector/store/sql/data-plane-instance-store-sql + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_NAME" + value: "dataplaneinstance" + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_USER" + value: { { .Values.postgresql.auth.username | required ".Values.postgresql.auth.username is required" | quote } } + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_PASSWORD" + value: { { .Values.postgresql.auth.password | required ".Values.postgresql.auth.password is required" | quote } } + - name: "EDC_DATASOURCE_DATAPLANEINSTANCE_URL" + value: { { tpl .Values.postgresql.jdbcUrl . | quote } } + ############################# ## IATP / STS / DIM CONFIG ## ############################# diff --git a/edc-extensions/migrations/control-plane-migration/src/main/java/org/eclipse/tractusx/edc/postgresql/migration/DataPlaneInstancePostgresqlMigrationExtension.java b/edc-extensions/migrations/control-plane-migration/src/main/java/org/eclipse/tractusx/edc/postgresql/migration/DataPlaneInstancePostgresqlMigrationExtension.java new file mode 100644 index 000000000..a0be305a7 --- /dev/null +++ b/edc-extensions/migrations/control-plane-migration/src/main/java/org/eclipse/tractusx/edc/postgresql/migration/DataPlaneInstancePostgresqlMigrationExtension.java @@ -0,0 +1,28 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +package org.eclipse.tractusx.edc.postgresql.migration; + +public class DataPlaneInstancePostgresqlMigrationExtension extends AbstractPostgresqlMigrationExtension { + private static final String NAME_SUBSYSTEM = "dataplaneinstance"; + + protected String getSubsystemName() { + return NAME_SUBSYSTEM; + } +} diff --git a/edc-extensions/migrations/control-plane-migration/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension b/edc-extensions/migrations/control-plane-migration/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension index 20a17d939..d43ec4565 100644 --- a/edc-extensions/migrations/control-plane-migration/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension +++ b/edc-extensions/migrations/control-plane-migration/src/main/resources/META-INF/services/org.eclipse.edc.spi.system.ServiceExtension @@ -24,6 +24,7 @@ org.eclipse.tractusx.edc.postgresql.migration.ContractDefinitionPostgresqlMigrat org.eclipse.tractusx.edc.postgresql.migration.ContractNegotiationPostgresqlMigrationExtension org.eclipse.tractusx.edc.postgresql.migration.PolicyPostgresqlMigrationExtension org.eclipse.tractusx.edc.postgresql.migration.PolicyMonitorPostgresqlMigrationExtension +org.eclipse.tractusx.edc.postgresql.migration.DataPlaneInstancePostgresqlMigrationExtension org.eclipse.tractusx.edc.postgresql.migration.TransferProcessPostgresqlMigrationExtension org.eclipse.tractusx.edc.postgresql.migration.BusinessGroupPostgresMigrationExtension org.eclipse.tractusx.edc.postgresql.migration.EdrIndexPostgresqlMigrationExtension \ No newline at end of file diff --git a/edc-extensions/migrations/control-plane-migration/src/main/resources/org/eclipse/tractusx/edc/postgresql/migration/dataplaneinstance/V0_0_1__Init_Dataplaneinstance.sql b/edc-extensions/migrations/control-plane-migration/src/main/resources/org/eclipse/tractusx/edc/postgresql/migration/dataplaneinstance/V0_0_1__Init_Dataplaneinstance.sql new file mode 100644 index 000000000..bd4680944 --- /dev/null +++ b/edc-extensions/migrations/control-plane-migration/src/main/resources/org/eclipse/tractusx/edc/postgresql/migration/dataplaneinstance/V0_0_1__Init_Dataplaneinstance.sql @@ -0,0 +1,34 @@ +-- +-- Copyright (c) 2024 Contributors to the Eclipse Foundation +-- +-- This program and the accompanying materials are made available under the +-- terms of the Apache License, Version 2.0 which is available at +-- https://www.apache.org/licenses/LICENSE-2.0 +-- +-- SPDX-License-Identifier: Apache-2.0 +-- +-- Contributors: +-- Contributors to the Eclipse Foundation - initial API and implementation +-- + + +CREATE TABLE IF NOT EXISTS edc_lease +( + leased_by VARCHAR NOT NULL, + leased_at BIGINT, + lease_duration INTEGER NOT NULL, + lease_id VARCHAR NOT NULL + CONSTRAINT lease_pk + PRIMARY KEY +); + + +CREATE TABLE IF NOT EXISTS edc_data_plane_instance +( + id VARCHAR NOT NULL PRIMARY KEY, + data JSON, + lease_id VARCHAR + CONSTRAINT data_plane_instance_lease_id_fk + REFERENCES edc_lease + ON DELETE SET NULL +); \ No newline at end of file diff --git a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java index 6472aebee..cf46b2012 100644 --- a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java +++ b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java @@ -40,7 +40,7 @@ public class PgRuntimeExtension extends ParticipantRuntimeExtension { private static final String PASSWORD = "password"; private static final List DATASOURCES = List.of("asset", "contractdefinition", "contractnegotiation", "policy", "transferprocess", "bpn", - "policy-monitor", "edr", "dataplane", "accesstokendata"); + "policy-monitor", "edr", "dataplane", "accesstokendata", "dataplaneinstance"); private final PostgreSQLContainer postgreSqlContainer; private final String dbName; diff --git a/edc-tests/edc-dataplane/cloud-transfer-tests/build.gradle.kts b/edc-tests/edc-dataplane/cloud-transfer-tests/build.gradle.kts index 8a5a15e06..f56056ae2 100644 --- a/edc-tests/edc-dataplane/cloud-transfer-tests/build.gradle.kts +++ b/edc-tests/edc-dataplane/cloud-transfer-tests/build.gradle.kts @@ -32,7 +32,7 @@ dependencies { testImplementation(libs.edc.config.filesystem) testImplementation(libs.edc.dpf.http) testImplementation(libs.edc.auth.tokenbased) - testImplementation(libs.edc.dpf.selector.spi) + testImplementation(libs.edc.spi.dataplane.selector) testImplementation(libs.testcontainers.junit) testImplementation(libs.edc.aws.s3.core) testImplementation(libs.aws.s3) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 07a863383..f0b963715 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -117,6 +117,7 @@ edc-sql-policy-monitor = { module = "org.eclipse.edc:policy-monitor-store-sql", edc-sql-edrindex = { module = "org.eclipse.edc:edr-index-sql", version.ref = "edc" } edc-sql-accesstokendata = { module = "org.eclipse.edc:accesstokendata-store-sql", version.ref = "edc" } edc-sql-dataplane = { module = "org.eclipse.edc:data-plane-store-sql", version.ref = "edc" } +edc-data-plane-instance-store-sql = { module = "org.eclipse.edc:data-plane-instance-store-sql", version.ref = "edc" } # azure stuff edc-azure-vault = { module = "org.eclipse.edc.azure:vault-azure", version.ref = "edc" } @@ -225,6 +226,6 @@ titaniumJsonLd = { module = "com.apicatalog:titanium-json-ld", version.ref = "ti [bundles] edc-connector = ["edc.boot", "edc.core-connector", "edc.core-controlplane", "edc.api-observability"] edc-dpf = ["edc.dpf-transfer-signaling", "edc.dpf-selector-core", "edc.spi-dataplane-selector"] -edc-sqlstores = ["edc.sql-assetindex", "edc.sql-contract-definition", "edc.sql-contract-negotiation", "edc.sql-transferprocess", "edc.sql-policydef", "edc.sql-policy-monitor", "edc.sql-edrindex"] +edc-sqlstores = ["edc.sql-assetindex", "edc.sql-contract-definition", "edc.sql-contract-negotiation", "edc.sql-transferprocess", "edc.sql-policydef", "edc.sql-policy-monitor", "edc.sql-edrindex", "edc.data-plane-instance-store-sql"] edc-monitoring = ["edc.micrometer-core", "edc.micrometer-jersey", "edc.micrometer-jetty"] edc-sts = ["edc-identity-trust-sts-core", "edc-identity-trust-sts-api", "edc-identity-trust-sts-client-configuration"]