@@ -22,6 +22,8 @@ import (
22
22
"fmt"
23
23
goruntime "runtime"
24
24
25
+ "github.com/containerd/containerd/v2/api/services/introspection/v1"
26
+ ptypes "github.com/containerd/containerd/v2/protobuf/types"
25
27
"github.com/containerd/log"
26
28
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
27
29
)
@@ -94,5 +96,51 @@ func (c *criService) Status(ctx context.Context, r *runtime.StatusRequest) (*run
94
96
}
95
97
resp .Info ["lastCNILoadStatus" ] = defaultStatus
96
98
}
99
+ intro , err := c .client .IntrospectionService ().Server (ctx , & ptypes.Empty {})
100
+ if err != nil {
101
+ return nil , err
102
+ }
103
+ cond , err := runtimeConditionContainerdHasNoDeprecationWarnings (intro .Deprecations , c .config .IgnoreDeprecationWarnings )
104
+ if err != nil {
105
+ return nil , err
106
+ }
107
+ resp .Status .Conditions = append (resp .Status .Conditions , cond )
97
108
return resp , nil
98
109
}
110
+
111
+ func runtimeConditionContainerdHasNoDeprecationWarnings (deprecations []* introspection.DeprecationWarning , ignore []string ) (* runtime.RuntimeCondition , error ) {
112
+ cond := & runtime.RuntimeCondition {
113
+ Type : ContainerdHasNoDeprecationWarnings ,
114
+ Status : true ,
115
+ }
116
+ ignoreM := make (map [string ]struct {})
117
+ for _ , f := range ignore {
118
+ ignoreM [f ] = struct {}{}
119
+ }
120
+ messages := make (map [string ]string ) // key: id, value: message
121
+ for _ , d := range deprecations {
122
+ if _ , ok := ignoreM [d .ID ]; ! ok {
123
+ messages [d .ID ] = d .Message
124
+ }
125
+ }
126
+ if len (messages ) > 0 {
127
+ cond .Status = false
128
+ cond .Reason = ContainerdHasDeprecationWarnings
129
+ messageJ , err := json .Marshal (messages )
130
+ if err != nil {
131
+ return nil , err
132
+ }
133
+ cond .Message = string (messageJ ) // Arbitrary string
134
+ }
135
+ return cond , nil
136
+ }
137
+
138
+ const (
139
+ // ContainerdHasNoDeprecationWarnings is a string for [runtime.RuntimeCondition.Type].
140
+ ContainerdHasNoDeprecationWarnings = "ContainerdHasNoDeprecationWarnings"
141
+
142
+ // ContainerdHasDeprecationWarnings is a string for [runtime.RuntimeCondition.Reason].
143
+ // CamelCase is demanded by the spec.
144
+ // https://github.com/kubernetes/cri-api/blob/v0.29.1/pkg/apis/runtime/v1/api.proto#L1514
145
+ ContainerdHasDeprecationWarnings = "ContainerdHasDeprecationWarnings"
146
+ )
0 commit comments