mirror of https://github.com/k3s-io/k3s
Merge pull request #50852 from guangxuli/fix_apiserver_register
Automatic merge from submit-queue (batch tested with PRs 50281, 50747, 50347, 50834, 50852) fix incorrect logic in admission register **What this PR does / why we need it**: There is no issue for this PR, just fix incorrect logic in invocation `func (ps *Plugins) Register(name string, plugin Factory) ` after browsing the code accidentally. And apparently, the logic exits potential panic. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # no issue **Special notes for your reviewer**: none **Release note**: nonepull/6/head
commit
1eb04f6a2a
|
@ -67,13 +67,15 @@ func (ps *Plugins) Registered() []string {
|
|||
func (ps *Plugins) Register(name string, plugin Factory) {
|
||||
ps.lock.Lock()
|
||||
defer ps.lock.Unlock()
|
||||
_, found := ps.registry[name]
|
||||
if found {
|
||||
glog.Fatalf("Admission plugin %q was registered twice", name)
|
||||
}
|
||||
if ps.registry == nil {
|
||||
if ps.registry != nil {
|
||||
_, found := ps.registry[name]
|
||||
if found {
|
||||
glog.Fatalf("Admission plugin %q was registered twice", name)
|
||||
}
|
||||
} else {
|
||||
ps.registry = map[string]Factory{}
|
||||
}
|
||||
|
||||
glog.V(1).Infof("Registered admission plugin %q", name)
|
||||
ps.registry[name] = plugin
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue