@@ -12,6 +12,7 @@ import (
12
12
"path/filepath"
13
13
"strings"
14
14
15
+ semver "github.com/Masterminds/semver/v3"
15
16
"github.com/containerd/containerd"
16
17
eventtypes "github.com/containerd/containerd/api/events"
17
18
"github.com/containerd/containerd/content"
@@ -79,6 +80,7 @@ func (c *Containerd) Name() string {
79
80
}
80
81
81
82
func (c * Containerd ) Verify (ctx context.Context ) error {
83
+ log := logr .FromContextOrDiscard (ctx )
82
84
client , err := c .Client ()
83
85
if err != nil {
84
86
return err
@@ -90,11 +92,30 @@ func (c *Containerd) Verify(ctx context.Context) error {
90
92
if ! ok {
91
93
return errors .New ("could not reach Containerd service" )
92
94
}
93
- resp , err := runtimeapi .NewRuntimeServiceClient (client .Conn ()).Status (ctx , & runtimeapi.StatusRequest {Verbose : true })
95
+ srv := runtimeapi .NewRuntimeServiceClient (client .Conn ())
96
+ versionResp , err := srv .Version (ctx , & runtimeapi.VersionRequest {})
97
+ if err != nil {
98
+ return err
99
+ }
100
+
101
+ version , err := semver .NewVersion (versionResp .GetRuntimeVersion ())
102
+ if err != nil {
103
+ return err
104
+ }
105
+ constraint , err := semver .NewConstraint (">1-0" )
106
+ if err != nil {
107
+ return err
108
+ }
109
+ if constraint .Check (version ) {
110
+ log .Info ("unable to verify status response for containerd version" , "version" , version .String ())
111
+ return nil
112
+ }
113
+
114
+ statusResp , err := srv .Status (ctx , & runtimeapi.StatusRequest {Verbose : true })
94
115
if err != nil {
95
116
return err
96
117
}
97
- err = verifyStatusResponse (resp , c .registryConfigPath )
118
+ err = verifyStatusResponse (statusResp , c .registryConfigPath )
98
119
if err != nil {
99
120
return err
100
121
}
0 commit comments