Skip to content

Commit

Permalink
Do not require overrideBootstrapCommand when ami family is Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
a2ush committed Jun 2, 2022
1 parent dde684a commit 8380bee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/apis/eksctl.io/v1alpha5/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ func ValidateNodeGroup(i int, ng *NodeGroup) error {
}
}

if ng.AMI != "" && ng.OverrideBootstrapCommand == nil && ng.AMIFamily != NodeImageFamilyBottlerocket {
if ng.AMI != "" && ng.OverrideBootstrapCommand == nil && ng.AMIFamily != NodeImageFamilyBottlerocket && !IsWindowsImage(ng.AMIFamily) {
return errors.Errorf("%[1]s.overrideBootstrapCommand is required when using a custom AMI (%[1]s.ami)", path)
}

Expand Down Expand Up @@ -681,6 +681,10 @@ func ValidateNodeGroup(i int, ng *NodeGroup) error {
return fieldNotSupported("kubeletExtraConfig")
}

if IsWindowsImage(ng.AMIFamily) && ng.OverrideBootstrapCommand != nil {
return fieldNotSupported("overrideBootstrapCommand")
}

if ng.AMIFamily == NodeImageFamilyBottlerocket {
if ng.PreBootstrapCommands != nil {
return fieldNotSupported("preBootstrapCommands")
Expand Down
17 changes: 17 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,23 @@ var _ = Describe("ClusterConfig validation", func() {
ng0.AMIFamily = api.NodeImageFamilyBottlerocket
Expect(api.ValidateNodeGroup(0, ng0)).To(Succeed())
})
It("should not require overrideBootstrapCommand if ami is set and type is Windows", func() {
cfg := api.NewClusterConfig()
ng0 := cfg.NewNodeGroup()
ng0.Name = "node-group"
ng0.AMI = "ami-1234"
ng0.AMIFamily = api.NodeImageFamilyWindowsServer2019CoreContainer
Expect(api.ValidateNodeGroup(0, ng0)).To(Succeed())
})
It("should throw an error if overrideBootstrapCommand is set and type is Windows", func() {
cfg := api.NewClusterConfig()
ng0 := cfg.NewNodeGroup()
ng0.Name = "node-group"
ng0.AMI = "ami-1234"
ng0.AMIFamily = api.NodeImageFamilyWindowsServer2019CoreContainer
ng0.OverrideBootstrapCommand = aws.String("echo 'yo'")
Expect(api.ValidateNodeGroup(0, ng0)).To(MatchError(ContainSubstring("overrideBootstrapCommand is not supported for WindowsServer2019CoreContainer nodegroups")))
})
It("should accept ami with a overrideBootstrapCommand set", func() {
cfg := api.NewClusterConfig()
ng0 := cfg.NewNodeGroup()
Expand Down

0 comments on commit 8380bee

Please sign in to comment.