Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ jobs:
# The slowest healthy job finishes in under 18 minutes. Anything still running at 30 has lost its
# runner or hung on infrastructure, and without a cap it would occupy the runner for 6 hours.
timeout-minutes: 30
permissions:
contents: read
# Google Cloud workload identity federation for the GooglePubSub category
id-token: write
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
# Categories are declared by the <TestCategory> property in each test project. A category can
# span several projects that share infrastructure, so that the container is provisioned once
# and the union of their build closures is compiled once.
test-category: [ DefaultCore, DefaultMonitoring, Raven, SqlServer, PostgreSql, RabbitMQ, AzureServiceBus, AzureStorageQueues, MSMQ, SQS, IBMMQ ]
test-category: [ DefaultCore, DefaultMonitoring, Raven, SqlServer, PostgreSql, RabbitMQ, AzureServiceBus, AzureStorageQueues, MSMQ, SQS, IBMMQ, GooglePubSub ]
include:
- os: windows-latest
os-name: Windows
Expand Down Expand Up @@ -185,6 +189,23 @@ jobs:
tag: ServiceControl
env:
REGION_OVERRIDE: eastus
- name: Authenticate to Google Cloud
id: gcp-auth
if: matrix.test-category == 'GooglePubSub'
uses: google-github-actions/auth@v3.0.0
with:
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
- name: Setup Google Cloud SDK
if: matrix.test-category == 'GooglePubSub'
uses: google-github-actions/setup-gcloud@v3.0.1
- name: Setup Google Pub/Sub environment variables
if: matrix.test-category == 'GooglePubSub'
run: |
# The prefix keeps parallel runs apart and scopes the cleanup step to this run's topics and subscriptions
$prefix = "gha-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.os-name }}-"
echo "PUBSUB_TEST_PREFIX=$prefix" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
echo "ServiceControl_TransportTests_GooglePubSub_ConnectionString=ProjectId=${{ vars.GOOGLE_CLOUD_PROJECT }};ResourceNamePrefix=$prefix" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Run tests
uses: Particular/run-tests-action@v1.9.0
with:
Expand All @@ -194,6 +215,16 @@ jobs:
ServiceControl_TESTS_FILTER: ${{ matrix.test-category }}
PARTICULARSOFTWARE_LICENSE: ${{ secrets.LICENSETEXT }}
AZURE_ACI_CREDENTIALS: ${{ secrets.AZURE_ACI_CREDENTIALS }}
- name: Clean up Google Pub/Sub resources
if: always() && steps.gcp-auth.outcome == 'success'
run: |
$project = '${{ vars.GOOGLE_CLOUD_PROJECT }}'
$filter = "name:$Env:PUBSUB_TEST_PREFIX"
$subscriptions = @(gcloud pubsub subscriptions list --project=$project --filter=$filter --format="value(name.basename())" --verbosity=error)
if ($subscriptions.Count -gt 0) { gcloud pubsub subscriptions delete @subscriptions --project=$project --quiet --verbosity=error }
$topics = @(gcloud pubsub topics list --project=$project --filter=$filter --format="value(name.basename())" --verbosity=error)
if ($topics.Count -gt 0) { gcloud pubsub topics delete @topics --project=$project --quiet --verbosity=error }
Write-Host "Deleted $($subscriptions.Count) subscriptions and $($topics.Count) topics with prefix $Env:PUBSUB_TEST_PREFIX"

compile:
name: ${{ matrix.os-name }}-Compile
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Transports:

- `AzureServiceBus`
- `AzureStorageQueues`
- `GooglePubSub`
- `IBMMQ`
- `MSMQ`
- `RabbitMQ` (all four classic/quorum and conventional/direct routing combinations)
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This section points to sources that explain why ServiceControl is designed the w
- [Message body storage](message-body-storage.md) — where the Audit SQL Server and PostgreSQL persisters keep message bodies, how retention removes them, and which settings are optional
- [Bulk retries design](bulk-retries-design.md) — how ServiceControl retries failed messages in bulk
- [Retries over Azure Storage Queues transport](retries-asq-transport.md) — how retries behave with one or several storage accounts
- [Google Cloud Pub/Sub transport](google-pubsub-transport.md) — why credentials come only from Application Default Credentials, and which platform features the transport limits
- [Data versioning design](data-versioning-design.md) — which invariant keeps a cached API response from going stale
- [Event log design](eventlog-design.md) — what the event log is and what it records
- [Multiple ServiceControl instances communication](multipleservicecontrolinstancescommunication.md) — how primary, audit, and monitoring instances talk to each other
Expand Down
35 changes: 35 additions & 0 deletions docs/google-pubsub-transport.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Google Cloud Pub/Sub transport

