mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	cleanup: remove unnecessary codes
Signed-off-by: kerthcet <kerthcet@gmail.com>
This commit is contained in:
		@@ -198,6 +198,11 @@ func (s *Status) IsWait() bool {
 | 
				
			|||||||
	return s.Code() == Wait
 | 
						return s.Code() == Wait
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// IsSkip returns true if and only if "Status" is non-nil and its Code is "Skip".
 | 
				
			||||||
 | 
					func (s *Status) IsSkip() bool {
 | 
				
			||||||
 | 
						return s.Code() == Skip
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable).
 | 
					// IsUnschedulable returns true if "Status" is Unschedulable (Unschedulable or UnschedulableAndUnresolvable).
 | 
				
			||||||
func (s *Status) IsUnschedulable() bool {
 | 
					func (s *Status) IsUnschedulable() bool {
 | 
				
			||||||
	code := s.Code()
 | 
						code := s.Code()
 | 
				
			||||||
@@ -207,7 +212,7 @@ func (s *Status) IsUnschedulable() bool {
 | 
				
			|||||||
// AsError returns nil if the status is a success or a wait; otherwise returns an "error" object
 | 
					// AsError returns nil if the status is a success or a wait; otherwise returns an "error" object
 | 
				
			||||||
// with a concatenated message on reasons of the Status.
 | 
					// with a concatenated message on reasons of the Status.
 | 
				
			||||||
func (s *Status) AsError() error {
 | 
					func (s *Status) AsError() error {
 | 
				
			||||||
	if s.IsSuccess() || s.IsWait() {
 | 
						if s.IsSuccess() || s.IsWait() || s.IsSkip() {
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if s.err != nil {
 | 
						if s.err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -35,6 +35,7 @@ func TestStatus(t *testing.T) {
 | 
				
			|||||||
		expectedMessage   string
 | 
							expectedMessage   string
 | 
				
			||||||
		expectedIsSuccess bool
 | 
							expectedIsSuccess bool
 | 
				
			||||||
		expectedIsWait    bool
 | 
							expectedIsWait    bool
 | 
				
			||||||
 | 
							expectedIsSkip    bool
 | 
				
			||||||
		expectedAsError   error
 | 
							expectedAsError   error
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -44,6 +45,7 @@ func TestStatus(t *testing.T) {
 | 
				
			|||||||
			expectedMessage:   "",
 | 
								expectedMessage:   "",
 | 
				
			||||||
			expectedIsSuccess: true,
 | 
								expectedIsSuccess: true,
 | 
				
			||||||
			expectedIsWait:    false,
 | 
								expectedIsWait:    false,
 | 
				
			||||||
 | 
								expectedIsSkip:    false,
 | 
				
			||||||
			expectedAsError:   nil,
 | 
								expectedAsError:   nil,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -53,6 +55,7 @@ func TestStatus(t *testing.T) {
 | 
				
			|||||||
			expectedMessage:   "",
 | 
								expectedMessage:   "",
 | 
				
			||||||
			expectedIsSuccess: false,
 | 
								expectedIsSuccess: false,
 | 
				
			||||||
			expectedIsWait:    true,
 | 
								expectedIsWait:    true,
 | 
				
			||||||
 | 
								expectedIsSkip:    false,
 | 
				
			||||||
			expectedAsError:   nil,
 | 
								expectedAsError:   nil,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@@ -62,14 +65,26 @@ func TestStatus(t *testing.T) {
 | 
				
			|||||||
			expectedMessage:   "unknown error",
 | 
								expectedMessage:   "unknown error",
 | 
				
			||||||
			expectedIsSuccess: false,
 | 
								expectedIsSuccess: false,
 | 
				
			||||||
			expectedIsWait:    false,
 | 
								expectedIsWait:    false,
 | 
				
			||||||
 | 
								expectedIsSkip:    false,
 | 
				
			||||||
			expectedAsError:   errors.New("unknown error"),
 | 
								expectedAsError:   errors.New("unknown error"),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								name:              "skip status",
 | 
				
			||||||
 | 
								status:            NewStatus(Skip, ""),
 | 
				
			||||||
 | 
								expectedCode:      Skip,
 | 
				
			||||||
 | 
								expectedMessage:   "",
 | 
				
			||||||
 | 
								expectedIsSuccess: false,
 | 
				
			||||||
 | 
								expectedIsWait:    false,
 | 
				
			||||||
 | 
								expectedIsSkip:    true,
 | 
				
			||||||
 | 
								expectedAsError:   nil,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:              "nil status",
 | 
								name:              "nil status",
 | 
				
			||||||
			status:            nil,
 | 
								status:            nil,
 | 
				
			||||||
			expectedCode:      Success,
 | 
								expectedCode:      Success,
 | 
				
			||||||
			expectedMessage:   "",
 | 
								expectedMessage:   "",
 | 
				
			||||||
			expectedIsSuccess: true,
 | 
								expectedIsSuccess: true,
 | 
				
			||||||
 | 
								expectedIsSkip:    false,
 | 
				
			||||||
			expectedAsError:   nil,
 | 
								expectedAsError:   nil,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -92,6 +107,10 @@ func TestStatus(t *testing.T) {
 | 
				
			|||||||
				t.Errorf("status.IsWait() returns %v, but want %v", test.status.IsWait(), test.expectedIsWait)
 | 
									t.Errorf("status.IsWait() returns %v, but want %v", test.status.IsWait(), test.expectedIsWait)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if test.status.IsSkip() != test.expectedIsSkip {
 | 
				
			||||||
 | 
									t.Errorf("status.IsSkip() returns %v, but want %v", test.status.IsSkip(), test.expectedIsSkip)
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if test.status.AsError() == test.expectedAsError {
 | 
								if test.status.AsError() == test.expectedAsError {
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1038,7 +1038,7 @@ func (f *frameworkImpl) RunBindPlugins(ctx context.Context, state *framework.Cyc
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	for _, bp := range f.bindPlugins {
 | 
						for _, bp := range f.bindPlugins {
 | 
				
			||||||
		status = f.runBindPlugin(ctx, bp, state, pod, nodeName)
 | 
							status = f.runBindPlugin(ctx, bp, state, pod, nodeName)
 | 
				
			||||||
		if status != nil && status.Code() == framework.Skip {
 | 
							if status.IsSkip() {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if !status.IsSuccess() {
 | 
							if !status.IsSuccess() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user