Skip to content

Commit 99fc25a

Browse files
committed
pkg/deviceplugin: do not reset Envs/Annotations from previous loops
When more than one device ID is Allocate()'d to a container, Envs/Annotations for all but the last device ID get lost because their cresp.* maps are (re-)instantiated on each loop. Fix it by doing that only once. Fixes: 55f3e17 Signed-off-by: Mikko Ylinen <[email protected]>
1 parent fd67c5c commit 99fc25a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/deviceplugin/server.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,17 @@ func (srv *server) Allocate(ctx context.Context, rqt *pluginapi.AllocateRequest)
161161
cresp.Mounts = append(cresp.Mounts, &dev.mounts[i])
162162
}
163163

164-
cresp.Envs = map[string]string{}
164+
if cresp.Envs == nil {
165+
cresp.Envs = map[string]string{}
166+
}
165167

166168
for key, value := range dev.envs {
167169
cresp.Envs[key] = value
168170
}
169171

170-
cresp.Annotations = map[string]string{}
172+
if cresp.Annotations == nil {
173+
cresp.Annotations = map[string]string{}
174+
}
171175

172176
for key, value := range dev.annotations {
173177
cresp.Annotations[key] = value

0 commit comments

Comments
 (0)