Skip to content

Commit 507253a

Browse files
authored
Merge pull request #592 from jichenjc/bug/591
Add event for seucrity group
2 parents f849c94 + 02b7380 commit 507253a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/cloud/services/networking/securitygroups.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
2323
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules"
2424
infrav1 "sigs.k8s.io/cluster-api-provider-openstack/api/v1alpha3"
25+
"sigs.k8s.io/cluster-api-provider-openstack/pkg/record"
2526
)
2627

2728
const (
@@ -66,7 +67,7 @@ func (s *Service) ReconcileSecurityGroups(clusterName string, openStackCluster *
6667
}
6768
//create security groups first, because desired rules use group ids.
6869
for _, v := range secGroupNames {
69-
if err := s.createSecurityGroupIfNotExists(v); err != nil {
70+
if err := s.createSecurityGroupIfNotExists(openStackCluster, v); err != nil {
7071
return err
7172
}
7273
}
@@ -361,7 +362,7 @@ func (s *Service) reconcileGroupRules(desired, observed infrav1.SecurityGroup) (
361362
return observed, nil
362363
}
363364

364-
func (s *Service) createSecurityGroupIfNotExists(groupName string) error {
365+
func (s *Service) createSecurityGroupIfNotExists(openStackCluster *infrav1.OpenStackCluster, groupName string) error {
365366
secGroup, err := s.getSecurityGroupByName(groupName)
366367
if err != nil {
367368
return err
@@ -378,6 +379,7 @@ func (s *Service) createSecurityGroupIfNotExists(groupName string) error {
378379
if err != nil {
379380
return err
380381
}
382+
record.Eventf(openStackCluster, "SuccessfulCreateSecurityGroup", "Created security group %s with id %s", groupName, secGroup.ID)
381383
return nil
382384

383385
}

0 commit comments

Comments
 (0)