mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
Merge pull request #9739 from hashicorp/b-alloc-netmode-ports
Use port's to value when building service address under 'alloc' addr_mode
This commit is contained in:
@@ -6,6 +6,7 @@ IMPROVEMENTS:
|
||||
|
||||
BUG FIXES:
|
||||
* consul: Fixed a bug where updating a task to include services would not work [[GH-9707](https://github.com/hashicorp/nomad/issues/9707)]
|
||||
* consul: Fixed alloc address mode port advertisement to use the mapped `to` port value [[GH-9730](https://github.com/hashicorp/nomad/issues/9730)]
|
||||
* consul/connect: Fixed a bug where absent ingress envoy proxy configuration could panic client [[GH-9669](https://github.com/hashicorp/nomad/issues/9669)]
|
||||
* template: Fixed multiple issues in template src/dest and artifact dest interpolation [[GH-9671](https://github.com/hashicorp/nomad/issues/9671)]
|
||||
* template: Fixed a bug where dynamic secrets did not trigger the template `change_mode` after a client restart. [[GH-9636](https://github.com/hashicorp/nomad/issues/9636)]
|
||||
|
||||
@@ -1547,7 +1547,7 @@ func getAddress(addrMode, portLabel string, networks structs.Networks, driverNet
|
||||
|
||||
return driverNet.IP, port, nil
|
||||
|
||||
case "alloc":
|
||||
case structs.AddressModeAlloc:
|
||||
if netStatus == nil {
|
||||
return "", 0, fmt.Errorf(`cannot use address_mode="alloc": no allocation network status reported`)
|
||||
}
|
||||
@@ -1559,6 +1559,10 @@ func getAddress(addrMode, portLabel string, networks structs.Networks, driverNet
|
||||
|
||||
// If port is a label and is found then return it
|
||||
if port, ok := ports.Get(portLabel); ok {
|
||||
// Use port.To value unless not set
|
||||
if port.To > 0 {
|
||||
return netStatus.Address, port.To, nil
|
||||
}
|
||||
return netStatus.Address, port.Value, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1632,6 +1632,24 @@ func TestGetAddress(t *testing.T) {
|
||||
Address: "172.26.0.1",
|
||||
},
|
||||
ExpectedIP: "172.26.0.1",
|
||||
ExpectedPort: 6379,
|
||||
},
|
||||
{
|
||||
Name: "Alloc no to value",
|
||||
Mode: structs.AddressModeAlloc,
|
||||
PortLabel: "db",
|
||||
Ports: []structs.AllocatedPortMapping{
|
||||
{
|
||||
Label: "db",
|
||||
Value: 12345,
|
||||
HostIP: HostIP,
|
||||
},
|
||||
},
|
||||
Status: &structs.AllocNetworkStatus{
|
||||
InterfaceName: "eth0",
|
||||
Address: "172.26.0.1",
|
||||
},
|
||||
ExpectedIP: "172.26.0.1",
|
||||
ExpectedPort: 12345,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -106,9 +106,13 @@ Connect][connect] integration.
|
||||
service. The value of `port` depends on which [`address_mode`](#address_mode)
|
||||
is being used:
|
||||
|
||||
- `alloc` - Advertise the mapped `to` value of the labeled port and the allocation address.
|
||||
If a `to` value is not set, the port falls back to using the allocated host port. The `port`
|
||||
field may be a numeric port or a port label specified in the same group's network stanza.
|
||||
|
||||
- `driver` - Advertise the port determined by the driver (e.g. Docker or rkt).
|
||||
The `port` may be a numeric port or a port label specified in the driver's
|
||||
`port_map`.
|
||||
`ports` field.
|
||||
|
||||
- `host` - Advertise the host port for this service. `port` must match a port
|
||||
_label_ specified in the [`network`][network] stanza.
|
||||
|
||||
Reference in New Issue
Block a user