mirror of https://github.com/k3s-io/k3s
Merge pull request #59082 from WanLinghao/package_name_fix
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix package name error 1.priority admission file got wrong package name 2.PriorityPlugin struct should not be public as well as its construct function. this patch fix this. **What this PR does / why we need it**: **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```pull/6/head
commit
f351d8cddb
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package admission
|
||||
package priority
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -43,12 +43,12 @@ const (
|
|||
// Register registers a plugin
|
||||
func Register(plugins *admission.Plugins) {
|
||||
plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) {
|
||||
return NewPlugin(), nil
|
||||
return newPlugin(), nil
|
||||
})
|
||||
}
|
||||
|
||||
// PriorityPlugin is an implementation of admission.Interface.
|
||||
type PriorityPlugin struct {
|
||||
// priorityPlugin is an implementation of admission.Interface.
|
||||
type priorityPlugin struct {
|
||||
*admission.Handler
|
||||
client internalclientset.Interface
|
||||
lister schedulinglisters.PriorityClassLister
|
||||
|
@ -56,20 +56,20 @@ type PriorityPlugin struct {
|
|||
globalDefaultPriority *int32
|
||||
}
|
||||
|
||||
var _ admission.MutationInterface = &PriorityPlugin{}
|
||||
var _ admission.ValidationInterface = &PriorityPlugin{}
|
||||
var _ = kubeapiserveradmission.WantsInternalKubeInformerFactory(&PriorityPlugin{})
|
||||
var _ = kubeapiserveradmission.WantsInternalKubeClientSet(&PriorityPlugin{})
|
||||
var _ admission.MutationInterface = &priorityPlugin{}
|
||||
var _ admission.ValidationInterface = &priorityPlugin{}
|
||||
var _ = kubeapiserveradmission.WantsInternalKubeInformerFactory(&priorityPlugin{})
|
||||
var _ = kubeapiserveradmission.WantsInternalKubeClientSet(&priorityPlugin{})
|
||||
|
||||
// NewPlugin creates a new priority admission plugin.
|
||||
func NewPlugin() *PriorityPlugin {
|
||||
return &PriorityPlugin{
|
||||
func newPlugin() *priorityPlugin {
|
||||
return &priorityPlugin{
|
||||
Handler: admission.NewHandler(admission.Create, admission.Update, admission.Delete),
|
||||
}
|
||||
}
|
||||
|
||||
// ValidateInitialization implements the InitializationValidator interface.
|
||||
func (p *PriorityPlugin) ValidateInitialization() error {
|
||||
func (p *priorityPlugin) ValidateInitialization() error {
|
||||
if p.client == nil {
|
||||
return fmt.Errorf("%s requires a client", PluginName)
|
||||
}
|
||||
|
@ -80,12 +80,12 @@ func (p *PriorityPlugin) ValidateInitialization() error {
|
|||
}
|
||||
|
||||
// SetInternalKubeClientSet implements the WantsInternalKubeClientSet interface.
|
||||
func (p *PriorityPlugin) SetInternalKubeClientSet(client internalclientset.Interface) {
|
||||
func (p *priorityPlugin) SetInternalKubeClientSet(client internalclientset.Interface) {
|
||||
p.client = client
|
||||
}
|
||||
|
||||
// SetInternalKubeInformerFactory implements the WantsInternalKubeInformerFactory interface.
|
||||
func (p *PriorityPlugin) SetInternalKubeInformerFactory(f informers.SharedInformerFactory) {
|
||||
func (p *priorityPlugin) SetInternalKubeInformerFactory(f informers.SharedInformerFactory) {
|
||||
priorityInformer := f.Scheduling().InternalVersion().PriorityClasses()
|
||||
p.lister = priorityInformer.Lister()
|
||||
p.SetReadyFunc(priorityInformer.Informer().HasSynced)
|
||||
|
@ -98,7 +98,7 @@ var (
|
|||
|
||||
// Admit checks Pods and admits or rejects them. It also resolves the priority of pods based on their PriorityClass.
|
||||
// Note that pod validation mechanism prevents update of a pod priority.
|
||||
func (p *PriorityPlugin) Admit(a admission.Attributes) error {
|
||||
func (p *priorityPlugin) Admit(a admission.Attributes) error {
|
||||
operation := a.GetOperation()
|
||||
// Ignore all calls to subresources
|
||||
if len(a.GetSubresource()) != 0 {
|
||||
|
@ -118,7 +118,7 @@ func (p *PriorityPlugin) Admit(a admission.Attributes) error {
|
|||
}
|
||||
|
||||
// Validate checks PriorityClasses and admits or rejects them.
|
||||
func (p *PriorityPlugin) Validate(a admission.Attributes) error {
|
||||
func (p *priorityPlugin) Validate(a admission.Attributes) error {
|
||||
operation := a.GetOperation()
|
||||
// Ignore all calls to subresources
|
||||
if len(a.GetSubresource()) != 0 {
|
||||
|
@ -142,7 +142,7 @@ func (p *PriorityPlugin) Validate(a admission.Attributes) error {
|
|||
}
|
||||
|
||||
// admitPod makes sure a new pod does not set spec.Priority field. It also makes sure that the PriorityClassName exists if it is provided and resolves the pod priority from the PriorityClassName.
|
||||
func (p *PriorityPlugin) admitPod(a admission.Attributes) error {
|
||||
func (p *priorityPlugin) admitPod(a admission.Attributes) error {
|
||||
operation := a.GetOperation()
|
||||
pod, ok := a.GetObject().(*api.Pod)
|
||||
if !ok {
|
||||
|
@ -192,7 +192,7 @@ func (p *PriorityPlugin) admitPod(a admission.Attributes) error {
|
|||
}
|
||||
|
||||
// validatePriorityClass ensures that the value field is not larger than the highest user definable priority. If the GlobalDefault is set, it ensures that there is no other PriorityClass whose GlobalDefault is set.
|
||||
func (p *PriorityPlugin) validatePriorityClass(a admission.Attributes) error {
|
||||
func (p *priorityPlugin) validatePriorityClass(a admission.Attributes) error {
|
||||
operation := a.GetOperation()
|
||||
pc, ok := a.GetObject().(*scheduling.PriorityClass)
|
||||
if !ok {
|
||||
|
@ -222,7 +222,7 @@ func (p *PriorityPlugin) validatePriorityClass(a admission.Attributes) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *PriorityPlugin) getDefaultPriorityClass() (*scheduling.PriorityClass, error) {
|
||||
func (p *priorityPlugin) getDefaultPriorityClass() (*scheduling.PriorityClass, error) {
|
||||
list, err := p.lister.List(labels.Everything())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -240,7 +240,7 @@ func (p *PriorityPlugin) getDefaultPriorityClass() (*scheduling.PriorityClass, e
|
|||
return defaultPC, nil
|
||||
}
|
||||
|
||||
func (p *PriorityPlugin) getDefaultPriority() (int32, error) {
|
||||
func (p *priorityPlugin) getDefaultPriority() (int32, error) {
|
||||
// If global default priority is cached, return it.
|
||||
if p.globalDefaultPriority != nil {
|
||||
return *p.globalDefaultPriority, nil
|
||||
|
@ -259,6 +259,6 @@ func (p *PriorityPlugin) getDefaultPriority() (int32, error) {
|
|||
}
|
||||
|
||||
// invalidateCachedDefaultPriority sets global default priority to nil to indicate that it should be looked up again.
|
||||
func (p *PriorityPlugin) invalidateCachedDefaultPriority() {
|
||||
func (p *priorityPlugin) invalidateCachedDefaultPriority() {
|
||||
p.globalDefaultPriority = nil
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
package admission
|
||||
package priority
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -33,7 +33,7 @@ import (
|
|||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
|
||||
)
|
||||
|
||||
func addPriorityClasses(ctrl *PriorityPlugin, priorityClasses []*scheduling.PriorityClass) {
|
||||
func addPriorityClasses(ctrl *priorityPlugin, priorityClasses []*scheduling.PriorityClass) {
|
||||
informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc())
|
||||
ctrl.SetInternalKubeInformerFactory(informerFactory)
|
||||
// First add the existing classes to the cache.
|
||||
|
@ -133,7 +133,7 @@ func TestPriorityClassAdmission(t *testing.T) {
|
|||
for _, test := range tests {
|
||||
glog.V(4).Infof("starting test %q", test.name)
|
||||
|
||||
ctrl := NewPlugin()
|
||||
ctrl := newPlugin()
|
||||
// Add existing priority classes.
|
||||
addPriorityClasses(ctrl, test.existingClasses)
|
||||
// Now add the new class.
|
||||
|
@ -218,7 +218,7 @@ func TestDefaultPriority(t *testing.T) {
|
|||
|
||||
for _, test := range tests {
|
||||
glog.V(4).Infof("starting test %q", test.name)
|
||||
ctrl := NewPlugin()
|
||||
ctrl := newPlugin()
|
||||
addPriorityClasses(ctrl, test.classesBefore)
|
||||
defaultPriority, err := ctrl.getDefaultPriority()
|
||||
if err != nil {
|
||||
|
@ -464,7 +464,7 @@ func TestPodAdmission(t *testing.T) {
|
|||
for _, test := range tests {
|
||||
glog.V(4).Infof("starting test %q", test.name)
|
||||
|
||||
ctrl := NewPlugin()
|
||||
ctrl := newPlugin()
|
||||
// Add existing priority classes.
|
||||
addPriorityClasses(ctrl, test.existingClasses)
|
||||
|
||||
|
|
Loading…
Reference in New Issue