Files
UA-.NETStandard/samples/Redundancy/RedundantServer/Transparent/docker-compose.yml
d525bc3f28 Bound reconnect cleanup and organize samples by domain (#4276)
# Description

This PR fixes bounded ManagedSession reconnect cleanup and reorganizes
the sample applications into domain-focused folders.

## Reconnect cleanup

- Bounds reconnect integration cleanup with independent 30-second close
and dispose limits.
- Sends `CloseSession` through the awaited transport request path during
`Session.DisposeAsync`.
- Preserves explicit `Session.CloseAsync` behavior that waits for or
cancels outstanding publish requests.
- Covers the disposal request path with a regression test.

## Sample organization

- `samples/OpenUsd`: `GeneratorServer`, `SiteCompositionServer`
- `samples/Redundancy`: `RedundantClient`, `RedundantServer`,
`RedundantPubSub`
- `samples/Isa95`: `MinimalIsa95Server`
- `samples/MinimalApi`: `MinimalBoilerServer`, `MinimalCalcServer`,
`MinimalClient`
- `samples/DI`: `PumpDeviceIntegrationServer`
- `samples/Lds`: `ConsoleLdsServer`
- `samples/Reference`: `ConsoleReferenceClient`,
`ConsoleReferenceServer`
- `samples/PubSub`: `ConsoleReferencePubSubClient`

`UA.slnx` now exposes the same requested domain groups. Project
references, tests, runtime sample probes, CI workflows, Dockerfiles,
Compose files, helper scripts, and documentation were updated to the new
paths. `samples/Robotics/MinimalRobotServer` remains under `Robotics`.

## Validation

- `dotnet build UA.slnx`
- 3 Redundancy short-haul sample tests
- 70 DI sample tests
- 914 OpenUSD tests
- 1 WotCon model-materialization test
- 137 AOT tests
- `docker compose config` for all 6 moved Redundancy Compose files

## Related Issues

- Fixes #4273

## Checklist

- [ ] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [x] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [x] I have verified that my changes do not introduce new build or
analyzer warnings.
- [x] I built the complete `UA.slnx` solution locally.
- [ ] I ran all tests locally against at least .NET Framework and .NET
10.
- [ ] I fixed all failing and flaky tests in the CI pipelines and all
CodeQL warnings.
- [x] I have addressed all PR feedback received.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Co-authored-by: Marc Schier <mschier@microsoft.com>
Co-authored-by: Marc Schier <marcschier@users.noreply.github.com>
Copilot-Session: a2c2838f-74ae-4997-a1d4-50574d9e0636
2026-08-21 04:35:47 +00:00

112 lines
4.0 KiB
YAML

# Transparent redundancy: two replicas present ONE logical OPC UA server behind a
# single virtual endpoint.
#
# Both replicas share one ApplicationUri and one ApplicationInstanceCertificate
# (seeded into a shared PKI volume by server-a, then reused by server-b), and
# mirror address-space + session state by CRDT gossip (HA_MODE=aa,
# REDUNDANCY_MODE=transparent). An nginx TCP load balancer publishes the single
# virtual endpoint; each replica advertises that same endpoint URL (HA_HOST=lb)
# while binding to all interfaces in its own container, so discovery and
# CreateSession echo the one endpoint the client actually uses.
#
# When a replica fails, the load balancer routes the next connection to the
# survivor; because the session is mirrored, a token-reuse reconnect resumes it
# transparently on the survivor (full ActivateSession re-check still applies).
#
# The build context is the repository root. Run from the repo root:
# docker compose -f samples/Redundancy/RedundantServer/Transparent/docker-compose.yml up --build
#
# Single virtual OPC UA endpoint on the host: opc.tcp://localhost:62543/RedundantServer
#
# NOTE: this sample connects with SecurityMode None, so the per-replica cert race
# on first start is benign here. A SECURED transparent deployment must PRE-PROVISION
# the single shared ApplicationInstanceCertificate to every replica (for example a
# Kubernetes Secret / KMS), never let each replica self-generate one.
services:
server-a:
build:
context: ../../../..
dockerfile: samples/Redundancy/RedundantServer/Dockerfile
image: opcua-redundant-server
hostname: server-a
environment:
# Advertise the shared virtual endpoint (the load balancer host). The host
# is a DNS name, so the listener binds to all interfaces in this container
# while returning opc.tcp://lb:62543/... to clients.
HA_HOST: lb
HA_NODE_ID: replica-a
HA_MODE: aa
REDUNDANCY_MODE: transparent
# Shared logical identity: every replica MUST use the same ApplicationUri
# (CreateSession validates the client-supplied serverUri against it) and the
# same certificate subject.
HA_APPLICATION_URI: urn:OPCFoundation:RedundantServer:transparent
HA_SUBJECT_NAME: "CN=RedundantServer, O=OPC Foundation, DC=lb"
HA_PKI_ROOT: /shared/pki
HA_GOSSIP_PORT: "4840"
HA_GOSSIP_PEERS: server-b:4840
command: ["--port", "62543"]
volumes:
- shared-pki:/shared/pki
# server-a seeds the shared certificate; report healthy once the PKI store is
# populated so server-b starts afterwards and reuses the same certificate.
healthcheck:
test: ["CMD-SHELL", "test -n \"$(ls -A /shared/pki 2>/dev/null)\""]
interval: 3s
timeout: 2s
retries: 20
server-b:
build:
context: ../../../..
dockerfile: samples/Redundancy/RedundantServer/Dockerfile
image: opcua-redundant-server
hostname: server-b
environment:
HA_HOST: lb
HA_NODE_ID: replica-b
HA_MODE: aa
REDUNDANCY_MODE: transparent
HA_APPLICATION_URI: urn:OPCFoundation:RedundantServer:transparent
HA_SUBJECT_NAME: "CN=RedundantServer, O=OPC Foundation, DC=lb"
HA_PKI_ROOT: /shared/pki
HA_GOSSIP_PORT: "4840"
HA_GOSSIP_PEERS: server-a:4840
command: ["--port", "62543"]
volumes:
- shared-pki:/shared/pki
depends_on:
server-a:
condition: service_healthy
lb:
image: nginx:1.27-alpine
hostname: lb
depends_on:
- server-a
- server-b
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
# The single virtual OPC UA endpoint exposed to clients on the host.
- "62543:62543"
client:
build:
context: ../../../..
dockerfile: samples/Redundancy/RedundantClient/Dockerfile
image: opcua-redundant-client
depends_on:
- lb
command:
- "--server"
- "opc.tcp://lb:62543/RedundantServer"
- "--autoaccept"
- "--nosecurity"
- "--duration"
- "00:10:00"
volumes:
shared-pki: