@@ -169,6 +169,8 @@ var _ = g.Describe("[sig-node][apigroup:config.openshift.io] CPU Partitioning no
169169 nodeRoleCPUSet , err := getExpectedCPUSetConstraints (ctx , oc , isClusterCPUPartitioned )
170170 o .Expect (err ).ToNot (o .HaveOccurred (), "error getting node CPUSets" )
171171
172+ var validationErrors []string
173+
172174 for _ , node := range nodes .Items {
173175 // Collect the container data from the node
174176 crioData , err := collectContainerInfo (ctx , oc , node , isClusterCPUPartitioned )
@@ -204,32 +206,55 @@ var _ = g.Describe("[sig-node][apigroup:config.openshift.io] CPU Partitioning no
204206 for _ , containerInfo := range crioData {
205207 failLocation := fmt .Sprintf ("node: %s pod: %s/%s container: %s" , node .Name , containerInfo .PodNamespace , containerInfo .PodName , containerInfo .Name )
206208 parsedContainer , err := cpuset .Parse (containerInfo .CPUSet )
207- o .Expect (err ).ToNot (o .HaveOccurred (), fmt .Sprintf ("%s | error parsing crio container cpuset %s" , failLocation , containerInfo .CPUSet ))
209+ if err != nil {
210+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | error parsing crio container cpuset %s: %v" , failLocation , containerInfo .CPUSet , err ))
211+ continue
212+ }
208213 parsedHost , err := cpuset .Parse (containerInfo .HostCPUSet )
209- o .Expect (err ).ToNot (o .HaveOccurred (), fmt .Sprintf ("%s | error parsing host cpuset %s" , failLocation , containerInfo .HostCPUSet ))
214+ if err != nil {
215+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | error parsing host cpuset %s: %v" , failLocation , containerInfo .HostCPUSet , err ))
216+ continue
217+ }
210218
211- o .Expect (parsedContainer .Equals (expectedCPUSet )).To (o .BeTrue (), "cpusets do not match between container and desired" )
219+ if ! parsedContainer .Equals (expectedCPUSet ) {
220+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | cpuset mismatch: expected %s got %s" , failLocation , expectedCPUSet , parsedContainer ))
221+ }
212222
213223 // Empty CPUSets mean wide open, so we check the processes are not being limited.
214224 // If the expected CPUSet is not empty, we make sure the host is respecting it.
215225 if expectedCPUSet .IsEmpty () {
216- o .Expect (parsedHost .Equals (parsedFullNodeCPUSet )).To (o .BeTrue (), fmt .Sprintf ("%s | expected container pid CPUset to be: %s but got: %s" , failLocation , parsedFullNodeCPUSet , parsedHost ))
226+ if ! parsedHost .Equals (parsedFullNodeCPUSet ) {
227+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | expected container pid CPUSet: %s but got: %s" , failLocation , parsedFullNodeCPUSet , parsedHost ))
228+ }
217229 } else {
218- o .Expect (parsedContainer .Equals (parsedHost )).To (o .BeTrue (), fmt .Sprintf ("%s | expected container pid CPUset to be: %s got: %s" , failLocation , parsedHost , parsedContainer ))
230+ if ! parsedContainer .Equals (parsedHost ) {
231+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | expected container pid CPUSet to be: %s got: %s" , failLocation , parsedHost , parsedContainer ))
232+ }
219233 }
220234
221235 // If we are in a CPU Partitioned cluster, containers MUST be annotated with the correct CPU Share at the CRIO level
222236 // and the desired annotation cpu shares must equal the crio config cpu shares
223237 if isClusterCPUPartitioned {
224238 resource , err := containerInfo .getAnnotationCPUResources ()
225- o .Expect (err ).ToNot (o .HaveOccurred (), fmt .Sprintf ("%s | failed to get container resource annotation json" , failLocation ), err )
226- o .Expect (resource .CPUShares ).To (o .Equal (containerInfo .CPUShares ), fmt .Sprintf ("%s | cpushares do not match between crio config and desired" , failLocation ))
239+ if err != nil {
240+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | failed to get container resource annotation json: %v" , failLocation , err ))
241+ continue
242+ }
243+ if resource .CPUShares != containerInfo .CPUShares {
244+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | CPUShares mismatch between annotation (%d) and CRIO config (%d)" , failLocation , resource .CPUShares , containerInfo .CPUShares ))
245+ }
227246
228247 desiredCPUQuota := milliCPUToQuota (resource .CPULimit , containerInfo .CPUPeriod )
229- o .Expect (desiredCPUQuota ).To (o .Equal (containerInfo .CPUQuota ), fmt .Sprintf ("%s | cpuquota do not match between crio config and desired" , failLocation ))
248+ if desiredCPUQuota != containerInfo .CPUQuota {
249+ validationErrors = append (validationErrors , fmt .Sprintf ("%s | CPUQuota mismatch between desired (%d) and CRIO config (%d)" , failLocation , desiredCPUQuota , containerInfo .CPUQuota ))
250+ }
230251 }
231252 }
232253 }
254+
255+ if len (validationErrors ) > 0 {
256+ o .Expect (validationErrors ).To (o .BeEmpty (), fmt .Sprintf ("CRIO containers failed validation:\n %s" , strings .Join (validationErrors , "\n " )))
257+ }
233258 })
234259})
235260
0 commit comments