Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

driver: add support for configuring extra_hosts in podman tasks #255

Merged
merged 1 commit into from
Jun 12, 2023

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Jun 12, 2023

This PR adds support for setting extra_hosts on in podman task configuration,
bringing the podman driver support up to par with the docker driver.

Closes #244

This PR adds support for setting extra_hosts on in podman task configuration,
bringing the podman driver support up to par with the docker driver.

Closes #373
Comment on lines +711 to +712
if cleanupErr := d.podman.ContainerDelete(d.ctx, containerID, true, true); cleanupErr != nil {
d.logger.Error("failed to clean up from an error in Start", "error", cleanupErr)
Copy link
Member Author

@shoenig shoenig Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fun fact - this would overwrite err during the cleanup() call, causing what is now startErr to always be nil at the time it was logged, which was beyond confusing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof..nice catch!

@shoenig shoenig marked this pull request as ready for review June 12, 2023 18:56
@shoenig
Copy link
Member Author

shoenig commented Jun 12, 2023

Spot check,

job file

job "sleep" {
  group "group" {
    count = 1

    task "sleep" {
      driver = "podman"

      config {
        image = "docker.io/bash:5"
        args  = ["sleep", "infinity"]

        extra_hosts = ["test4.localhost:127.0.0.2", "test6.localhost:[::1]"]
      }

      resources {
        cores  = 2
        memory = 64
      }
    }
  }
}

exec into the container and cat /etc/hosts, see our extra hosts got added

➜ noamd alloc exec 28 /bin/sh
/ # cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 diablo

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.2 test4.localhost
[::1] test6.localhost
10.88.0.53      581de9968e4c sleep-28c28dd8-62e5-dfbc-6411-54101a77c90e
10.88.0.1 host.containers.internal

Copy link
Contributor

@lgfa29 lgfa29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just needs a CHANGELOG entry 😄

Comment on lines +711 to +712
if cleanupErr := d.podman.ContainerDelete(d.ctx, containerID, true, true); cleanupErr != nil {
d.logger.Error("failed to clean up from an error in Start", "error", cleanupErr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof..nice catch!

@shoenig shoenig merged commit b43d68c into main Jun 12, 2023
@shoenig shoenig deleted the set-add-host branch June 12, 2023 19:32
@shoenig shoenig added this to the v0.5.0 milestone Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Podman] Support task.config.extra_hosts also for Podman Driver
2 participants