mirror of https://github.com/kubernetes/kops.git
Remove components from cluster validation
This commit is contained in:
parent
9b3f13d93f
commit
c2434a2e08
|
@ -170,10 +170,6 @@ func (v *clusterValidatorImpl) Validate() (*ValidationCluster, error) {
|
|||
}
|
||||
readyNodes := validation.validateNodes(cloudGroups, v.instanceGroups)
|
||||
|
||||
if err := validation.collectComponentFailures(ctx, v.k8sClient); err != nil {
|
||||
return nil, fmt.Errorf("cannot get component status for %q: %v", clusterName, err)
|
||||
}
|
||||
|
||||
if err := validation.collectPodFailures(ctx, v.k8sClient, readyNodes, v.instanceGroups); err != nil {
|
||||
return nil, fmt.Errorf("cannot get pod health for %q: %v", clusterName, err)
|
||||
}
|
||||
|
@ -181,27 +177,6 @@ func (v *clusterValidatorImpl) Validate() (*ValidationCluster, error) {
|
|||
return validation, nil
|
||||
}
|
||||
|
||||
func (v *ValidationCluster) collectComponentFailures(ctx context.Context, client kubernetes.Interface) error {
|
||||
componentList, err := client.CoreV1().ComponentStatuses().List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error listing ComponentStatuses: %v", err)
|
||||
}
|
||||
|
||||
// TODO: Add logic to figure out the InstanceGroup given a component
|
||||
for _, component := range componentList.Items {
|
||||
for _, condition := range component.Conditions {
|
||||
if condition.Status != v1.ConditionTrue {
|
||||
v.addError(&ValidationError{
|
||||
Kind: "ComponentStatus",
|
||||
Name: component.Name,
|
||||
Message: fmt.Sprintf("component %q is unhealthy", component.Name),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var masterStaticPods = []string{
|
||||
"kube-apiserver",
|
||||
"kube-controller-manager",
|
||||
|
|
|
@ -556,56 +556,6 @@ func Test_ValidateMasterStaticPods(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func Test_ValidateNoComponentFailures(t *testing.T) {
|
||||
v, err := testValidate(t, nil, []runtime.Object{
|
||||
&v1.ComponentStatus{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "testcomponent",
|
||||
},
|
||||
Conditions: []v1.ComponentCondition{
|
||||
{
|
||||
Status: v1.ConditionTrue,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
assert.Empty(t, v.Failures)
|
||||
}
|
||||
|
||||
func Test_ValidateComponentFailure(t *testing.T) {
|
||||
for _, status := range []v1.ConditionStatus{
|
||||
v1.ConditionFalse,
|
||||
v1.ConditionUnknown,
|
||||
} {
|
||||
t.Run(string(status), func(t *testing.T) {
|
||||
v, err := testValidate(t, nil, []runtime.Object{
|
||||
&v1.ComponentStatus{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "testcomponent",
|
||||
},
|
||||
Conditions: []v1.ComponentCondition{
|
||||
{
|
||||
Status: status,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
if !assert.Len(t, v.Failures, 1) ||
|
||||
!assert.Equal(t, &ValidationError{
|
||||
Kind: "ComponentStatus",
|
||||
Name: "testcomponent",
|
||||
Message: "component \"testcomponent\" is unhealthy",
|
||||
}, v.Failures[0]) {
|
||||
printDebug(t, v)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_ValidateNoPodFailures(t *testing.T) {
|
||||
testpods := []map[string]string{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue