Skip to content

Introduce a single -default.interface flag #2889

Open

Description

@roidelapluie
  -compactor.ring.instance-interface value
        Name of network interface to read address from. (default [eth0 en0])
  -distributor.ring.instance-interface value
        Name of network interface to read address from. (default [eth0 en0])
  -experimental.store-gateway.sharding-ring.instance-interface value
        Name of network interface to read address from. (default [eth0 en0])-
  -ingester.lifecycler.interface value
        Name of network interface to read address from. (default [eth0 en0])
  -ruler.ring.instance-interface value
        Name of network interface to read address from. (default [eth0 en0])

We could have a -default.interfaces flag so we do not need to overrule all those flags when we do not have en0 or eth0 on a machine.

Activity

  1. pracucci commented on Jul 16, 2020

    @pracucci
    Contributor

    Thanks for raising the issue. Let me try to approach the issue from another angle. If you had this issue I guess your system doesn't have neither eth0 and en0. If so, could you share which network interfaces your system has, please? Maybe we could just improve defaults.

  2. roidelapluie commented on Jul 16, 2020

    @roidelapluie
    ContributorAuthor

    enp0s31f6 and wlp3s0 :)

  3. pracucci commented on Jul 16, 2020

    @pracucci
    Contributor

    Nice! I'm wondering if, instead of failing when the preferred interfaces don't exist, we could just fallback to the first defined interface in the system. Honestly, I would be happy if you wouldn't have to configure the interface name at all.

    @pstibrany any thought on this?

  4. roidelapluie commented on Jul 16, 2020

    @roidelapluie
    ContributorAuthor

    Alertmanager takes the first rfc1918 ip address by default

  5. pracucci commented on Jul 16, 2020

    @pracucci
    Contributor

    We could do the same as well, while still keeping the option to allow to configure the preferred one.

  6. stale commented on Sep 14, 2020

    @stale

    This issue has been automatically marked as stale because it has not had any activity in the past 60 days. It will be closed in 15 days if no further activity occurs. Thank you for your contributions.

  7. pracucci commented on Sep 15, 2020

    @pracucci
    Contributor

    Still valid. Feedback is good.

  8. roidelapluie commented on Sep 15, 2020

    @roidelapluie
    ContributorAuthor

    I am now doing ./cortex-linux-amd64 $(./cortex-linux-amd64 --help|grep eth0 -B 1|grep value|sed s/value/lo/) locally.

  9. sandy2008 commented on Oct 28, 2026

    @sandy2008
    Contributor

    Still the case on master, and there are now eight of these flags (alertmanager, compactor, distributor, frontend, ingester, querier, ruler and store-gateway), all defaulting to [eth0 en0]. The address lookup still only tries the listed interfaces and fails with "no address found" otherwise (

    cortex/pkg/ring/util.go

    Lines 154 to 186 in 5d93557

    func getFirstAddressOf(names []string, logger log.Logger) (string, error) {
    var ipAddr string
    for _, name := range names {
    inf, err := net.InterfaceByName(name)
    if err != nil {
    level.Warn(logger).Log("msg", "error getting interface", "inf", name, "err", err)
    continue
    }
    addrs, err := inf.Addrs()
    if err != nil {
    level.Warn(logger).Log("msg", "error getting addresses for interface", "inf", name, "err", err)
    continue
    }
    if len(addrs) <= 0 {
    level.Warn(logger).Log("msg", "no addresses found for interface", "inf", name, "err", err)
    continue
    }
    if ip := filterIPs(addrs); ip != "" {
    ipAddr = ip
    }
    if strings.HasPrefix(ipAddr, `169.254.`) || ipAddr == "" {
    continue
    }
    return ipAddr, nil
    }
    if ipAddr == "" {
    return "", fmt.Errorf("no address found for %s", names)
    }
    if strings.HasPrefix(ipAddr, `169.254.`) {
    level.Warn(logger).Log("msg", "using automatic private ip", "address", ipAddr)
    }
    return ipAddr, nil
    }
    , with an identical copy in pkg/util/net.go used by the frontend), so the fallback suggested above would remove the need to override each flag on hosts without those interface names.

  10. princecherry9905 commented on Dec 3, 2026

    @princecherry9905

    Hello maintainers,

    I would like to work on this issue. I have experience with Go and cloud-native backend systems, and I’ve followed the discussion on unifying the -default.interface flag across Cortex components and improving the default interface fallback behavior.

    If this issue is still open for external contributors, could you please assign it to me? I will review the current per-component interface flags, propose and implement the unified flag/fallback behavior with appropriate tests, and submit a PR following the project's guidelines.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions