Skip to content

Commit 0ae9c5d

Browse files
committed
Vendor ctrd v2.1.0 and update CIs to WS2022,WS2025
Signed-off-by: Kirtana Ashok <[email protected]>
1 parent 7135484 commit 0ae9c5d

File tree

411 files changed

+18391
-8519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

411 files changed

+18391
-8519
lines changed

.github/workflows/ci.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,12 @@ jobs:
273273
fail-fast: false
274274
matrix:
275275
name:
276-
[windows-2022, windows-2019]
276+
[windows-2025, windows-2022]
277277
include:
278-
- name: "windows-2019"
279-
runner: [self-hosted, 1ES.Pool=containerplat-github-runner-pool-east-us-2, 1ES.ImageOverride=github-mms-ws2019-containers-enabled]
280278
- name: "windows-2022"
281279
runner: [self-hosted, 1ES.Pool=containerplat-github-runner-pool-east-us-2, 1ES.ImageOverride=github-mms-ws2022-containers-enabled]
280+
- name: "windows-2025"
281+
runner: [self-hosted, 1ES.Pool=containerplat-github-runner-pool-east-us-2, 1ES.ImageOverride=github-ws2025-containers-enabled]
282282
steps:
283283
- name: Checkout
284284
uses: actions/checkout@v4
@@ -313,7 +313,7 @@ jobs:
313313
}
314314
315315
# accept the eula
316-
& '${{ github.workspace }}/bin/psexec' -accepteula -nobanner cmd /c "exit 0" 2>$null
316+
& '${{ github.workspace }}/bin/psexec' -accepteula -nobanner cmd /c "exit 0"
317317
318318
# run tests
319319
- name: Test repo
@@ -326,10 +326,10 @@ jobs:
326326
- name: Build and run containerd-shim-runhcs-v1 tests
327327
shell: powershell
328328
run: |
329-
pwsh {
330-
cd '..'
331-
${{ env.GO_BUILD_CMD }} -o ./test ./cmd/containerd-shim-runhcs-v1 2>&1
332-
}
329+
Push-Location '..'
330+
${{ env.GO_BUILD_CMD }} -o ./test ./cmd/containerd-shim-runhcs-v1 2>&1
331+
Pop-Location
332+
333333
if ( $LASTEXITCODE ) {
334334
Write-Output '::error::Could not build containerd-shim-runhcs-v1.exe'
335335
exit $LASTEXITCODE
@@ -360,9 +360,18 @@ jobs:
360360
exit $LASTEXITCODE
361361
}
362362
363+
# Resolve go.exe path
364+
$go = Get-Command -Name 'go' -CommandType Application -ErrorAction Stop |
365+
Select-Object -First 1 -ExpandProperty Source
366+
if ([string]::IsNullOrEmpty($go)) {
367+
Write-Output '::error::Could not find go.exe path'
368+
exit 1
369+
}
370+
363371
# Don't run Linux uVM (ie, nested virt) or LCOW integrity tests. Windows uVM tests will be run on 1ES runner pool.
364372
$cmd = '${{ env.GOTESTSUM_CMD_RAW }} ./functional.test.exe -exclude=LCOW,LCOWIntegrity -test.timeout=1h -test.v -log-level=info'
365-
$cmd = $cmd -replace 'gotestsum', $gotestsum
373+
$cmd = $cmd -replace '\bgo\b', $go
374+
$cmd = $cmd -replace '\bgotestsum\b', $gotestsum
366375
Write-Host "gotestsum command: $cmd"
367376
368377
# Apparently, in a GH runner, PsExec always runs noninteractively (even with `-i`)
@@ -404,7 +413,7 @@ jobs:
404413
strategy:
405414
fail-fast: false
406415
matrix:
407-
os: [windows-2019, windows-2022]
416+
os: [windows-2022, windows-2025]
408417

409418
steps:
410419
- name: Checkout hcsshim
@@ -429,7 +438,7 @@ jobs:
429438
- name: Get containerd ref
430439
shell: powershell
431440
run: |
432-
$v = go list -m -f '{{ .Version }}' 'github.com/containerd/containerd' 2>&1
441+
$v = go list -m -f '{{ .Version }}' 'github.com/containerd/containerd/v2' 2>&1
433442
if ( $LASTEXITCODE ) {
434443
Write-Output '::error::Could not retrieve containerd version.'
435444
exit $LASTEXITCODE

cmd/containerd-shim-runhcs-v1/events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"fmt"
88

99
"github.com/Microsoft/hcsshim/internal/oc"
10-
"github.com/containerd/containerd/namespaces"
11-
shim "github.com/containerd/containerd/runtime/v2/shim"
10+
"github.com/containerd/containerd/v2/pkg/namespaces"
11+
"github.com/containerd/containerd/v2/pkg/shim"
1212
"go.opencensus.io/trace"
1313
)
1414

