Skip to content

Commit

Permalink
cilium-cli: use agent container name rather than process name
Browse files Browse the repository at this point in the history
Use defaults.AgentContainerName instead of components.CiliumAgentName.
Both have the same value ("cilium-agent") currently, but the former
makes it more obvious that we're interested in the name of the Cilium
agent container.

Signed-off-by: Tobias Klauser <tobias@cilium.io>
  • Loading branch information
tklauser committed Aug 26, 2024
1 parent b543910 commit cfbb71a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cilium-cli/connectivity/check/metricssource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package check
import (
"fmt"

"github.com/cilium/cilium/pkg/components"
"github.com/cilium/cilium/cilium-cli/defaults"
)

const prometheusContainerPortName = "prometheus"
Expand All @@ -32,15 +32,15 @@ func (ct *ConnectivityTest) CiliumAgentMetrics() MetricsSource {
}

source := MetricsSource{
Name: components.CiliumAgentName,
Name: defaults.AgentContainerName,
}

// Retrieve the container port value for Prometheus.
for _, p := range ciliumPods {
source.Pods = append(source.Pods, p)
// parse all the containers
for _, c := range p.Pod.Spec.Containers {
if c.Name == components.CiliumAgentName {
if c.Name == defaults.AgentContainerName {
// parse all the container ports
for _, port := range c.Ports {
if port.Name == prometheusContainerPortName {
Expand Down
14 changes: 7 additions & 7 deletions cilium-cli/connectivity/check/metricssource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ package check
import (
"testing"

"github.com/cilium/cilium/pkg/components"

"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"

"github.com/cilium/cilium/cilium-cli/defaults"
)

func TestConnectivityTestCiliumAgentMetrics(t *testing.T) {
Expand All @@ -18,7 +18,7 @@ func TestConnectivityTestCiliumAgentMetrics(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: components.CiliumAgentName,
Name: defaults.AgentContainerName,
Ports: []corev1.ContainerPort{
{
Name: prometheusContainerPortName,
Expand All @@ -37,7 +37,7 @@ func TestConnectivityTestCiliumAgentMetrics(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: components.CiliumAgentName,
Name: defaults.AgentContainerName,
Ports: []corev1.ContainerPort{
{
Name: "peer-service",
Expand All @@ -57,10 +57,10 @@ func TestConnectivityTestCiliumAgentMetrics(t *testing.T) {
}{
"nominal case": {
ct: ConnectivityTest{ciliumPods: map[string]Pod{
components.CiliumAgentName: ciliumPod,
defaults.AgentContainerName: ciliumPod,
}},
want: MetricsSource{
Name: components.CiliumAgentName,
Name: defaults.AgentContainerName,
Pods: []Pod{ciliumPod},
Port: "9962",
},
Expand All @@ -70,7 +70,7 @@ func TestConnectivityTestCiliumAgentMetrics(t *testing.T) {
want: MetricsSource{},
},
"no prometheus container port": {
ct: ConnectivityTest{ciliumPods: map[string]Pod{components.CiliumAgentName: podWithPrometheusMissing}},
ct: ConnectivityTest{ciliumPods: map[string]Pod{defaults.AgentContainerName: podWithPrometheusMissing}},
want: MetricsSource{},
},
}
Expand Down
8 changes: 4 additions & 4 deletions cilium-cli/connectivity/check/result_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ package check
import (
"testing"

"github.com/cilium/cilium/pkg/components"

prommodel "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"

"github.com/cilium/cilium/cilium-cli/defaults"
)

func TestExpectMetricsToIncrease(t *testing.T) {
Expand All @@ -19,7 +19,7 @@ func TestExpectMetricsToIncrease(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: components.CiliumAgentName,
Name: defaults.AgentContainerName,
Ports: []corev1.ContainerPort{
{
Name: "prometheus",
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestExpectMetricsToIncrease(t *testing.T) {
"metric name not present in the metrics before, counters should be set 0": {
metrics: "cilium_forward_count_total",
source: MetricsSource{
Name: components.CiliumAgentName,
Name: defaults.AgentContainerName,
Pods: []Pod{ciliumPod},
Port: "9962",
},
Expand Down

0 comments on commit cfbb71a

Please sign in to comment.