Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/Aspire.Hosting.SqlServer/SqlServerBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public static IResourceBuilder<SqlServerServerResource> AddSqlServer(this IDistr
var sqlServer = new SqlServerServerResource(name, passwordParameter);
return builder.AddResource(sqlServer)
.WithEndpoint(port: port, targetPort: 1433, name: SqlServerServerResource.PrimaryEndpointName)
.WithImage(SqlServerContainerImageTags.Image, SqlServerContainerImageTags.Tag)
.WithImage(SqlServerContainerImageTags.Image)
.WithImageSHA256(SqlServerContainerImageTags.Digest)
Copy link
Member

@eerhardt eerhardt Jul 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they suggested we should instead depend on digests as opposed to tags, to be able to guarantee determinism

Note that this is OK to unblock our tests, but this doesn't comply with our long term plan.

#3933
#1997 (comment)

This approach doesn't allow for security patches to be automatically applied.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a follow up discussion just to finalize on our plan going forward. We may very well end up following the same plan we have, I just want to make sure we take into consideration the concept of determinism and the fact that we have now been broken by this, so we should check what our customers would expect us to do.

For this particular case, it's worth noting that the underlying image doesn't follow semver which seems to be one of the keys of our plan.

.WithImageRegistry(SqlServerContainerImageTags.Registry)
.WithEnvironment("ACCEPT_EULA", "Y")
.WithEnvironment(context =>
Expand Down
3 changes: 2 additions & 1 deletion src/Aspire.Hosting.SqlServer/SqlServerContainerImageTags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ internal static class SqlServerContainerImageTags
{
public const string Registry = "mcr.microsoft.com";
public const string Image = "mssql/server";
public const string Tag = "2022-latest";
// Tracking tag: 2022-latest. NOTE: latest digest fails the tests. We need to investigate.
public const string Digest = "sha256:c4369c38385eba011c10906dc8892425831275bb035d5ce69656da8e29de50d8";
}
2 changes: 1 addition & 1 deletion tests/Aspire.Hosting.Tests/ManifestGenerationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public void VerifyTestProgramFullManifest()
"sqlserver": {
"type": "container.v0",
"connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={sqlserver-password.value};TrustServerCertificate=true",
"image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}:{{SqlServerContainerImageTags.Tag}}",
"image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}@{{SqlServerContainerImageTags.Digest}}",
"env": {
"ACCEPT_EULA": "Y",
"MSSQL_SA_PASSWORD": "{sqlserver-password.value}"
Expand Down
6 changes: 3 additions & 3 deletions tests/Aspire.Hosting.Tests/SqlServer/AddSqlServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task AddSqlServerContainerWithDefaultsAddsAnnotationMetadata()
Assert.Equal("tcp", endpoint.UriScheme);

var containerAnnotation = Assert.Single(containerResource.Annotations.OfType<ContainerImageAnnotation>());
Assert.Equal(SqlServerContainerImageTags.Tag, containerAnnotation.Tag);
Assert.Equal(SqlServerContainerImageTags.Digest, containerAnnotation.SHA256);
Assert.Equal(SqlServerContainerImageTags.Image, containerAnnotation.Image);
Assert.Equal(SqlServerContainerImageTags.Registry, containerAnnotation.Registry);

Expand Down Expand Up @@ -135,7 +135,7 @@ public async Task VerifyManifest()
{
"type": "container.v0",
"connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={sqlserver-password.value};TrustServerCertificate=true",
"image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}:{{SqlServerContainerImageTags.Tag}}",
"image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}@{{SqlServerContainerImageTags.Digest}}",
"env": {
"ACCEPT_EULA": "Y",
"MSSQL_SA_PASSWORD": "{sqlserver-password.value}"
Expand Down Expand Up @@ -175,7 +175,7 @@ public async Task VerifyManifestWithPasswordParameter()
{
"type": "container.v0",
"connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={pass.value};TrustServerCertificate=true",
"image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}:{{SqlServerContainerImageTags.Tag}}",
"image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}@{{SqlServerContainerImageTags.Digest}}",
"env": {
"ACCEPT_EULA": "Y",
"MSSQL_SA_PASSWORD": "{pass.value}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public async Task InitializeAsync()
if (RequiresDockerAttribute.IsSupported)
{
Container = new MsSqlBuilder()
.WithImage($"{SqlServerContainerImageTags.Registry}/{SqlServerContainerImageTags.Image}:{SqlServerContainerImageTags.Tag}")
.WithImage($"{SqlServerContainerImageTags.Registry}/{SqlServerContainerImageTags.Image}@{SqlServerContainerImageTags.Digest}")
.Build();
await Container.StartAsync();
}
Expand Down