@@ -66,14 +66,9 @@ func (d *draDependency) Setup(config *dependency.Config) error {
66
66
namespace = draNamespace
67
67
}
68
68
69
- workerCount , ok := config .Params ["WorkerNodeCount" ]
70
- if ! ok {
71
- workerCount = defaultWorkerNodeCount
72
- }
73
-
74
69
mapping := map [string ]interface {}{
75
70
"Namespace" : namespace ,
76
- "WorkerNodeCount" : workerCount ,
71
+ "WorkerNodeCount" : getWorkerCount ( config ) ,
77
72
}
78
73
if err := config .ClusterFramework .ApplyTemplatedManifests (
79
74
manifestsFS ,
@@ -113,12 +108,23 @@ func (d *draDependency) Teardown(config *dependency.Config) error {
113
108
}
114
109
115
110
func (d * draDependency ) waitForDRADriverToBeHealthy (config * dependency.Config , timeout time.Duration ) error {
116
- return wait .PollImmediate (
111
+ if err := wait .PollImmediate (
117
112
checkDRAReadyInterval ,
118
113
timeout ,
119
114
func () (done bool , err error ) {
120
115
return d .isDRADriverReady (config )
121
- })
116
+ }); err != nil {
117
+ return err
118
+ }
119
+ if err := wait .PollImmediate (
120
+ checkDRAReadyInterval ,
121
+ timeout ,
122
+ func () (done bool , err error ) {
123
+ return isResourceSlicesPublished (config )
124
+ }); err != nil {
125
+ return err
126
+ }
127
+ return nil
122
128
}
123
129
124
130
func (d * draDependency ) isDRADriverReady (config * dependency.Config ) (done bool , err error ) {
@@ -138,6 +144,29 @@ func (d *draDependency) isDRADriverReady(config *dependency.Config) (done bool,
138
144
return ready , nil
139
145
}
140
146
147
+ func isResourceSlicesPublished (config * dependency.Config ) (bool , error ) {
148
+ workerCount := int (getWorkerCount (config ).(float64 ))
149
+
150
+ resourceSlices , err := config .ClusterFramework .GetClientSets ().GetClient ().ResourceV1beta1 ().ResourceSlices ().List (context .Background (), metav1.ListOptions {})
151
+ if err != nil {
152
+ return false , fmt .Errorf ("failed to list resourceslices: %v" , err )
153
+ }
154
+ if len (resourceSlices .Items ) != workerCount {
155
+ klog .V (2 ).Infof ("waiting for resourceslices to be available, " +
156
+ "DesiredResourceSliceCount: %d, NumberResourceSlicesAvailable: %d" , workerCount , len (resourceSlices .Items ))
157
+ return false , nil
158
+ }
159
+ return true , nil
160
+ }
161
+
162
+ func getWorkerCount (config * dependency.Config ) interface {} {
163
+ workerCount , ok := config .Params ["WorkerNodeCount" ]
164
+ if ! ok {
165
+ workerCount = defaultWorkerNodeCount
166
+ }
167
+ return workerCount
168
+ }
169
+
141
170
// String returns string representation of this dependency.
142
171
func (d * draDependency ) String () string {
143
172
return draDependencyName
0 commit comments