{"record":{"id":"f738a8497c658f13","repo":"kubernetes/kops","slug":"failed-to-associated-floating-ip-to-instance-s","errorCode":null,"errorMessage":"failed to associated floating IP to instance %s: %v","messagePattern":"failed to associated floating IP to instance (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstacktasks/instance.go","lineNumber":420,"sourceCode":"\t\t}\n\t}\n\tif changes.FloatingIP != nil {\n\t\terr := associateFloatingIP(t, e)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc associateFloatingIP(t *openstack.OpenstackAPITarget, e *Instance) error {\n\tclient := t.Cloud.NetworkingClient()\n\n\t_, err := l3floatingip.Update(context.TODO(), client, fi.ValueOf(e.FloatingIP.ID), l3floatingip.UpdateOpts{\n\t\tPortID: e.Port.ID,\n\t}).Extract()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to associated floating IP to instance %s: %v\", *e.Name, err)\n\t}\n\treturn nil\n}\n\nfunc includeBootVolumeOptions(t *openstack.OpenstackAPITarget, e *Instance, opts servers.CreateOpts) (servers.CreateOpts, error) {\n\tif !bootFromVolume(e.Metadata) {\n\t\treturn opts, nil\n\t}\n\n\ti, err := t.Cloud.GetImage(fi.ValueOf(e.Image))\n\tif err != nil {\n\t\treturn servers.CreateOpts{}, fmt.Errorf(\"Error getting image information: %v\", err)\n\t}\n\n\tblockDevice := servers.BlockDevice{\n\t\tBootIndex:           0,\n\t\tDeleteOnTermination: true,\n\t\tDestinationType:     \"volume\",","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstacktasks/instance.go#L402-L438","documentation":"Thrown by associateFloatingIP when the Neutron L3 floating-IP update (PUT /v2.0/floatingips/{id} setting PortID) fails while associating a floating IP with the new instance's port during RenderOpenstack. The Neutron client (l3floatingip.Update) returns errors such as port not found, IP already associated, or 401/404. The message names the instance to make the failing task identifiable in the kOps apply output.","triggerScenarios":"l3floatingip.Update returns error during instance creation or when changes.FloatingIP triggers re-association: FloatingIP.ID no longer exists (deleted/released between tasks), e.Port.ID is nil or points to a deleted port, the floating IP belongs to a different project/network than the port, or Neutron rejects the association because the port has no fixed IP in the floating IP's subnet.","commonSituations":"A leftover floating IP from a prior failed apply was deleted externally; running with insufficient Neutron RBAC to update floating IPs; port and floating IP created in mismatched subnets; concurrent applies racing to associate the same IP; Octavia/Neutron extension `l3-floating-ip` unavailable on older clouds.","solutions":["Check the floating IP still exists and is unassociated: `openstack floating ip show <id>`; delete/recreate it and rerun `kops update cluster`","Verify the port exists and has a fixed IP in the same subnet as the floating IP: `openstack port show <port-id>`","Confirm Neutron credentials/RBAC allow updating floating IPs for the project","Ensure the cluster spec doesn't reuse one floating IP for multiple instances (concurrent association conflict)","If the cloud lacks the floating IP port-forwarding/l3 extension expected by the gophercloud version, upgrade the cloud side or pin a compatible client"],"exampleFix":"// before: stale floating IP left from failed apply\n// openstack floating ip delete <stale-ip-id>\n// after: recreate then re-apply\n// openstack floating ip create --subnet <subnet> <external-network>\n// kops update cluster --name <cluster> --yes","handlingStrategy":"try-catch","validationCode":"// pre-flight: floating IP must exist, be unassociated, and port must have a fixed IP\nfunc validateFloatingIPAssociation(netClient *gophercloud.ServiceClient, fipID, portID string) error {\n\tfip, err := l3floatingip.Get(context.TODO(), netClient, fipID).Extract()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"floating IP %q missing: %w\", fipID, err)\n\t}\n\tif fip.PortID != \"\" {\n\t\treturn fmt.Errorf(\"floating IP %q already associated with port %q\", fipID, fip.PortID)\n\t}\n\tport, err := ports.Get(context.TODO(), netClient, portID).Extract()\n\tif err != nil || len(port.FixedIPs) == 0 {\n\t\treturn fmt.Errorf(\"port %q missing or has no fixed IP\", portID)\n\t}\n\treturn nil\n}","typeGuard":"func isFloatingIPNotFound(err error) bool {\n\tvar _, nf gophercloud.ErrDefault404\n\treturn errors.As(err, &nf) || strings.Contains(err.Error(), \"No address with that ID\")\n}","tryCatchPattern":"_, err := l3floatingip.Update(context.TODO(), client, fi.ValueOf(e.FloatingIP.ID), l3floatingip.UpdateOpts{PortID: e.Port.ID}).Extract()\nif err != nil {\n\tif isFloatingIPNotFound(err) {\n\t\treturn fmt.Errorf(\"floating IP %s was deleted; recreate it and re-apply: %w\", fi.ValueOf(e.FloatingIP.ID), err)\n\t}\n\treturn fmt.Errorf(\"failed to associated floating IP to instance %s: %w\", *e.Name, err)\n}","preventionTips":["Don't share a single floating IP across multiple instances or concurrent applies","Check with `openstack floating ip show <id>` that the IP exists and is unassociated before applying","Ensure port and floating IP are in the same subnet/project","Grant the automation credentials Neutron permissions to update floating IPs","Re-run `kops update cluster` after failed applies so kOps can reconcile stale IP tasks"],"tags":["openstack","neutron","floating-ip","kops"],"backgroundTag":"floating-ip-association-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}