Skip to content

Commit 59e0c50

Browse files
committed
fmt
1 parent 0c1b9fa commit 59e0c50

File tree

3 files changed

+37
-41
lines changed

3 files changed

+37
-41
lines changed

internal/ingress/controller/nginx.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ func NewNGINXController(config *Configuration, mc metric.Collector) *NGINXContro
146146

147147
if config.UpdateStatus {
148148
n.syncStatus = status.NewStatusSyncer(status.Config{
149-
Client: config.Client,
150-
PublishService: config.PublishService,
151-
PublishStatusAddress: config.PublishStatusAddress,
152-
IngressLister: n.store,
153-
UpdateStatusOnShutdown: config.UpdateStatusOnShutdown,
154-
UseNodeInternalIP: config.UseNodeInternalIP,
149+
Client: config.Client,
150+
PublishService: config.PublishService,
151+
PublishStatusAddress: config.PublishStatusAddress,
152+
IngressLister: n.store,
153+
UpdateStatusOnShutdown: config.UpdateStatusOnShutdown,
154+
UseNodeInternalIP: config.UseNodeInternalIP,
155155
UseElectionIDSelectorOnShutdown: config.UseElectionIDSelectorOnShutdown,
156-
ElectionID: config.ElectionID,
156+
ElectionID: config.ElectionID,
157157
})
158158
} else {
159159
klog.Warning("Update of Ingress status is disabled (flag --update-status)")

internal/ingress/status/status.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ func nameOrIPToLoadBalancerIngress(nameOrIP string) v1.IngressLoadBalancerIngres
187187
// listControllerPods returns a list of running pods with controller labels
188188
func (s *statusSync) listControllerPods(useElectionID bool) (*apiv1.PodList, error) {
189189
podLabel := make(map[string]string)
190-
190+
191191
if useElectionID {
192192
// When using electionID, only look for pods with the electionID label
193193
// This is more specific and will correctly identify pods belonging to the same controller group
194194
// Note: This requires the electionID label to be set on the pods (done by helm chart)
195-
podLabel[ElectionIDLabelKey] = s.Config.ElectionID
195+
podLabel[ElectionIDLabelKey] = s.ElectionID
196196
} else {
197197
// As a standard, app.kubernetes.io are "reserved well-known" labels.
198198
// In our case, we add those labels as identifiers of the Ingress
@@ -206,9 +206,8 @@ func (s *statusSync) listControllerPods(useElectionID bool) (*apiv1.PodList, err
206206
}
207207
}
208208
}
209-
210209
return s.Client.CoreV1().Pods(k8s.IngressPodDetails.Namespace).List(
211-
context.TODO(),
210+
context.TODO(),
212211
metav1.ListOptions{
213212
LabelSelector: labels.SelectorFromSet(podLabel).String(),
214213
})

internal/ingress/status/status_test.go

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,9 @@ func TestListControllerPods(t *testing.T) {
755755
useElectionIDSelector: true,
756756
electionID: "test-election-id",
757757
podLabels: map[string]string{
758-
"app": "ingress-nginx",
759-
"pod-template-hash": "abc123",
760-
ElectionIDLabelKey: "test-election-id",
758+
"app": "ingress-nginx",
759+
"pod-template-hash": "abc123",
760+
ElectionIDLabelKey: "test-election-id",
761761
},
762762
expectedLabelSelectorContains: ElectionIDLabelKey,
763763
},
@@ -766,7 +766,7 @@ func TestListControllerPods(t *testing.T) {
766766
useElectionIDSelector: false,
767767
electionID: "test-election-id",
768768
podLabels: map[string]string{
769-
"app": "ingress-nginx",
769+
"app": "ingress-nginx",
770770
"pod-template-hash": "abc123",
771771
},
772772
expectedLabelSelectorContains: "app=ingress-nginx",
@@ -802,9 +802,9 @@ func TestListControllerPods(t *testing.T) {
802802
// Create a status sync with our test configuration
803803
st := &statusSync{
804804
Config: Config{
805-
Client: client,
805+
Client: client,
806806
UseElectionIDSelectorOnShutdown: tc.useElectionIDSelector,
807-
ElectionID: tc.electionID,
807+
ElectionID: tc.electionID,
808808
},
809809
}
810810

@@ -824,11 +824,8 @@ func TestListControllerPods(t *testing.T) {
824824
if len(podList.Items) != 0 && tc.podLabels[ElectionIDLabelKey] != tc.electionID {
825825
t.Errorf("expected 0 pods but got %d", len(podList.Items))
826826
}
827-
} else {
828-
// Should have exactly one pod
829-
if len(podList.Items) != 1 {
830-
t.Errorf("expected 1 pod but got %d", len(podList.Items))
831-
}
827+
} else if len(podList.Items) != 1 {
828+
t.Errorf("expected 1 pod but got %d", len(podList.Items))
832829
}
833830
})
834831
}
@@ -837,26 +834,26 @@ func TestListControllerPods(t *testing.T) {
837834
// TestIsRunningMultiplePods tests the isRunningMultiplePods function with different label selectors
838835
func TestIsRunningMultiplePods(t *testing.T) {
839836
testCases := []struct {
840-
name string
841-
useElectionID bool
842-
electionID string
843-
podLabels []map[string]string
844-
expectedMultiple bool
837+
name string
838+
useElectionID bool
839+
electionID string
840+
podLabels []map[string]string
841+
expectedMultiple bool
845842
}{
846843
{
847844
name: "multiple pods with same electionID",
848845
useElectionID: true,
849846
electionID: "test-election-id",
850847
podLabels: []map[string]string{
851848
{
852-
"app": "ingress-nginx",
849+
"app": "ingress-nginx",
853850
"pod-template-hash": "abc123",
854-
ElectionIDLabelKey: "test-election-id",
851+
ElectionIDLabelKey: "test-election-id",
855852
},
856853
{
857-
"app": "ingress-nginx",
854+
"app": "ingress-nginx",
858855
"pod-template-hash": "def456",
859-
ElectionIDLabelKey: "test-election-id",
856+
ElectionIDLabelKey: "test-election-id",
860857
},
861858
},
862859
expectedMultiple: true,
@@ -867,14 +864,14 @@ func TestIsRunningMultiplePods(t *testing.T) {
867864
electionID: "test-election-id",
868865
podLabels: []map[string]string{
869866
{
870-
"app": "ingress-nginx",
867+
"app": "ingress-nginx",
871868
"pod-template-hash": "abc123",
872-
ElectionIDLabelKey: "test-election-id",
869+
ElectionIDLabelKey: "test-election-id",
873870
},
874871
{
875-
"app": "ingress-nginx",
872+
"app": "ingress-nginx",
876873
"pod-template-hash": "def456",
877-
ElectionIDLabelKey: "other-election-id",
874+
ElectionIDLabelKey: "other-election-id",
878875
},
879876
},
880877
expectedMultiple: false,
@@ -885,9 +882,9 @@ func TestIsRunningMultiplePods(t *testing.T) {
885882
electionID: "test-election-id",
886883
podLabels: []map[string]string{
887884
{
888-
"app": "ingress-nginx",
885+
"app": "ingress-nginx",
889886
"pod-template-hash": "abc123",
890-
ElectionIDLabelKey: "test-election-id",
887+
ElectionIDLabelKey: "test-election-id",
891888
},
892889
},
893890
expectedMultiple: false,
@@ -898,11 +895,11 @@ func TestIsRunningMultiplePods(t *testing.T) {
898895
electionID: "test-election-id",
899896
podLabels: []map[string]string{
900897
{
901-
"app": "ingress-nginx",
898+
"app": "ingress-nginx",
902899
"pod-template-hash": "abc123",
903900
},
904901
{
905-
"app": "ingress-nginx",
902+
"app": "ingress-nginx",
906903
"pod-template-hash": "def456",
907904
},
908905
},
@@ -943,9 +940,9 @@ func TestIsRunningMultiplePods(t *testing.T) {
943940
// Create a status sync with our test configuration
944941
st := &statusSync{
945942
Config: Config{
946-
Client: client,
943+
Client: client,
947944
UseElectionIDSelectorOnShutdown: tc.useElectionID,
948-
ElectionID: tc.electionID,
945+
ElectionID: tc.electionID,
949946
},
950947
}
951948

0 commit comments

Comments
 (0)