Some checks failed
v2-ci / build (push) Failing after 41s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
Two bring-up issues found while clicking through the operator Deploy flow
on the docker-dev stack:
- ConfigPublishCoordinator computes expected-ack NodeIds from
Akka.Cluster.State.Members as "{host}:{port}" (e.g. "driver-a:4053") to
match ClusterRoleInfo's NodeId derivation. The seed had been using the
bare service name ("driver-a"), so NodeDeploymentState INSERT hit FK
violation 547 on NodeDeploymentState.NodeId → ClusterNode.NodeId. Seed
now writes the full host:port form for every ClusterNode row.
- Blazor Server uses SignalR (WebSocket upgrade after the initial GET).
Without sticky sessions, Traefik round-robins admin-a/admin-b and the
WebSocket upgrade lands on the wrong backend, returning "No Connection
with that ID: Status code '404'" so @onclick handlers never fire on the
client. Added sticky.cookie (otopcua_lb, SameSite=Lax) to all three
Traefik service loadBalancers so each session pins to one node.
Verified end-to-end: clicked "Deploy current configuration" on
/deployments → Deployment row sealed in ~70ms → driver-a + driver-b
spawn GalaxyMxGateway driver (stub=False) → GalaxyDriver connects to
http://10.100.0.48:5120 with the seeded ApiKeySecretRef=env:GALAXY_MXGW_API_KEY.
165 lines
7.6 KiB
SQL
165 lines
7.6 KiB
SQL
-- docker-dev cluster seed. Idempotent — safe to re-run on every `docker compose up`.
|
|
--
|
|
-- Populates:
|
|
-- ServerCluster MAIN, SITE-A, SITE-B
|
|
-- ClusterNode driver-a, driver-b → MAIN
|
|
-- site-a-1, site-a-2 → SITE-A
|
|
-- site-b-1, site-b-2 → SITE-B
|
|
--
|
|
-- ServerCluster.NodeCount + RedundancyMode are coupled by CHECK constraint:
|
|
-- NodeCount=1 ⇒ RedundancyMode='None'
|
|
-- NodeCount=2 ⇒ RedundancyMode∈('Warm','Hot')
|
|
--
|
|
-- Each ClusterNode.ApplicationUri MUST be globally unique (UX_ClusterNode_ApplicationUri).
|
|
-- Convention: urn:OtOpcUa:<NodeId>.
|
|
--
|
|
-- Host = Compose service name (resolves inside the otopcua-dev network).
|
|
-- OpcUaPort stays at the container-internal 4840; the host-side port mapping is in
|
|
-- docker-compose.yml ports: blocks and is irrelevant to ClusterNode rows.
|
|
|
|
SET NOCOUNT ON;
|
|
SET XACT_ABORT ON;
|
|
|
|
BEGIN TRANSACTION;
|
|
|
|
------------------------------------------------------------------------------
|
|
-- ServerCluster
|
|
------------------------------------------------------------------------------
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ServerCluster WHERE ClusterId = 'MAIN')
|
|
INSERT INTO dbo.ServerCluster
|
|
(ClusterId, Name, Enterprise, Site, NodeCount, RedundancyMode, Enabled, Notes, CreatedBy)
|
|
VALUES
|
|
('MAIN', 'Main cluster', 'zb', 'docker-dev',
|
|
2, 'Warm', 1,
|
|
'docker-dev seed — admin-a/admin-b control-plane, driver-a/driver-b OPC UA publishers.',
|
|
'docker-dev-seed');
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ServerCluster WHERE ClusterId = 'SITE-A')
|
|
INSERT INTO dbo.ServerCluster
|
|
(ClusterId, Name, Enterprise, Site, NodeCount, RedundancyMode, Enabled, Notes, CreatedBy)
|
|
VALUES
|
|
('SITE-A', 'Site A', 'zb', 'site-a',
|
|
2, 'Warm', 1,
|
|
'docker-dev seed — 2-node fused admin+driver cluster.',
|
|
'docker-dev-seed');
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ServerCluster WHERE ClusterId = 'SITE-B')
|
|
INSERT INTO dbo.ServerCluster
|
|
(ClusterId, Name, Enterprise, Site, NodeCount, RedundancyMode, Enabled, Notes, CreatedBy)
|
|
VALUES
|
|
('SITE-B', 'Site B', 'zb', 'site-b',
|
|
2, 'Warm', 1,
|
|
'docker-dev seed — 2-node fused admin+driver cluster.',
|
|
'docker-dev-seed');
|
|
|
|
------------------------------------------------------------------------------
|
|
-- ClusterNode — main cluster OPC UA publishers
|
|
--
|
|
-- NodeId is "<compose-service>:4053" so it matches what ClusterRoleInfo +
|
|
-- ConfigPublishCoordinator derive from Akka.Cluster.Get(system).State.Members
|
|
-- (member.Address.Host:Port). NodeDeploymentState.NodeId is FK-bound to
|
|
-- ClusterNode.NodeId; mismatched values cause FK 547 on deploy.
|
|
------------------------------------------------------------------------------
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ClusterNode WHERE NodeId = 'driver-a:4053')
|
|
INSERT INTO dbo.ClusterNode
|
|
(NodeId, ClusterId, Host, OpcUaPort, DashboardPort, ApplicationUri, ServiceLevelBase, Enabled, CreatedBy)
|
|
VALUES ('driver-a:4053', 'MAIN', 'driver-a', 4840, 8081, 'urn:OtOpcUa:driver-a', 200, 1, 'docker-dev-seed');
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ClusterNode WHERE NodeId = 'driver-b:4053')
|
|
INSERT INTO dbo.ClusterNode
|
|
(NodeId, ClusterId, Host, OpcUaPort, DashboardPort, ApplicationUri, ServiceLevelBase, Enabled, CreatedBy)
|
|
VALUES ('driver-b:4053', 'MAIN', 'driver-b', 4840, 8081, 'urn:OtOpcUa:driver-b', 150, 1, 'docker-dev-seed');
|
|
|
|
------------------------------------------------------------------------------
|
|
-- ClusterNode — site A
|
|
------------------------------------------------------------------------------
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ClusterNode WHERE NodeId = 'site-a-1:4053')
|
|
INSERT INTO dbo.ClusterNode
|
|
(NodeId, ClusterId, Host, OpcUaPort, DashboardPort, ApplicationUri, ServiceLevelBase, Enabled, CreatedBy)
|
|
VALUES ('site-a-1:4053', 'SITE-A', 'site-a-1', 4840, 8081, 'urn:OtOpcUa:site-a-1', 200, 1, 'docker-dev-seed');
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ClusterNode WHERE NodeId = 'site-a-2:4053')
|
|
INSERT INTO dbo.ClusterNode
|
|
(NodeId, ClusterId, Host, OpcUaPort, DashboardPort, ApplicationUri, ServiceLevelBase, Enabled, CreatedBy)
|
|
VALUES ('site-a-2:4053', 'SITE-A', 'site-a-2', 4840, 8081, 'urn:OtOpcUa:site-a-2', 150, 1, 'docker-dev-seed');
|
|
|
|
------------------------------------------------------------------------------
|
|
-- ClusterNode — site B
|
|
------------------------------------------------------------------------------
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ClusterNode WHERE NodeId = 'site-b-1:4053')
|
|
INSERT INTO dbo.ClusterNode
|
|
(NodeId, ClusterId, Host, OpcUaPort, DashboardPort, ApplicationUri, ServiceLevelBase, Enabled, CreatedBy)
|
|
VALUES ('site-b-1:4053', 'SITE-B', 'site-b-1', 4840, 8081, 'urn:OtOpcUa:site-b-1', 200, 1, 'docker-dev-seed');
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.ClusterNode WHERE NodeId = 'site-b-2:4053')
|
|
INSERT INTO dbo.ClusterNode
|
|
(NodeId, ClusterId, Host, OpcUaPort, DashboardPort, ApplicationUri, ServiceLevelBase, Enabled, CreatedBy)
|
|
VALUES ('site-b-2:4053', 'SITE-B', 'site-b-2', 4840, 8081, 'urn:OtOpcUa:site-b-2', 150, 1, 'docker-dev-seed');
|
|
|
|
------------------------------------------------------------------------------
|
|
-- Galaxy MxAccess gateway — MAIN cluster
|
|
--
|
|
-- Namespace.Kind=SystemPlatform is required for Galaxy/MXAccess data per
|
|
-- decision #107; raw equipment drivers use Equipment. DriverInstance points
|
|
-- at the external mxaccessgw process. The driver code lives in this repo
|
|
-- (.NET 10, cross-platform); only the gateway worker needs Windows.
|
|
--
|
|
-- ApiKeySecretRef = env:GALAXY_MXGW_API_KEY → resolved at runtime by
|
|
-- GalaxyDriver.ResolveApiKey. The env var is set on every driver-role
|
|
-- container in docker-compose.yml.
|
|
------------------------------------------------------------------------------
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.Namespace WHERE NamespaceId = 'MAIN-galaxy')
|
|
INSERT INTO dbo.Namespace
|
|
(NamespaceRowId, NamespaceId, ClusterId, Kind, NamespaceUri, Enabled, Notes)
|
|
VALUES
|
|
(NEWID(), 'MAIN-galaxy', 'MAIN', 'SystemPlatform',
|
|
'urn:zb:docker-dev:galaxy', 1,
|
|
'docker-dev seed — Galaxy / MXAccess namespace served by the MAIN cluster.');
|
|
|
|
IF NOT EXISTS (SELECT 1 FROM dbo.DriverInstance WHERE DriverInstanceId = 'MAIN-galaxy-mxgw')
|
|
INSERT INTO dbo.DriverInstance
|
|
(DriverInstanceRowId, DriverInstanceId, ClusterId, NamespaceId, Name, DriverType, Enabled, DriverConfig)
|
|
VALUES
|
|
(NEWID(), 'MAIN-galaxy-mxgw', 'MAIN', 'MAIN-galaxy',
|
|
'MxAccess gateway (10.100.0.48:5120)', 'GalaxyMxGateway', 1,
|
|
N'{
|
|
"Gateway": {
|
|
"Endpoint": "http://10.100.0.48:5120",
|
|
"ApiKeySecretRef": "env:GALAXY_MXGW_API_KEY",
|
|
"UseTls": false,
|
|
"ConnectTimeoutSeconds": 10,
|
|
"DefaultCallTimeoutSeconds": 30
|
|
},
|
|
"MxAccess": {
|
|
"ClientName": "OtOpcUa-MAIN-docker-dev",
|
|
"PublishingIntervalMs": 1000
|
|
},
|
|
"Repository": {
|
|
"DiscoverPageSize": 5000,
|
|
"WatchDeployEvents": true
|
|
},
|
|
"Reconnect": {
|
|
"InitialBackoffMs": 500,
|
|
"MaxBackoffMs": 30000,
|
|
"ReplayOnSessionLost": true
|
|
}
|
|
}');
|
|
|
|
COMMIT TRANSACTION;
|
|
|
|
------------------------------------------------------------------------------
|
|
-- Summary (logged by sqlcmd output)
|
|
------------------------------------------------------------------------------
|
|
|
|
SELECT ClusterId, Name, NodeCount, RedundancyMode FROM dbo.ServerCluster ORDER BY ClusterId;
|
|
SELECT NodeId, ClusterId, Host, OpcUaPort, ApplicationUri, ServiceLevelBase
|
|
FROM dbo.ClusterNode ORDER BY ClusterId, NodeId;
|
|
SELECT NamespaceId, ClusterId, Kind, NamespaceUri FROM dbo.Namespace ORDER BY ClusterId, NamespaceId;
|
|
SELECT DriverInstanceId, ClusterId, DriverType, NamespaceId, Name
|
|
FROM dbo.DriverInstance ORDER BY ClusterId, DriverInstanceId;
|