-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor and increase test coverage for creating nodegroups #3728
Conversation
@aclevername I implemented your review feedback and then manually created a nodegroup to test the changes - no regression! |
@@ -18,6 +18,8 @@ type Manager struct { | |||
cfg *api.ClusterConfig | |||
clientSet *kubernetes.Clientset | |||
wait WaitFunc | |||
init eks.NodeGroupInitialiser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like init
is a bit vague, but not sure on a better name 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think initialiser
, while verbose, would be clearer. init
as we know it in Go does shorthand initialise, but it may be helpful to clarify that we don't mean that kind of init
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Big PR so worth waiting for 2 accepting reviews before merging IMO 😄
2ccf506
to
a932fda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 🎉
I just have a couple of comments on really superficial things.
e7bfd41
to
6feb6d0
Compare
Remove KubeProvider from v1alpha5 types Generate KubeProvider mocks to be used by Nodegroup unit tests * Abstracts some of ClusterProvider's functions into a KubeProvider interface in pkg/eks/kubeprovider.go * Generates mocks for KubeProvider in pkg/eks/fakes * Passes KubeProvider to the ClusterProvider struct * Mocks calls to KubeProvider's functions in pkg/actions/nodegroups/create.go and pkg/actions/nodegroups/create_test.go
* Test for failing to load VPC from config * Test when cluster does not support managed nodes
* Test for when cluster is not compatible with ng config * Test for when existing local ng stacks in config file fail to be listed
* Unit test ng creation when failing to validate legacy subnets for ng * Transcribe go pkg tests to ginkgo tests * Test whether ng uses IRSA, test that stack manager does tasks * Test evaluates whether aws-node uses IRSA * Test checks if stack manager fails to do ng tasks * Test ng is created without errors - happy path * Test ng creation with dry run option * Test creating ng will all options * Unit test creating managed nodegroups * Refactored WaitForNodes from ClusterProvider to nodeGroupService * Refactor WaitTimeout to KubeProvider * Refactor UpdateAuthConfigMap to nodeGroupService
* Move ValidateExistingNodeGroupsForCompatibility to nodegroup initialiser interface * Move DoAllNodegroupStackTasks to nodegroup initialiser interface
* Get rid of counterfeiter warning when generating mocks * Update doc comments * Rename unit test names to more descriptive names Co-authored-by: Claudia <claudiaberesford@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Closes #3699
Related to #2931
Adds unit test for
pkg/actions/nodegroup.create
to increase test coverage. Tests failures as well as successfully creating managed nodes, creating unmanaged nodes, and creating nodes with or without all of theCreateOpts
.New Interfaces
KubeProvider
has some functions from theClusterProvider
struct that did not previously belong to any interface and were therefore hard to mock.NodeGroupInitialiser
has functions from theNodeGroupService
struct.NodegroupFilter
has functions from the structNodeGroupFilter
(StackLister
had to be exported in order to be able to mock it).Refactoring the main
Create
functionNodeManager
to mock out 2 of its fields without having to change the code in all the other packages whereNodeManager
is used.Create
func to a new funcUpdateAuthConfigMap
that is now part of theKubeProvider
interface.Create
function to a new funcnodeCreationTasks
so this reduces it from ~200 to ~120 LOC.Checklist
README.md
, or theuserdocs
directory)area/nodegroup
) and kind (e.g.kind/improvement
)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