Skip to content

Commit

Permalink
Backport of Ensure infra_image gets proper label used for reconciliat…
Browse files Browse the repository at this point in the history
…ion into release/1.2.x (#15957)

This pull request was automerged via backport-assistant
  • Loading branch information
hc-github-team-nomad-core authored Jan 30, 2023
1 parent 84d75d1 commit c0ce214
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/15898.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
docker: Fixed a bug where infra_image did not get alloc_id label
```
4 changes: 3 additions & 1 deletion drivers/docker/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ func (d *Driver) DestroyNetwork(allocID string, spec *drivers.NetworkIsolationSp
// createSandboxContainerConfig creates a docker container configuration which
// starts a container with an empty network namespace.
func (d *Driver) createSandboxContainerConfig(allocID string, createSpec *drivers.NetworkCreateRequest) (*docker.CreateContainerOptions, error) {

return &docker.CreateContainerOptions{
Name: fmt.Sprintf("nomad_init_%s", allocID),
Config: &docker.Config{
Image: d.config.InfraImage,
Hostname: createSpec.Hostname,
Labels: map[string]string{
dockerLabelAllocID: allocID,
},
},
HostConfig: &docker.HostConfig{
// Set the network mode to none which creates a network namespace
Expand Down
6 changes: 6 additions & 0 deletions drivers/docker/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func TestDriver_createSandboxContainerConfig(t *testing.T) {
Name: "nomad_init_768b5e8c-a52e-825c-d564-51100230eb62",
Config: &docker.Config{
Image: "gcr.io/google_containers/pause-amd64:3.1",
Labels: map[string]string{
dockerLabelAllocID: "768b5e8c-a52e-825c-d564-51100230eb62",
},
},
HostConfig: &docker.HostConfig{
NetworkMode: "none",
Expand All @@ -44,6 +47,9 @@ func TestDriver_createSandboxContainerConfig(t *testing.T) {
Config: &docker.Config{
Image: "gcr.io/google_containers/pause-amd64:3.1",
Hostname: "linux",
Labels: map[string]string{
dockerLabelAllocID: "768b5e8c-a52e-825c-d564-51100230eb62",
},
},
HostConfig: &docker.HostConfig{
NetworkMode: "none",
Expand Down

0 comments on commit c0ce214

Please sign in to comment.