The primary, audit, and monitoring instances can run on the `NServiceBus.Transport.GooglePubSub` package. The transport maps each queue to a topic and a subscription with the same ID. This page covers how ServiceControl uses the transport and which platform features the transport limits.

## Connection string

The connection string accepts `ProjectId`, `ResourceNamePrefix`, `ServiceEndpoint`, and `EmulatorDetection`, and each maps to the `GooglePubSubTransportOptions` property of the same name. All four are optional. The parser rejects any other key, so credentials cannot end up in the connection string or in the instance configuration.

Without `ProjectId`, the transport reads the `GOOGLE_CLOUD_PROJECT` or `GCLOUD_PROJECT` environment variable, then the Google Cloud metadata server. The transport ignores the Pub/Sub emulator unless `EmulatorDetection` is `EmulatorOnly` or `EmulatorOrProduction`. With either value, it connects to the address in `PUBSUB_EMULATOR_HOST`, without authentication or encryption.

## Credentials

ServiceControl uses Application Default Credentials (ADC) for every component. Error ingestion, audit ingestion, retries, and the throughput queue create their receivers through `TransportCustomization.CreateTransportInfrastructure`, which passes no service provider to the transport. Without a service provider, the transport uses ADC. A credential registered in dependency injection would reach only the NServiceBus endpoints.

## Transaction mode

The transport supports `None` and `ReceiveOnly`. The retry dequeuer requests `SendsAtomicWithReceive` and falls back to `ReceiveOnly`. Forwarding a retried message and acknowledging its staged copy are separate operations, so a failure between them makes ServiceControl forward the message again.

## Delayed delivery

The transport throws for delayed sends and saga timeouts, and it limits delayed retries to 600 seconds. ServiceControl sends no delayed messages and disables sagas. The primary and monitoring instances set delayed retries to zero, which passes the transport's startup check. The audit instance is send-only, so the transport skips the check for it.

## Integration events

With `EnableExternalIntegrationsPublishing`, the primary publishes integration events to the transport's default event topics. The running primary has installers disabled, and the transport throws when it publishes to a missing topic. The customization therefore declares each type in `TransportSettings.EventTypesPublished` with `Topology.Publishes`, and the transport creates their topics when setup calls `ProvisionQueues`. ServiceControl leaves topic naming to the transport.

Setup declares the event types only when `EnableExternalIntegrationsPublishing` is on. An instance that turns the setting on later must run setup again before it publishes.

## Queue length

The monitoring instance does not report queue lengths for this transport yet. The Pub/Sub API has no backlog count, so queue length has to come from Cloud Monitoring.

## Headers with empty values

