Skip to content

Commit

Permalink
Fix using deprecated pointer type
Browse files Browse the repository at this point in the history
Signed-off-by: Jian Wang <[email protected]>
  • Loading branch information
w13915984028 committed Oct 23, 2024
1 parent d9809e6 commit 654c5ce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ require (
k8s.io/api v0.28.6
k8s.io/apimachinery v0.29.2
k8s.io/client-go v12.0.0+incompatible
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
kubevirt.io/api v1.1.1
)

Expand Down Expand Up @@ -216,6 +215,7 @@ require (
k8s.io/kube-aggregator v0.26.4 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/mount-utils v0.30.0 // indirect
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 // indirect
kubevirt.io/client-go v1.1.1 // indirect
kubevirt.io/containerized-data-importer-api v1.57.0-alpha1 // indirect
kubevirt.io/controller-lifecycle-operator-sdk/api v0.0.0-20220329064328-f3cc58c6ed90 // indirect
Expand Down
7 changes: 4 additions & 3 deletions pkg/lb/servicelb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"

"github.com/harvester/harvester-load-balancer/pkg/apis/loadbalancer.harvesterhci.io"
lbv1 "github.com/harvester/harvester-load-balancer/pkg/apis/loadbalancer.harvesterhci.io/v1beta1"
Expand Down Expand Up @@ -567,6 +566,7 @@ const dummyEndpointIPv4Address = "10.52.0.255"
const dummyEndpointID = "dummy347-546a-4642-9da6-5608endpoint"

func appendDummyEndpoint(eps []discoveryv1.Endpoint, lb *lbv1.LoadBalancer) []discoveryv1.Endpoint {
cond := true
endpoint := discoveryv1.Endpoint{
Addresses: []string{dummyEndpointIPv4Address},
TargetRef: &corev1.ObjectReference{
Expand All @@ -575,7 +575,7 @@ func appendDummyEndpoint(eps []discoveryv1.Endpoint, lb *lbv1.LoadBalancer) []di
UID: dummyEndpointID,
},
Conditions: discoveryv1.EndpointConditions{
Ready: pointer.Bool(true),
Ready: &cond,
},
}
eps = append(eps, endpoint)
Expand Down Expand Up @@ -642,6 +642,7 @@ func (m *Manager) constructEndpointSliceFromBackendServers(cur *discoveryv1.Endp
}
}
// add the non-existing endpoint
cond := false
if !existing {
endpoint := discoveryv1.Endpoint{
Addresses: []string{address},
Expand All @@ -651,7 +652,7 @@ func (m *Manager) constructEndpointSliceFromBackendServers(cur *discoveryv1.Endp
UID: server.GetUID(),
},
Conditions: discoveryv1.EndpointConditions{
Ready: pointer.Bool(true),
Ready: &cond,
},
}
endpoints = append(endpoints, endpoint)
Expand Down
7 changes: 4 additions & 3 deletions pkg/prober/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestManager(t *testing.T) {
}); err != nil {
t.Errorf("case: %s, add worker failed %s", healthyCase, err.Error())
}
time.Sleep(time.Second * 2)
time.Sleep(time.Second * 10)
if len(mng.workers) == 0 {
t.Errorf("case: %s, add worker failed", healthyCase)
}
Expand All @@ -54,14 +54,15 @@ func TestManager(t *testing.T) {
FailureThreshold: 2,
Timeout: time.Second,
Period: time.Second,
InitialCondition: true,
// it depends on where to run the test cases, some may block on dns looking up, set initial condition to false
InitialCondition: false,
}); err != nil {
t.Errorf("case: %s, add worker failed %s", unhealthyCase, err.Error())
}
if len(mng.workers[unhealthyCase]) != 1 {
t.Errorf("case: %s, Add worker failed, len=%d", unhealthyCase, len(mng.workers[unhealthyCase]))
}
time.Sleep(time.Second * 5)
time.Sleep(time.Second * 10)
if mng.workers[unhealthyCase][unhealthyAddress].condition {
t.Errorf("it should not be able to connect %s", unhealthyAddress)
}
Expand Down

0 comments on commit 654c5ce

Please sign in to comment.