Skip to content

Commit 6b5473d

Browse files
authored
Merge pull request #3682 from xrstf/fix-panic-mapper
fix concurrent map read access and write panic
2 parents e9d9d41 + c564fb4 commit 6b5473d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/reconciler/dynamicrestmapper/dynamicrestmapper_builtin_controller.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ func (c *BuiltinTypesController) process(ctx context.Context, key string) error
227227
return err
228228
}
229229

230+
c.state.lock.Lock()
231+
defer c.state.lock.Unlock()
232+
230233
// Remove and add the mapping -- this way we can refresh any existing mappings.
231234
typeMetaToRemove, err := c.gatherGVKRsForMappedGroupResource(gr)
232235
if err != nil {
@@ -236,8 +239,6 @@ func (c *BuiltinTypesController) process(ctx context.Context, key string) error
236239

237240
logger.V(4).Info("applying mappings")
238241

239-
c.state.lock.Lock()
240-
defer c.state.lock.Unlock()
241242
c.state.builtin.apply(typeMetaToRemove, typeMetaToAdd)
242243
return nil
243244
}

0 commit comments

Comments
 (0)