The transport drops headers whose value is empty or null, because Pub/Sub does not deliver an attribute with an empty value. ServiceControl's own headers always have a value. A header that a user empties while editing a failed message is not sent with the retried message.
15 changes: 15 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ The SQL Server and PostgreSQL persistence test projects contain a `SlowMigration

Transport tests run the transport test suite for each transport.

### Google Cloud Pub/Sub

The `GooglePubSub` tests read their connection string from `ServiceControl_TransportTests_GooglePubSub_ConnectionString`. CI runs them against a Google Cloud project rather than the Pub/Sub emulator, because the emulator delivers headers with empty values that Pub/Sub drops. The job signs in through workload identity federation with the `GCP_WORKLOAD_IDENTITY_PROVIDER` and `GCP_SERVICE_ACCOUNT` repository variables, and creates its resources in the project named by `GOOGLE_CLOUD_PROJECT`. The service account needs the Pub/Sub Editor role (`roles/pubsub.editor`) to create and delete topics and subscriptions.

Each job sets `ResourceNamePrefix` to a prefix built from the run ID, the attempt, and the operating system, so that parallel jobs do not share resources. The last step deletes every subscription and topic with that prefix, even when the tests fail.

To run the tests locally against the emulator:

1. Start the emulator: `docker run --rm -p 8085:8085 gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators gcloud beta emulators pubsub start --host-port=0.0.0.0:8085`
2. Set `PUBSUB_EMULATOR_HOST=localhost:8085`.
3. Set `ServiceControl_TransportTests_GooglePubSub_ConnectionString=ProjectId=local-test;EmulatorDetection=EmulatorOnly`.
4. Set `ServiceControl_TESTS_FILTER=GooglePubSub` and run the `ServiceControl.Transports.GooglePubSub.Tests` project.

To run them against a Google Cloud project instead, leave `PUBSUB_EMULATOR_HOST` unset, sign in with `gcloud auth application-default login`, and set `ProjectId` and a personal `ResourceNamePrefix` in the connection string.

## Acceptance tests

Acceptance tests run the full ServiceControl and use the HTTP API to validate results. LearningTransport is used for all tests.
Expand Down
3 changes: 3 additions & 0 deletions docs/usage-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ The primary's `TransportEnvironmentDataProvider` emits `Transport.Type` and adds
| `Transport.AmazonSQS.LargeMessageBucket` | `None`, `Configured` | `S3BucketForLargeMessages` | Unreleased |
| `Transport.AmazonSQS.MessageWrapping` | `Enabled`, `Disabled` | `DoNotWrapOutgoingMessages` | Unreleased |
| `Transport.AmazonSQS.ReservedBytesInMessageSize` | `Default` or number | `ReservedBytesInMessageSize` | Unreleased |
| `Transport.GooglePubSub.NamePrefix` | `None`, `Configured` | `ResourceNamePrefix` in the connection string | Unreleased |
| `Transport.RabbitMQ.DeliveryLimitValidation` | `Enabled`, `Disabled` | `ValidateDeliveryLimits` | Unreleased |
| `Transport.RabbitMQ.ManagementApi` | `Default`, `Configured` | `ManagementApiUrl` | Unreleased |
| `Transport.SQLServer.QueueSchema` | `Default`, `Custom` | `Queue Schema` in the connection string | Unreleased |
Expand Down Expand Up @@ -286,6 +287,7 @@ A setting that identifies and is also security configuration is listed as Identi
| `Cors.AllowAnyOrigin` and whether origins are restricted | Security configuration | |
| `ForwardedHeaders.Enabled`, `TrustAllProxies` and whether proxies are restricted | Security configuration | |
| Transport authentication, encryption and certificate validation options in the connection string, for example RabbitMQ `UseExternalAuthMechanism` and `DisableRemoteCertificateValidation` | Security configuration | |
| Google Pub/Sub `ServiceEndpoint` | Security configuration | A custom endpoint usually means a regional endpoint or the restricted endpoint of VPC Service Controls, which restricts access. |
| Database authentication, encryption and certificate validation options, for example SQL Server `Encrypt` and `TrustServerCertificate` or PostgreSQL `SSL Mode`, and whether a RavenDB client certificate is used | Security configuration | |
| Body storage authentication mode | Security configuration | 6.20.0 to 6.21.2 report it as `Persistence.BodyStorage.Auth`. |
| Email notification TLS and SMTP authentication | Security configuration | |
Expand All @@ -299,6 +301,7 @@ A setting that identifies and is also security configuration is listed as Identi
| `--error-ingestion-only` | Not a choice | A worker mode. Workers do not build reports. |
| RavenDB `MaintenanceMode` | Not a choice | An instance in maintenance mode serves no API, so it cannot build a report. |
| `ASPNETCORE_ENVIRONMENT=Development` | Not a choice | A development mode. |
| Google Pub/Sub `EmulatorDetection`, `PUBSUB_EMULATOR_HOST` | Not a choice | They select the Pub/Sub emulator, a development mode. |
| `DOTNET_RUNNING_IN_CONTAINER` | Not a choice | Already covered by `Host.Model`. |
| Retry, archive, unarchive, resolve, edit and group comment operations | Not a choice | These are actions. Their on/off switch, where one exists, is reported. |
| Custom checks | Not a choice | Endpoints report them and ServiceControl stores them. Deleting one does not keep a muted state. |
Expand Down
4 changes: 4 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<PackageVersion Include="NServiceBus.Testing" Version="11.0.0" />
<PackageVersion Include="NServiceBus.Transport.AzureServiceBus" Version="6.6.2" />
<PackageVersion Include="NServiceBus.Transport.AzureStorageQueues" Version="14.1.0" />
<PackageVersion Include="NServiceBus.Transport.GooglePubSub" Version="0.0.0-alpha.0.64" />
<PackageVersion Include="NServiceBus.Transport.Msmq.Sources" Version="4.0.1" />
<PackageVersion Include="NServiceBus.Transport.PostgreSql" Version="9.2.0" />
<PackageVersion Include="NServiceBus.Transport.SqlServer" Version="9.2.0" />
Expand Down Expand Up @@ -103,14 +104,17 @@
</ItemGroup>
<ItemGroup Label="Versions to pin transitive references">
<PackageVersion Include="Azure.Core" Version="1.65.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="$(RuntimeFrameworkVersion)" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.1.2" />
<!-- Enforced by DeploymentPackageTests.DuplicateAssembliesInDeploymentUnitsShouldHaveMatchingVersions -->
<PackageVersion Include="Microsoft.Data.SqlClient.Extensions.Abstractions" Version="7.1.2" />
<PackageVersion Include="Microsoft.Data.SqlClient.Internal.Logging" Version="7.1.2" />
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="$(RuntimeFrameworkVersion)" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(RuntimeFrameworkVersion)" />
<PackageVersion Include="Microsoft.IdentityModel.Abstractions" Version="8.23.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="Npgsql" Version="10.0.4" />
<PackageVersion Include="System.CodeDom" Version="$(RuntimeFrameworkVersion)" />
<PackageVersion Include="System.Formats.Cbor" Version="$(RuntimeFrameworkVersion)" />
<PackageVersion Include="System.Security.Cryptography.Pkcs" Version="$(RuntimeFrameworkVersion)" />
<PackageVersion Include="System.Threading.RateLimiting" Version="$(RuntimeFrameworkVersion)" />
Expand Down
1 change: 1 addition & 0 deletions src/ProjectReferences.Transports.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<ItemGroup Label="Transports">
<ProjectReference Include="..\ServiceControl.Transports.ASBS\ServiceControl.Transports.ASBS.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.ASQ\ServiceControl.Transports.ASQ.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.GooglePubSub\ServiceControl.Transports.GooglePubSub.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.IBMMQ\ServiceControl.Transports.IBMMQ.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.Learning\ServiceControl.Transports.Learning.csproj" ReferenceOutputAssembly="false" Private="false" />
<ProjectReference Include="..\ServiceControl.Transports.Msmq\ServiceControl.Transports.Msmq.csproj" ReferenceOutputAssembly="false" Private="false" SkipGetTargetFrameworkProperties="true" UndefineProperties="TargetFramework" />
Expand Down
4 changes: 4 additions & 0 deletions src/ServiceControl.Audit/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ These settings are only here so that we can debug ServiceControl while developin
<add key="ServiceControl.Audit/TransportType" value="LearningTransport" />
<!--<add key="ServiceControl.Audit/TransportType" value="AmazonSQS" />-->
<!--<add key="ServiceControl.Audit/TransportType" value="AzureStorageQueue" />-->
<!--<add key="ServiceControl.Audit/TransportType" value="GooglePubSub" />-->
<!--<add key="ServiceControl.Audit/TransportType" value="MSMQ" />-->
<!--<add key="ServiceControl.Audit/TransportType" value="NetStandardAzureServiceBus" />-->
<!--<add key="ServiceControl.Audit/TransportType" value="PostgreSQL" />-->
Expand Down Expand Up @@ -88,6 +89,9 @@ These settings are only here so that we can debug ServiceControl while developin
<!--AzureStorageQueue -->
<!--<add name="NServiceBus/Transport" connectionString="DefaultEndpointsProtocol=[http|https];AccountName=;AccountKey=;Subscriptions Table=tablename" />-->

<!--GooglePubSub: credentials come from Application Default Credentials. For the emulator, add EmulatorDetection=EmulatorOnly and set PUBSUB_EMULATOR_HOST -->
<!--<add name="NServiceBus/Transport" connectionString="ProjectId=;ResourceNamePrefix=" />-->

<!--MSMQ -->
<!--<add name="NServiceBus/Transport" connectionString="" />-->

Expand Down
4 changes: 4 additions & 0 deletions src/ServiceControl.Monitoring/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ These settings are only here so that we can debug ServiceControl while developin
<add key="Monitoring/TransportType" value="LearningTransport" />
<!--<add key="Monitoring/TransportType" value="AmazonSQS" />-->
<!--<add key="Monitoring/TransportType" value="AzureStorageQueue" />-->
<!--<add key="Monitoring/TransportType" value="GooglePubSub" />-->
<!--<add key="Monitoring/TransportType" value="MSMQ" />-->
<!--<add key="Monitoring/TransportType" value="NetStandardAzureServiceBus" />-->
<!--<add key="Monitoring/TransportType" value="PostgreSQL" />-->
Expand Down Expand Up @@ -81,6 +82,9 @@ These settings are only here so that we can debug ServiceControl while developin
<!--AzureStorageQueue -->
<!--<add name="NServiceBus/Transport" connectionString="DefaultEndpointsProtocol=[http|https];AccountName=;AccountKey=;Subscriptions Table=tablename" />-->

<!--GooglePubSub: credentials come from Application Default Credentials. For the emulator, add EmulatorDetection=EmulatorOnly and set PUBSUB_EMULATOR_HOST -->
<!--<add name="NServiceBus/Transport" connectionString="ProjectId=;ResourceNamePrefix=" />-->

<!--MSMQ -->
<!--<add name="NServiceBus/Transport" connectionString="" />-->

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# Justification: Test project
dotnet_diagnostic.CA2007.severity = none
Loading
Loading