Commit 1eb04f6a authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

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**: none
parents d958a35a d4b41afe
...@@ -67,13 +67,15 @@ func (ps *Plugins) Registered() []string { ...@@ -67,13 +67,15 @@ func (ps *Plugins) Registered() []string {
func (ps *Plugins) Register(name string, plugin Factory) { func (ps *Plugins) Register(name string, plugin Factory) {
ps.lock.Lock() ps.lock.Lock()
defer ps.lock.Unlock() defer ps.lock.Unlock()
_, found := ps.registry[name] if ps.registry != nil {
if found { _, found := ps.registry[name]
glog.Fatalf("Admission plugin %q was registered twice", name) if found {
} glog.Fatalf("Admission plugin %q was registered twice", name)
if ps.registry == nil { }
} else {
ps.registry = map[string]Factory{} ps.registry = map[string]Factory{}
} }
glog.V(1).Infof("Registered admission plugin %q", name) glog.V(1).Infof("Registered admission plugin %q", name)
ps.registry[name] = plugin ps.registry[name] = plugin
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment