Skip to content

Commit

Permalink
Merge pull request #11757 from ederst/automated-cherry-pick-of-#11741-#…
Browse files Browse the repository at this point in the history
…11743-origin-release-1.21

Automated cherry pick of #11741: Compare OpenStack security groups deterministically
#11743: Make forwardToKubeDNS work in the NodeLocal DNSCache template
  • Loading branch information
k8s-ci-robot authored Jun 16, 2021
2 parents b7a953c + 812f263 commit 0ea4179
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ data:
prometheus :9253
health {{ KubeDNS.NodeLocalDNS.LocalIP }}:{{ NodeLocalDNSHealthCheck }}
}
{{- if KubeDNS.NodeLocalDNS.ForwardToKubeDNS }}
{{- if WithDefaultBool KubeDNS.NodeLocalDNS.ForwardToKubeDNS false }}
.:53 {
errors
cache 30
Expand Down
9 changes: 9 additions & 0 deletions upup/pkg/fi/cloudup/openstacktasks/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package openstacktasks

import (
"fmt"
"sort"

secgroup "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
Expand Down Expand Up @@ -88,6 +89,10 @@ func newPortTaskFromCloud(cloud openstack.OpenstackCloud, lifecycle *fi.Lifecycl
Lifecycle: lifecycle,
})
}

// sort for consistent comparison
sort.Sort(SecurityGroupsByID(sgs))

subnets := make([]*Subnet, len(port.FixedIPs))
for i, subn := range port.FixedIPs {
subnets[i] = &Subnet{
Expand Down Expand Up @@ -131,6 +136,10 @@ func (s *Port) Find(context *fi.Context) (*Port, error) {
} else if len(rs) != 1 {
return nil, fmt.Errorf("found multiple ports with name: %s", fi.StringValue(s.Name))
}

// sort for consistent comparison
sort.Sort(SecurityGroupsByID(s.SecurityGroups))

return newPortTaskFromCloud(cloud, s.Lifecycle, &rs[0], s)
}

Expand Down
9 changes: 9 additions & 0 deletions upup/pkg/fi/cloudup/openstacktasks/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ type SecurityGroup struct {
Lifecycle *fi.Lifecycle
}

// SecurityGroupsByID implements sort.Interface based on the ID field.
type SecurityGroupsByID []*SecurityGroup

func (a SecurityGroupsByID) Len() int { return len(a) }
func (a SecurityGroupsByID) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SecurityGroupsByID) Less(i, j int) bool {
return fi.StringValue(a[i].ID) < fi.StringValue(a[j].ID)
}

var _ fi.CompareWithID = &SecurityGroup{}

func (s *SecurityGroup) CompareWithID() *string {
Expand Down

0 comments on commit 0ea4179

Please sign in to comment.