-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow configuration of Docker hostnames in bridge mode (#11173)
Add a new hostname string parameter to the network block which allows operators to specify the hostname of the network namespace. Changing this causes a destructive update to the allocation and it is omitted if empty from API responses. This parameter also supports interpolation. In order to have a hostname passed as a configuration param when creating an allocation network, the CreateNetwork func of the DriverNetworkManager interface needs to be updated. In order to minimize the disruption of future changes, rather than add another string func arg, the function now accepts a request struct along with the allocID param. The struct has the hostname as a field. The in-tree implementations of DriverNetworkManager.CreateNetwork have been modified to account for the function signature change. In updating for the change, the enhancement of adding hostnames to network namespaces has also been added to the Docker driver, whilst the default Linux manager does not current implement it.
- Loading branch information
1 parent
1c82154
commit aff6339
Showing
31 changed files
with
947 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package taskenv | ||
|
||
import ( | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
) | ||
|
||
// InterpolateNetworks returns an interpolated copy of the task group networks | ||
// with values from the task's environment. | ||
// | ||
// Current interoperable fields: | ||
// - Hostname | ||
func InterpolateNetworks(taskEnv *TaskEnv, networks structs.Networks) structs.Networks { | ||
|
||
// Guard against not having a valid taskEnv. This can be the case if the | ||
// PreKilling or Exited hook is run before Poststart. | ||
if taskEnv == nil || networks == nil { | ||
return nil | ||
} | ||
|
||
// Create a copy of the networks array, so we can manipulate the copy. | ||
interpolated := networks.Copy() | ||
|
||
// Iterate the copy and perform the interpolation. | ||
for i := range interpolated { | ||
interpolated[i].Hostname = taskEnv.ReplaceEnv(interpolated[i].Hostname) | ||
} | ||
|
||
return interpolated | ||
} |
Oops, something went wrong.