-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loki: Append loopback to ingester net interface default list (#4570)
* Move LoopbackInterfaceName to its own package. - Create new package `util/net` and puts `LoopbackInterfaceName` there - Modify distributor_test to use `util/net` package * By default, append loopback to ingester interfaces. - Append the loopback net interface to the list of net interfaces used by the ingester ring. The append only occurs if the ingester net interfaces are default - Add CHANGELOG entry * Test ring net interface behavior. - Add tests to check the current net interface name resolution. The tests checks if the ingester ring net interface names are correctly copied to other rings
- Loading branch information
1 parent
96e6475
commit 3c16658
Showing
5 changed files
with
122 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net | ||
|
||
import ( | ||
"fmt" | ||
"net" | ||
) | ||
|
||
// LoopbackInterfaceName search for the name of a loopback interface in the list | ||
// of the system's network interfaces and returns the first one found. | ||
func LoopbackInterfaceName() (string, error) { | ||
is, err := net.Interfaces() | ||
if err != nil { | ||
return "", fmt.Errorf("can't retrieve loopback interface name: %s", err) | ||
} | ||
|
||
for _, i := range is { | ||
if i.Flags&net.FlagLoopback != 0 { | ||
return i.Name, nil | ||
} | ||
} | ||
|
||
return "", fmt.Errorf("can't retrieve loopback interface name") | ||
} |