mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-03-21 18:47:06 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cc9bd55ad | ||
|
|
72832bcbc4 | ||
|
|
a461b0ffd5 | ||
|
|
7609a3ab3f | ||
|
|
588c1a0173 | ||
|
|
79bb860f11 | ||
|
|
94965624cf | ||
|
|
c49fc9925c |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
@@ -39,7 +39,6 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=download
|
||||
platforms: linux/amd64,linux/arm64
|
||||
target: simple
|
||||
- name: Build vendor image
|
||||
@@ -50,6 +49,5 @@ jobs:
|
||||
flavor: |
|
||||
suffix: -vendor,onlatest=false
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=vendor
|
||||
platforms: linux/amd64,linux/arm64
|
||||
target: vendor
|
||||
|
||||
4
.github/workflows/publish.yml
vendored
4
.github/workflows/publish.yml
vendored
@@ -35,7 +35,6 @@ jobs:
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=download
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
@@ -49,9 +48,8 @@ jobs:
|
||||
flavor: |
|
||||
suffix: -vendor,onlatest=false
|
||||
file: ./Dockerfile
|
||||
build-args: GO_MOD_ACTION=vendor
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
tags: ${{ steps.meta.outputs.tags }}-vendor
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
target: vendor
|
||||
|
||||
@@ -32,6 +32,7 @@ var GoldpingerConfig = struct {
|
||||
UseHostIP bool `long:"use-host-ip" description:"When making the calls, use host ip (defaults to pod ip)" env:"USE_HOST_IP"`
|
||||
LabelSelector string `long:"label-selector" description:"label selector to use to discover goldpinger pods in the cluster" env:"LABEL_SELECTOR" default:"app=goldpinger"`
|
||||
Namespace *string `long:"namespace" description:"namespace to use to discover goldpinger pods in the cluster (empty for all). Defaults to discovering the namespace for the current pod" env:"NAMESPACE"`
|
||||
DisplayNodeName bool `long:"display-nodename" description:"Display nodename other than podname in UI (defaults is podname)." env:"DISPLAY_NODENAME"`
|
||||
KubernetesClient *kubernetes.Clientset
|
||||
|
||||
DnsHosts []string `long:"host-to-resolve" description:"A host to attempt dns resolve on (space delimited)" env:"HOSTS_TO_RESOLVE" env-delim:" "`
|
||||
|
||||
@@ -16,8 +16,9 @@ package goldpinger
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.uber.org/zap"
|
||||
"io/ioutil"
|
||||
|
||||
"go.uber.org/zap"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
k8snet "k8s.io/utils/net"
|
||||
@@ -93,6 +94,14 @@ func getPodIP(p v1.Pod) string {
|
||||
return podIP
|
||||
}
|
||||
|
||||
func getPodNodeName(p v1.Pod) string {
|
||||
if GoldpingerConfig.DisplayNodeName {
|
||||
return p.Spec.NodeName
|
||||
}
|
||||
|
||||
return p.Name
|
||||
}
|
||||
|
||||
// GetAllPods returns a mapping from a pod name to a pointer to a GoldpingerPod(s)
|
||||
func GetAllPods() map[string]*GoldpingerPod {
|
||||
timer := GetLabeledKubernetesCallsTimer()
|
||||
@@ -111,7 +120,7 @@ func GetAllPods() map[string]*GoldpingerPod {
|
||||
podMap := make(map[string]*GoldpingerPod)
|
||||
for _, pod := range pods.Items {
|
||||
podMap[pod.Name] = &GoldpingerPod{
|
||||
Name: pod.Name,
|
||||
Name: getPodNodeName(pod),
|
||||
PodIP: getPodIP(pod),
|
||||
HostIP: getHostIP(pod),
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ var checkResultsMux = sync.Mutex{}
|
||||
// - there is already a pinger with the same name
|
||||
// - the pinger has the same podIP
|
||||
// - the pinger has the same hostIP
|
||||
func exists(existingPods map[string]*GoldpingerPod, new *GoldpingerPod) bool {
|
||||
old, exists := existingPods[new.Name]
|
||||
func exists(existingPods map[string]*GoldpingerPod, podName string, new *GoldpingerPod) bool {
|
||||
old, exists := existingPods[podName]
|
||||
return exists && (old.PodIP == new.PodIP) && (old.HostIP == new.HostIP)
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func updatePingers(resultsChan chan<- PingAllPodsResult) {
|
||||
|
||||
latest := SelectPods()
|
||||
for podName, pod := range latest {
|
||||
if exists(existingPods, pod) {
|
||||
if exists(existingPods, podName, pod) {
|
||||
// This pod continues to exist in the latest iteration of the update
|
||||
// without any changes
|
||||
// Delete it from the set of pods that we wish to delete
|
||||
|
||||
Reference in New Issue
Block a user