-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add compatibility check based on output feature flags
We may in the future store configuration inside the cluster, but until then we can track the effect of configuration on nodegroups using outputs, the theory is that only very few things actually break backwards compatibility in relation to configuration of nodegroups.
- Loading branch information
1 parent
abbda99
commit 1ec6ae2
Showing
7 changed files
with
105 additions
and
64 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
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
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,71 @@ | ||
package eks | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/kris-nova/logger" | ||
"github.com/pkg/errors" | ||
|
||
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha3" | ||
"github.com/weaveworks/eksctl/pkg/cfn/builder" | ||
"github.com/weaveworks/eksctl/pkg/cfn/manager" | ||
) | ||
|
||
// ValidateClusterForCompatibility looks at the cluster stack and check if it's | ||
// compatible with current nodegroup configuration, if it find issues it returns an error | ||
func (c *ClusterProvider) ValidateClusterForCompatibility(cfg *api.ClusterConfig, stackManager *manager.StackCollection) error { | ||
// TODO: must move this before we try to create the nodegroup actually | ||
cluster, err := stackManager.DescribeClusterStack() | ||
if err != nil { | ||
return errors.Wrap(err, "getting cluster stacks") | ||
} | ||
|
||
sharedClusterNodeSG := "" | ||
for _, x := range cluster.Outputs { | ||
if *x.OutputKey == builder.CfnOutputClusterSharedNodeSecurityGroup { | ||
sharedClusterNodeSG = *x.OutputValue | ||
} | ||
} | ||
|
||
if sharedClusterNodeSG == "" { | ||
return fmt.Errorf("cluster %q does not have shared node security group", cfg.Metadata.Name) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ValidateExistingNodeGroupsForCompatibility looks at each of the existing nodegroups and | ||
// validates configuration, if it find issues it logs messages | ||
func (c *ClusterProvider) ValidateExistingNodeGroupsForCompatibility(cfg *api.ClusterConfig, stackManager *manager.StackCollection) error { | ||
resourcesByNodeGroup, err := stackManager.DescribeNodeGroupStacksAndResources() | ||
if err != nil { | ||
return errors.Wrap(err, "getting resources for of all nodegroup stacks") | ||
} | ||
|
||
incompatibleNodeGroups := []string{} | ||
for ng, resources := range resourcesByNodeGroup { | ||
compatible := false | ||
for _, x := range resources.Stack.Outputs { | ||
if *x.OutputKey == builder.CfnOutputNodeGroupFeatureSharedSecurityGroup { | ||
compatible = true | ||
} | ||
} | ||
if !compatible { | ||
incompatibleNodeGroups = append(incompatibleNodeGroups, ng) | ||
} | ||
} | ||
|
||
numIncompatibleNodeGroups := len(incompatibleNodeGroups) | ||
if numIncompatibleNodeGroups == 0 { | ||
return nil | ||
} | ||
|
||
logger.Critical("found %d nodegroup(s) (%s) without shared security group, cluster networking maybe be broken", | ||
numIncompatibleNodeGroups, strings.Join(incompatibleNodeGroups, ", ")) | ||
logger.Critical("it's recommended to delete these nodegroups and create new ones instead") | ||
logger.Critical("as a temporary fix, you can patch the configuration and add each of these nodegroup(s) to %q", | ||
cfg.VPC.SharedNodeSecurityGroup) | ||
|
||
return nil | ||
} |
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