Skip to content

Commit 5962e15

Browse files
authored
Participant id migration (#2543)
* Add migration to set participant context id Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Add new identifier requirement to helm charts Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Update helmdocs Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Fix issues in checkstyle and testing Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Add participant context id to e2e test participants Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Add participant context id to deployment test helm value file Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Fix participant context id for dsp tck test Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Add participant context id to dataplane as well Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> * Add newer TCK support methods for DSP TCK testing Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com> --------- Signed-off-by: Lars Geyer-Blaumeiser <lars.blaumeiser@cofinity-x.com>
1 parent 95c69f8 commit 5962e15

File tree

17 files changed

+61
-3
lines changed

17 files changed

+61
-3
lines changed

charts/tractusx-connector-memory/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ helm install my-release tractusx-edc/tractusx-connector-memory --version 0.12.0-
7171
| log4j2.config | string | `"Appenders:\n Console:\n name: CONSOLE\n JsonTemplateLayout:\n eventTemplate: |-\n {\n \"timestamp\": {\n \"$resolver\": \"timestamp\",\n \"pattern\": {\n \"format\": \"yyyy-MM-dd'T'HH:mm:ss.SSSSSSS\",\n \"timeZone\": \"UTC\"\n }\n },\n \"level\": {\n \"$resolver\": \"level\",\n \"field\": \"severity\",\n \"severity\": {\n \"field\": \"keyword\"\n }\n },\n \"message\": {\n \"$resolver\": \"message\"\n }\n }\nLoggers:\n Root:\n level: \"OFF\"\n Logger:\n name: org.eclipse.edc.monitor.logger\n level: DEBUG\n AppenderRef:\n ref: CONSOLE"` | Log4j2 configuration for json log formatting. |
7272
| log4j2.enableJsonLogs | bool | `true` | Whether to enable the json log config in log4j2.config |
7373
| nameOverride | string | `""` | |
74+
| participant.contextId | string | `"UUID CHANGEME"` | Participant Context Id - Newly introduced id for a connector instance (needed for multitenancy) |
7475
| participant.id | string | `"BPNLCHANGEME"` | BPN Number |
7576
| runtime.affinity | object | `{}` | [affinity](https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity) to configure which nodes the pods can be scheduled on |
7677
| runtime.autoscaling.enabled | bool | `false` | Enables [horizontal pod autoscaling](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/) |

charts/tractusx-connector-memory/templates/deployment-runtime.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ spec:
149149
value: {{ .Values.iatp.id | required ".Values.iatp.id is required" | quote }}
150150
- name: "EDC_IAM_ISSUER_ID"
151151
value: {{ .Values.iatp.id | required ".Values.iatp.id is required" | quote }}
152+
- name: "EDC_PARTICIPANT_CONTEXT_ID"
153+
value: {{ .Values.participant.contextId | required ".Values.participant.contextId is required" | quote }}
152154
- name: "TRACTUSX_EDC_PARTICIPANT_BPN"
153155
value: {{ .Values.participant.id | required ".Values.participant.id is required" | quote }}
154156

charts/tractusx-connector-memory/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ customLabels: {}
3535
participant:
3636
# -- BPN Number
3737
id: "BPNLCHANGEME"
38+
# -- Participant Context Id - Newly introduced id for a connector instance (needed for multitenancy)
39+
contextId: "UUID CHANGEME"
3840

3941
iatp:
4042
# -- Decentralized IDentifier (DID) of the connector

charts/tractusx-connector/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ helm install my-release tractusx-edc/tractusx-connector --version 0.12.0-SNAPSHO
288288
| networkPolicy.dataplane | object | `{"from":[{"namespaceSelector":{}}]}` | Configuration of the dataplane component |
289289
| networkPolicy.dataplane.from | list | `[{"namespaceSelector":{}}]` | Specify from rule network policy for dp (defaults to all namespaces) |
290290
| networkPolicy.enabled | bool | `false` | If `true` network policy will be created to restrict access to control- and dataplane |
291+
| participant.contextId | string | `"UUID CHANGEME"` | Participant Context Id - Newly introduced id for a connector instance (needed for multitenancy) |
291292
| participant.id | string | `"BPNLCHANGEME"` | BPN Number |
292293
| postgresql.auth.database | string | `"edc"` | |
293294
| postgresql.auth.password | string | `"password"` | |

charts/tractusx-connector/templates/deployment-controlplane.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ spec:
150150
value: {{ .Values.iatp.id | required ".Values.iatp.id is required" | quote }}
151151
- name: "EDC_IAM_ISSUER_ID"
152152
value: {{ .Values.iatp.id | required ".Values.iatp.id is required" | quote }}
153+
- name: "EDC_PARTICIPANT_CONTEXT_ID"
154+
value: {{ .Values.participant.contextId | required ".Values.participant.contextId is required" | quote }}
153155
- name: "TRACTUSX_EDC_PARTICIPANT_BPN"
154156
value: {{ .Values.participant.id | required ".Values.participant.id is required" | quote }}
155157

charts/tractusx-connector/templates/deployment-dataplane.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ spec:
146146
########################
147147
- name: EDC_PARTICIPANT_ID
148148
value: {{ .Values.participant.id | required ".Values.participant.id is required" | quote }}
149+
- name: EDC_PARTICIPANT_CONTEXT_ID
150+
value: {{ .Values.participant.contextId | required ".Values.participant.contextId is required" | quote}}
149151
- name: "EDC_IAM_ISSUER_ID"
150152
value: {{ .Values.iatp.id | required ".Values.iatp.id is required" | quote}}
151153

charts/tractusx-connector/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ customLabels: {}
4242
participant:
4343
# -- BPN Number
4444
id: "BPNLCHANGEME"
45+
# -- Participant Context Id - Newly introduced id for a connector instance (needed for multitenancy)
46+
contextId: "UUID CHANGEME"
4547

4648
iatp:
4749
# -- Decentralized IDentifier (DID) of the connector

edc-extensions/migrations/connector-migration/src/main/java/org/eclipse/tractusx/edc/postgresql/migration/connector/ConnectorPostgresqlMigration.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,17 @@
2222
import org.eclipse.edc.runtime.metamodel.annotation.Configuration;
2323
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
2424
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
25+
import org.eclipse.edc.spi.EdcException;
2526
import org.eclipse.edc.spi.monitor.Monitor;
2627
import org.eclipse.edc.spi.persistence.EdcPersistenceException;
2728
import org.eclipse.edc.spi.system.ServiceExtension;
29+
import org.eclipse.edc.spi.system.ServiceExtensionContext;
2830
import org.eclipse.tractusx.edc.postgresql.migration.DatabaseMigrationConfiguration;
2931
import org.flywaydb.core.Flyway;
3032

33+
import java.util.Map;
34+
import java.util.UUID;
35+
3136
import static org.eclipse.tractusx.edc.postgresql.migration.connector.ConnectorPostgresqlMigration.NAME;
3237
import static org.flywaydb.core.api.MigrationVersion.LATEST;
3338

@@ -47,6 +52,18 @@ public String name() {
4752
return NAME;
4853
}
4954

55+
@Override
56+
public void initialize(ServiceExtensionContext context) {
57+
if (configuration.enabled() && configuration.participantContextId() == null) {
58+
throw new EdcException("The participant context id has not been set, it is a mandatory setting now. You can " +
59+
"use this UUID generated randomly for you: %s, or you can generate one by yourself. Please note that"
60+
.formatted(UUID.randomUUID().toString()) +
61+
" once set, it must never change. Depending on how you are configuring the Connector, set it on the " +
62+
"`edc.participant.context.id` setting/system property or `EDC_PARTICIPANT_CONTEXT_ID` environment " +
63+
"variable, then restart the Connector");
64+
}
65+
}
66+
5067
@Override
5168
public void prepare() {
5269
if (!configuration.enabled()) {
@@ -64,6 +81,7 @@ public void prepare() {
6481
.table("flyway_schema_history")
6582
.locations("classpath:migrations/connector")
6683
.defaultSchema(configuration.schema())
84+
.placeholders(Map.of("ParticipantContextId", configuration.participantContextId()))
6785
.target(LATEST)
6886
.load();
6987

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
UPDATE edc_asset SET participant_context_id = '${ParticipantContextId}';
2+
UPDATE edc_contract_agreement SET agr_participant_context_id = '${ParticipantContextId}';
3+
UPDATE edc_contract_definitions SET participant_context_id = '${ParticipantContextId}';
4+
UPDATE edc_contract_negotiation SET participant_context_id = '${ParticipantContextId}';
5+
UPDATE edc_edr_entry SET participant_context_id = '${ParticipantContextId}';
6+
UPDATE edc_policy_monitor SET participant_context_id = '${ParticipantContextId}';
7+
UPDATE edc_policydefinitions SET participant_context_id = '${ParticipantContextId}';
8+
UPDATE edc_transfer_process SET participant_context_id = '${ParticipantContextId}';
9+
UPDATE edc_data_plane SET participant_context_id = '${ParticipantContextId}';
10+
11+
-- UPDATE edc_data_plane_instance SET data = data || '{"participantContextId": "${ParticipantContextId}"}'::json;
12+
UPDATE edc_data_plane_instance SET data = (data::jsonb || '{"participantContextId": "${ParticipantContextId}"}'::jsonb)::json;

edc-extensions/migrations/connector-migration/src/test/java/org/eclipse/tractusx/edc/postgresql/migration/connector/ConnectorPostgresqlMigrationTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.sql.SQLException;
5252
import java.util.List;
5353
import java.util.Map;
54+
import java.util.UUID;
5455
import javax.sql.DataSource;
5556

5657
import static org.assertj.core.api.Assertions.assertThat;
@@ -71,7 +72,8 @@ void setUp(ServiceExtensionContext context) {
7172
when(context.getConfig()).thenReturn(ConfigFactory.fromMap(Map.of(
7273
"edc.datasource.default.url", postgresql.getJdbcUrl(),
7374
"edc.datasource.default.user", postgresql.getUsername(),
74-
"edc.datasource.default.password", postgresql.getPassword()
75+
"edc.datasource.default.password", postgresql.getPassword(),
76+
"edc.participant.context.id", UUID.randomUUID().toString()
7577
)));
7678
}
7779

0 commit comments

Comments
 (0)