forked from kubernetes-sigs/cluster-api-provider-aws
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log set of issues when node group in degraded state
- Loading branch information
1 parent
273f1d7
commit a607701
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package eks | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/service/eks" | ||
. "github.com/onsi/gomega" | ||
"sigs.k8s.io/cluster-api-provider-aws/exp/api/v1beta1" | ||
"sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/scope" | ||
capierrors "sigs.k8s.io/cluster-api/errors" | ||
"testing" | ||
) | ||
|
||
func TestSetStatus(t *testing.T) { | ||
g := NewWithT(t) | ||
degraded := eks.NodegroupStatusDegraded | ||
code := eks.NodegroupIssueCodeAsgInstanceLaunchFailures | ||
message := "VcpuLimitExceeded" | ||
resourceId := "my-worker-nodes" | ||
|
||
s := &NodegroupService{ | ||
scope: &scope.ManagedMachinePoolScope{ | ||
ManagedMachinePool: &v1beta1.AWSManagedMachinePool{ | ||
Status: v1beta1.AWSManagedMachinePoolStatus{ | ||
Ready: false, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
issue := &eks.Issue{ | ||
Code: &code, | ||
Message: &message, | ||
ResourceIds: []*string{&resourceId}, | ||
} | ||
ng := &eks.Nodegroup{ | ||
Status: °raded, | ||
Health: &eks.NodegroupHealth{ | ||
Issues: []*eks.Issue{issue}, | ||
}, | ||
} | ||
|
||
err := s.setStatus(ng) | ||
g.Expect(err).ToNot(BeNil()) | ||
// ensure machine pool status values are set as expected | ||
g.Expect(*s.scope.ManagedMachinePool.Status.FailureMessage).To(ContainSubstring(issue.GoString())) | ||
g.Expect(s.scope.ManagedMachinePool.Status.Ready).To(Equal(false)) | ||
g.Expect(*s.scope.ManagedMachinePool.Status.FailureReason).To(Equal(capierrors.InsufficientResourcesMachineError)) | ||
} |