cmd/containerd-shim-runhcs-v1/exec_hcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
eventstypes "github.com/containerd/containerd/api/events"
1111
task "github.com/containerd/containerd/api/runtime/task/v2"
1212
containerd_v1_types "github.com/containerd/containerd/api/types/task"
13-
"github.com/containerd/containerd/runtime"
13+
"github.com/containerd/containerd/v2/core/runtime"
1414
"github.com/containerd/errdefs"
1515
"github.com/opencontainers/runtime-spec/specs-go"
1616
"github.com/pkg/errors"

cmd/containerd-shim-runhcs-v1/exec_wcow_podsandbox.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
eventstypes "github.com/containerd/containerd/api/events"
1212
task "github.com/containerd/containerd/api/runtime/task/v2"
1313
containerd_v1_types "github.com/containerd/containerd/api/types/task"
14-
"github.com/containerd/containerd/runtime"
14+
"github.com/containerd/containerd/v2/core/runtime"
1515
"github.com/containerd/errdefs"
1616
"github.com/pkg/errors"
1717
"github.com/sirupsen/logrus"

cmd/containerd-shim-runhcs-v1/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
hcsversion "github.com/Microsoft/hcsshim/internal/version"
2525

2626
// register common types spec with typeurl
27-
_ "github.com/containerd/containerd/runtime"
27+
_ "github.com/containerd/containerd/v2/core/runtime"
2828
)
2929

3030
const usage = ``

cmd/containerd-shim-runhcs-v1/pod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/Microsoft/hcsshim/pkg/annotations"
1919
eventstypes "github.com/containerd/containerd/api/events"
2020
task "github.com/containerd/containerd/api/runtime/task/v2"
21-
"github.com/containerd/containerd/runtime"
21+
"github.com/containerd/containerd/v2/core/runtime"
2222
"github.com/containerd/errdefs"
2323
"github.com/opencontainers/runtime-spec/specs-go"
2424
"github.com/pkg/errors"

cmd/containerd-shim-runhcs-v1/service_internal.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
task "github.com/containerd/containerd/api/runtime/task/v2"
1313
containerd_v1_types "github.com/containerd/containerd/api/types/task"
14-
"github.com/containerd/containerd/protobuf"
1514
"github.com/containerd/errdefs"
1615
typeurl "github.com/containerd/typeurl/v2"
1716
"github.com/opencontainers/runtime-spec/specs-go"
@@ -231,7 +230,7 @@ func (s *service) pidsInternal(ctx context.Context, req *task.PidsRequest) (*tas
231230
}
232231
proc := &containerd_v1_types.ProcessInfo{
233232
Pid: p.ProcessID,
234-
Info: protobuf.FromAny(a),
233+
Info: typeurl.MarshalProto(a),
235234
}
236235
processes[i] = proc
237236
}
@@ -478,7 +477,7 @@ func (s *service) statsInternal(ctx context.Context, req *task.StatsRequest) (*t
478477
if err != nil {
479478
return nil, errors.Wrapf(err, "failed to marshal Statistics for task: %s", req.ID)
480479
}
481-
return &task.StatsResponse{Stats: protobuf.FromAny(any)}, nil
480+
return &task.StatsResponse{Stats: typeurl.MarshalProto(any)}, nil
482481
}
483482

484483
func (s *service) connectInternal(ctx context.Context, req *task.ConnectRequest) (*task.ConnectResponse, error) {

cmd/containerd-shim-runhcs-v1/service_internal_podshim_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
1515
"github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats"
1616
task "github.com/containerd/containerd/api/runtime/task/v2"
17-
"github.com/containerd/containerd/protobuf"
1817
"github.com/containerd/errdefs"
1918
typeurl "github.com/containerd/typeurl/v2"
2019
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -607,7 +606,12 @@ func Test_PodShim_updateInternal_Success(t *testing.T) {
607606
t.Fatal(err)
608607
}
609608

610-
resp, err := s.updateInternal(context.TODO(), &task.UpdateTaskRequest{ID: t1.ID(), Resources: protobuf.FromAny(any)})
609+
resp, err := s.updateInternal(
610+
context.TODO(),
611+
&task.UpdateTaskRequest{
612+
ID: t1.ID(),
613+
Resources: typeurl.MarshalProto(any),
614+
})
611615
if err != nil {
612616
t.Fatalf("should not have failed with error, got: %v", err)
613617
}
@@ -625,7 +629,13 @@ func Test_PodShim_updateInternal_Error(t *testing.T) {
625629
if err != nil {
626630
t.Fatal(err)
627631
}
628-
_, err = s.updateInternal(context.TODO(), &task.UpdateTaskRequest{ID: t1.ID(), Resources: protobuf.FromAny(any)})
632+
633+
_, err = s.updateInternal(
634+
context.TODO(),
635+
&task.UpdateTaskRequest{
636+
ID: t1.ID(),
637+
Resources: typeurl.MarshalProto(any),
638+
})
629639
if err == nil {
630640
t.Fatal("expected to get an error for incorrect resource's type")
631641
}

cmd/containerd-shim-runhcs-v1/service_internal_taskshim_test.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/Microsoft/hcsshim/internal/hcsoci"
1919
"github.com/Microsoft/hcsshim/pkg/ctrdtaskapi"
2020
task "github.com/containerd/containerd/api/runtime/task/v2"
21-
"github.com/containerd/containerd/protobuf"
2221
"github.com/containerd/errdefs"
2322
typeurl "github.com/containerd/typeurl/v2"
2423
"github.com/opencontainers/runtime-spec/specs-go"
@@ -527,12 +526,18 @@ func Test_TaskShim_updateInternal_Success(t *testing.T) {
527526
},
528527
}
529528

530-
any, err := typeurl.MarshalAny(resources)
529+
resourcesTypeURL, _ := typeurl.MarshalAny(resources)
530+
any, err := typeurl.MarshalAny(resourcesTypeURL)
531531
if err != nil {
532532
t.Fatal(err)
533533
}
534534

535-
resp, err := s.updateInternal(context.TODO(), &task.UpdateTaskRequest{ID: t1.ID(), Resources: protobuf.FromAny(any)})
535+
resp, err := s.updateInternal(
536+
context.TODO(),
537+
&task.UpdateTaskRequest{
538+
ID: t1.ID(),
539+
Resources: typeurl.MarshalProto(any),
540+
})
536541
if err != nil {
537542
t.Fatalf("should not have failed with error, got: %v", err)
538543
}
@@ -563,7 +568,12 @@ func Test_TaskShimWindowsMount_updateInternal_Success(t *testing.T) {
563568
t.Fatal(err)
564569
}
565570

566-
resp, err := s.updateInternal(context.TODO(), &task.UpdateTaskRequest{ID: t1.ID(), Resources: protobuf.FromAny(any)})
571+
resp, err := s.updateInternal(
572+
context.TODO(),
573+
&task.UpdateTaskRequest{
574+
ID: t1.ID(),
575+
Resources: typeurl.MarshalProto(any),
576+
})
567577
if err != nil {
568578
t.Fatalf("should not have failed update mount with error, got: %v", err)
569579
}
@@ -593,7 +603,12 @@ func Test_TaskShimWindowsMount_updateInternal_Error(t *testing.T) {
593603
t.Fatal(err)
594604
}
595605

596-
resp, err := s.updateInternal(context.TODO(), &task.UpdateTaskRequest{ID: t1.ID(), Resources: protobuf.FromAny(any)})
606+
resp, err := s.updateInternal(
607+
context.TODO(),
608+
&task.UpdateTaskRequest{
609+
ID: t1.ID(),
610+
Resources: typeurl.MarshalProto(any),
611+
})
597612
if err == nil {
598613
t.Fatalf("should have failed update mount with error")
599614
}
@@ -612,7 +627,10 @@ func Test_TaskShim_updateInternal_Error(t *testing.T) {
612627
t.Fatal(err)
613628
}
614629

615-
_, err = s.updateInternal(context.TODO(), &task.UpdateTaskRequest{ID: t1.ID(), Resources: protobuf.FromAny(any)})
630+
_, err = s.updateInternal(context.TODO(), &task.UpdateTaskRequest{
631+
ID: t1.ID(),
632+
Resources: typeurl.MarshalProto(any),
633+
})
616634
if err == nil {
617635
t.Fatal("expected to get an error for incorrect resource's type")
618636
}

cmd/containerd-shim-runhcs-v1/start.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
"github.com/Microsoft/hcsshim/internal/oci"
1616
"github.com/Microsoft/hcsshim/pkg/annotations"
1717
task "github.com/containerd/containerd/api/runtime/task/v2"
18-
"github.com/containerd/containerd/runtime/v2/shim"
18+
"github.com/containerd/containerd/v2/pkg/atomicfile"
19+
"github.com/containerd/containerd/v2/pkg/shim"
1920
"github.com/containerd/ttrpc"
2021
"github.com/pkg/errors"
2122
"github.com/sirupsen/logrus"
@@ -171,7 +172,7 @@ The start command can either start a new shim or return an address to an existin
171172
if err := shim.WritePidFile(filepath.Join(cwd, "shim.pid"), pid); err != nil {
172173
return err
173174
}
174-
if err := shim.WriteAddress(filepath.Join(cwd, "address"), address); err != nil {
175+
if err := writeAddress(filepath.Join(cwd, "address"), address); err != nil {
175176
return err
176177
}
177178

@@ -183,6 +184,24 @@ The start command can either start a new shim or return an address to an existin
183184
},
184185
}
185186

187+
// writeAddress writes an address file atomically
188+
func writeAddress(path, address string) error {
189+
path, err := filepath.Abs(path)
190+
if err != nil {
191+
return err
192+
}
193+
f, err := atomicfile.New(path, 0o644)
194+
if err != nil {
195+
return err
196+
}
197+
_, err = f.Write([]byte(address))
198+
if err != nil {
199+
_ = f.Cancel()
200+
return err
201+
}
202+
return f.Close()
203+
}
204+
186205
func getSpecAnnotations(bundlePath string) (map[string]string, error) {
187206
// specAnnotations is a minimal representation for oci.Spec that we need
188207
// to serve a shim.

0 commit comments

Comments
 (0)