Skip to content

Commit

Permalink
Merge pull request #6431 from zetaab/useifexist
Browse files Browse the repository at this point in the history
fix error when updating/creating lb in openstack
  • Loading branch information
k8s-ci-robot authored Feb 19, 2019
2 parents be2a6a5 + 6ce8fba commit 487ac63
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions upup/pkg/fi/cloudup/openstacktasks/floatingip.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ func (e *FloatingIP) FindIPAddress(context *fi.Context) (*string, error) {
}

cloud := context.Cloud.(openstack.OpenstackCloud)
// try to find using portid, the floatingips always attached to port
if e.ID == nil && e.LB != nil && e.LB.PortID != nil {
fips, err := cloud.ListL3FloatingIPs(l3floatingip.ListOpts{
PortID: fi.StringValue(e.LB.PortID),
})
if err != nil {
return nil, err
}
if len(fips) == 1 && fips[0].PortID == fi.StringValue(e.LB.PortID) {
return &fips[0].FloatingIP, nil
}
// not found
return nil, nil
}

fip, err := cloud.GetFloatingIP(fi.StringValue(e.ID))
if err != nil {
Expand Down

0 comments on commit 487ac63

Please sign in to comment.