@@ -26,10 +26,13 @@ func NewAddonManager(clients *awsClients) *AddonManager {
2626}
2727
2828func (m * AddonManager ) createAddons (infra * Infrastructure , cluster * Cluster , opts * deployerOptions ) error {
29+ ctx := context .TODO ()
30+
31+ addonMap := map [string ]string {}
2932 for _ , addon := range opts .Addons {
3033 addonParts := strings .Split (addon , ":" )
3134 if len (addonParts ) != 2 {
32- return fmt .Errorf ("invalid addon: %s" , addon )
35+ return fmt .Errorf ("invalid addon format : %s" , addon )
3336 }
3437 name := addonParts [0 ]
3538 version := addonParts [1 ]
@@ -38,26 +41,32 @@ func (m *AddonManager) createAddons(infra *Infrastructure, cluster *Cluster, opt
3841 if err != nil {
3942 return err
4043 }
41- klog .Infof ("creating addon %s version: %s" , name , resolvedVersion )
44+ // dedupe addons with the same name. last provided entry wins.
45+ addonMap [name ] = resolvedVersion
46+ }
47+
48+ for addonName , addonVersion := range addonMap {
49+ klog .Infof ("creating addon %s version: %s" , addonName , addonVersion )
4250 input := eks.CreateAddonInput {
43- AddonName : aws .String (name ),
44- AddonVersion : aws .String (resolvedVersion ),
51+ AddonName : aws .String (addonName ),
52+ AddonVersion : aws .String (addonVersion ),
4553 ClusterName : aws .String (cluster .name ),
4654 }
47- _ , err = m .clients .EKS ().CreateAddon (context . TODO () , & input )
55+ _ , err : = m .clients .EKS ().CreateAddon (ctx , & input )
4856 if err != nil {
4957 return fmt .Errorf ("failed to create addon: %v" , err )
5058 }
51- klog .Infof ("waiting for addon to be active: %s" , name )
59+ klog .Infof ("waiting for addon to be active: %s" , addonName )
5260 err = eks .NewAddonActiveWaiter (m .clients .EKS ()).
53- Wait (context .TODO (), & eks.DescribeAddonInput {
61+ Wait (ctx , & eks.DescribeAddonInput {
62+ AddonName : aws .String (addonName ),
5463 ClusterName : aws .String (cluster .name ),
55- AddonName : aws .String (name ),
5664 }, addonCreationTimeout )
5765 if err != nil {
5866 return fmt .Errorf ("failed to wait for addon to be active: %v" , err )
5967 }
6068 }
69+
6170 return nil
6271}
6372
0 commit comments