Skip to content

Commit 86cfb51

Browse files
authored
Merge pull request #3495 from sedefsavas/rever2
Revert "Create bastion security group only when bastion is enabled"
2 parents e9dcf1f + 37f0917 commit 86cfb51

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

controllers/awscluster_controller.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ import (
5757
"sigs.k8s.io/cluster-api/util/predicates"
5858
)
5959

60-
var defaultAWSSecurityGroupRoles = []infrav1.SecurityGroupRole{
61-
infrav1.SecurityGroupAPIServerLB,
62-
infrav1.SecurityGroupLB,
63-
infrav1.SecurityGroupControlPlane,
64-
infrav1.SecurityGroupNode,
65-
}
60+
var (
61+
awsSecurityGroupRoles = []infrav1.SecurityGroupRole{
62+
infrav1.SecurityGroupBastion,
63+
infrav1.SecurityGroupAPIServerLB,
64+
infrav1.SecurityGroupLB,
65+
infrav1.SecurityGroupControlPlane,
66+
infrav1.SecurityGroupNode,
67+
}
68+
)
6669

6770
// AWSClusterReconciler reconciles a AwsCluster object.
6871
type AWSClusterReconciler struct {
@@ -100,24 +103,12 @@ func (r *AWSClusterReconciler) getNetworkService(scope scope.ClusterScope) servi
100103
return network.NewService(&scope)
101104
}
102105

103-
// securityGroupRolesForCluster returns the security group roles determined by the cluster configuration.
104-
func securityGroupRolesForCluster(scope scope.ClusterScope) []infrav1.SecurityGroupRole {
105-
roles := []infrav1.SecurityGroupRole{}
106-
// Copy to ensure we do not modify the package-level variable.
107-
copy(roles, defaultAWSSecurityGroupRoles)
108-
109-
if scope.Bastion().Enabled {
110-
roles = append(roles, infrav1.SecurityGroupBastion)
111-
}
112-
return roles
113-
}
114-
115106
// getSecurityGroupService factory func is added for testing purpose so that we can inject mocked SecurityGroupService to the AWSClusterReconciler.
116107
func (r *AWSClusterReconciler) getSecurityGroupService(scope scope.ClusterScope) services.SecurityGroupInterface {
117108
if r.securityGroupFactory != nil {
118109
return r.securityGroupFactory(scope)
119110
}
120-
return securitygroup.NewService(&scope, securityGroupRolesForCluster(scope))
111+
return securitygroup.NewService(&scope, awsSecurityGroupRoles)
121112
}
122113

123114
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=awsclusters,verbs=get;list;watch;create;update;patch;delete

0 commit comments

Comments
 (0)