Difference in PSQL containers between new project & eShopLite when deployed
adamtrip opened this issue · comments
On eShopLite app sample, when running aspire generate
, on the aspire-output
for the catalogDb project it generates two files:
- kustomization.yml
- postgres-server-yml
However, in my test solution, it generates different things:
- deployment.yml
- kustomization.yml
- service.yml
All this because when deploying my solution I get a ServiceSocketException: Name or service not known
error while starting the DbManager project. On the eShopLite project, when starting the services on k8s it apears that they start on a specific order (maybe because of the database) while on my solution they all start at the same time.
Here's the files for both the scenarios. Check the difference between the catalog
on both manifests. The only difference on my setups is the aspire version because in eShopLite I can't call AddNodeApp
or AddNpmApp
eShopLite->manifest.json:
{
"resources": {
"catalog": {
"type": "postgres.server.v0"
},
"catalogdb": {
"type": "postgres.database.v0",
"parent": "catalog"
},
"basketcache": {
"type": "redis.v0"
},
"catalogservice": {
"type": "project.v0",
"path": "..\\eShopLite.CatalogService\\eShopLite.CatalogService.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"ConnectionStrings__catalogdb": "{catalogdb.connectionString}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
}
}
},
"basketservice": {
"type": "project.v0",
"path": "..\\eShopLite.BasketService\\eShopLite.BasketService.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"ConnectionStrings__basketcache": "{basketcache.connectionString}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http2"
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http2"
}
}
},
"frontend": {
"type": "project.v0",
"path": "..\\eShopLite.Frontend\\eShopLite.Frontend.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"services__basketservice__0": "{basketservice.bindings.http.url}",
"services__basketservice__1": "{basketservice.bindings.https.url}",
"services__catalogservice__0": "{catalogservice.bindings.http.url}",
"services__catalogservice__1": "{catalogservice.bindings.https.url}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
}
}
},
"catalogdbmanager": {
"type": "project.v0",
"path": "..\\eShopLite.CatalogDbManager\\eShopLite.CatalogDbManager.csproj",
"env": {
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES": "true",
"OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES": "true",
"ConnectionStrings__catalogdb": "{catalogdb.connectionString}"
},
"bindings": {
"http": {
"scheme": "http",
"protocol": "tcp",
"transport": "http"
},
"https": {
"scheme": "https",
"protocol": "tcp",
"transport": "http"
}
}
}
}
}
My Solution -> manifest.json:
{
"resources": {
"catalog": {
"type": "container.v0",
"image": "postgres:latest",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
"POSTGRES_PASSWORD": "{catalog.inputs.password}"
},
"bindings": {
"tcp": {
"scheme": "tcp",
"protocol": "tcp",
"transport": "tcp",
"containerPort": 5432
}
},
"connectionString": "Host={catalog.bindings.tcp.host};Port={catalog.bindings.tcp.port};Username=postgres;Password={catalog.inputs.password};",
"inputs": {
"password": {
"type": "string",
"secret": true,
"default": {
"generate": {
"minLength": 10
}
}
}
}
},
"catalogdb": {
"type": "postgres.database.v0",
"parent": "catalog"
}
}
}
Aye there is a reason for the difference in generated files
"catalog": {
"type": "postgres.server.v0"
},
This is the non abstract postgres server type - that has a dedicated template
Where as you are using the AddPostrgesContainer version it seems, which produces a container.v0
aspire component not a postgres.server.v0
component
"catalog": {
"type": "container.v0",
"image": "postgres:latest",
"env": {
"POSTGRES_HOST_AUTH_METHOD": "scram-sha-256",
"POSTGRES_INITDB_ARGS": "--auth-host=scram-sha-256 --auth-local=scram-sha-256",
"POSTGRES_PASSWORD": "{catalog.inputs.password}"
},
"bindings": {
"tcp": {
"scheme": "tcp",
"protocol": "tcp",
"transport": "tcp",
"containerPort": 5432
}
},
"connectionString": "Host={catalog.bindings.tcp.host};Port={catalog.bindings.tcp.port};Username=postgres;Password={catalog.inputs.password};",
"inputs": {
"password": {
"type": "string",
"secret": true,
"default": {
"generate": {
"minLength": 10
}
}
}
}
},
The two aspire methods are for different things and are treated differently because of this via aspirate, as they do different things in aspire preview 2.
The non container variant, uses a postgres template to deploy a server
The container variant includes inputs for generating secrets, as well as a connectionString property
Can you share your program.cs to confirm?
You should find two extension methods for adding postgres - if you want to have the same as the eShopLite, then you need to use the other postgres method
I can see running against eShopLite that the connection strings aren't correct
Will label this as a bug and sort
Found it.
Connection strings for containers were being processed incorrectly
Added a preview two manifest and as well as tests for it to the tests project
fixed in version 0.1.23-preview
going out in a few.
Solved it but a new issue is happening: #92!