Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump github.com/golangci/golangci-lint from 1.60.1 to 1.60.3 in /tools in the tools group #1715

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address golangci-lint v1.60.3 errors
Specifically, gosec "integer overflow conversion" issues.

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
tpantelis committed Aug 28, 2024
commit 4a2c2b9660404f7864aeb725b13043fc6daf259f
2 changes: 1 addition & 1 deletion test/e2e/framework/docker.go
Original file line number Diff line number Diff line change
@@ -96,7 +96,7 @@ func (d *Docker) RunCommandUntil(command ...string) (string, string) {

stdout, stderr, err = d.runCommand(command...)
return err
}, time.Duration(TestContext.OperationTimeout)*time.Second, 5*time.Second).Should(Succeed(),
}, TestContext.OperationTimeoutToDuration(), 5*time.Second).Should(Succeed(),
"Error attempting to run %v", append([]string{}, command...))

return stdout, stderr
4 changes: 2 additions & 2 deletions test/e2e/framework/endpoints.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ import (
typedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
)

func (f *Framework) CreateTCPEndpoints(cluster ClusterIndex, epName, portName, address string, port int) *corev1.Endpoints {
func (f *Framework) CreateTCPEndpoints(cluster ClusterIndex, epName, portName, address string, port int32) *corev1.Endpoints {
endpointsSpec := corev1.Endpoints{
ObjectMeta: metav1.ObjectMeta{
Name: epName,
@@ -41,7 +41,7 @@ func (f *Framework) CreateTCPEndpoints(cluster ClusterIndex, epName, portName, a
Ports: []corev1.EndpointPort{
{
Name: portName,
Port: int32(port),
Port: port,
Protocol: corev1.ProtocolTCP,
},
},
3 changes: 1 addition & 2 deletions test/e2e/framework/framework.go
Original file line number Diff line number Diff line change
@@ -567,8 +567,7 @@ func AwaitUntil(opMsg string, doOperation DoOperationFunc, checkResult CheckResu
func AwaitResultOrError(opMsg string, doOperation DoOperationFunc, checkResult CheckResultFunc) (interface{}, string, error) {
var finalResult interface{}
var lastMsg string
err := wait.PollUntilContextTimeout(context.Background(), 500*time.Millisecond,
time.Duration(TestContext.OperationTimeout)*time.Second, true,
err := wait.PollUntilContextTimeout(context.Background(), 500*time.Millisecond, TestContext.OperationTimeoutToDuration(), true,
func(_ context.Context) (bool, error) {
result, err := doOperation()
if err != nil {
28 changes: 14 additions & 14 deletions test/e2e/framework/network_pods.go
Original file line number Diff line number Diff line change
@@ -68,12 +68,12 @@ type NetworkPodConfig struct {
Type NetworkPodType
Cluster ClusterIndex
Scheduling NetworkPodScheduling
Port int
Data string
NumOfDataBufs uint
RemoteIP string
ConnectionTimeout uint
ConnectionAttempts uint
Port int32
Networking NetworkingType
ContainerName string
ImageName string
@@ -281,10 +281,10 @@ func (np *NetworkPod) buildTCPCheckListenerPod() {
" | nc -w $CONN_TIMEOUT -l -v -p $LISTEN_PORT -s 0.0.0.0 >/dev/termination-log 2>&1",
},
Env: []v1.EnvVar{
{Name: "LISTEN_PORT", Value: strconv.Itoa(np.Config.Port)},
{Name: "LISTEN_PORT", Value: strconv.FormatInt(int64(np.Config.Port), 10)},
{Name: "SEND_STRING", Value: np.Config.Data},
{Name: "CONN_TIMEOUT", Value: strconv.Itoa(int(np.Config.ConnectionTimeout * np.Config.ConnectionAttempts))},
{Name: "BUFS_NUM", Value: strconv.Itoa(int(np.Config.NumOfDataBufs))},
{Name: "CONN_TIMEOUT", Value: strconv.FormatUint(uint64(np.Config.ConnectionTimeout*np.Config.ConnectionAttempts), 10)},
{Name: "BUFS_NUM", Value: strconv.FormatUint(uint64(np.Config.NumOfDataBufs), 10)},
},
SecurityContext: podSecurityContext,
},
@@ -334,13 +334,13 @@ func (np *NetworkPod) buildTCPCheckConnectorPod() {
" fi; done >/dev/termination-log 2>&1",
},
Env: []v1.EnvVar{
{Name: "REMOTE_PORT", Value: strconv.Itoa(np.Config.Port)},
{Name: "REMOTE_PORT", Value: strconv.FormatInt(int64(np.Config.Port), 10)},
{Name: "SEND_STRING", Value: np.Config.Data},
{Name: "REMOTE_IP", Value: np.Config.RemoteIP},
{Name: "CONN_TRIES", Value: strconv.Itoa(int(np.Config.ConnectionAttempts))},
{Name: "CONN_TIMEOUT", Value: strconv.Itoa(int(np.Config.ConnectionTimeout))},
{Name: "RETRY_SLEEP", Value: strconv.Itoa(int(np.Config.ConnectionTimeout / 2))},
{Name: "BUFS_NUM", Value: strconv.Itoa(int(np.Config.NumOfDataBufs))},
{Name: "CONN_TRIES", Value: strconv.FormatUint(uint64(np.Config.ConnectionAttempts), 10)},
{Name: "CONN_TIMEOUT", Value: strconv.FormatUint(uint64(np.Config.ConnectionTimeout), 10)},
{Name: "RETRY_SLEEP", Value: strconv.FormatUint(uint64(np.Config.ConnectionTimeout/2), 10)},
{Name: "BUFS_NUM", Value: strconv.FormatUint(uint64(np.Config.NumOfDataBufs), 10)},
},
SecurityContext: podSecurityContext,
},
@@ -384,10 +384,10 @@ func (np *NetworkPod) buildThroughputClientPod() {
},
Env: []v1.EnvVar{
{Name: "TARGET_IP", Value: np.Config.RemoteIP},
{Name: "TARGET_PORT", Value: strconv.Itoa(np.Config.Port)},
{Name: "CONN_TRIES", Value: strconv.Itoa(int(np.Config.ConnectionAttempts))},
{Name: "RETRY_SLEEP", Value: strconv.Itoa(int(np.Config.ConnectionTimeout))},
{Name: "CONN_TIMEOUT", Value: strconv.Itoa(int(np.Config.ConnectionTimeout * 1000))},
{Name: "TARGET_PORT", Value: strconv.FormatInt(int64(np.Config.Port), 10)},
{Name: "CONN_TRIES", Value: strconv.FormatUint(uint64(np.Config.ConnectionAttempts), 10)},
{Name: "RETRY_SLEEP", Value: strconv.FormatUint(uint64(np.Config.ConnectionTimeout), 10)},
{Name: "CONN_TIMEOUT", Value: strconv.FormatUint(uint64(np.Config.ConnectionTimeout*1000), 10)},
},
SecurityContext: podSecurityContext,
},
@@ -422,7 +422,7 @@ func (np *NetworkPod) buildThroughputServerPod() {
ImagePullPolicy: v1.PullAlways,
Command: []string{"sh", "-c", "iperf3 -s -p $TARGET_PORT"},
Env: []v1.EnvVar{
{Name: "TARGET_PORT", Value: strconv.Itoa(np.Config.Port)},
{Name: "TARGET_PORT", Value: strconv.FormatInt(int64(np.Config.Port), 10)},
},
SecurityContext: podSecurityContext,
},
12 changes: 6 additions & 6 deletions test/e2e/framework/services.go
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ const (
TestAppLabel = "test-app"
)

func (f *Framework) NewService(name, portName string, port int, protocol corev1.Protocol, selector map[string]string,
func (f *Framework) NewService(name, portName string, port int32, protocol corev1.Protocol, selector map[string]string,
isHeadless bool,
) *corev1.Service {
service := corev1.Service{
@@ -42,9 +42,9 @@ func (f *Framework) NewService(name, portName string, port int, protocol corev1.
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{{
Port: int32(port),
Port: port,
Name: portName,
TargetPort: intstr.FromInt(port),
TargetPort: intstr.FromInt32(port),
Protocol: protocol,
}},
},
@@ -62,15 +62,15 @@ func (f *Framework) NewService(name, portName string, port int, protocol corev1.
return &service
}

func (f *Framework) CreateTCPService(cluster ClusterIndex, selectorName string, port int) *corev1.Service {
func (f *Framework) CreateTCPService(cluster ClusterIndex, selectorName string, port int32) *corev1.Service {
tcpService := f.NewService(fmt.Sprintf("test-svc-%s", selectorName), "tcp", port, corev1.ProtocolTCP,
map[string]string{TestAppLabel: selectorName}, false)
sc := KubeClients[cluster].CoreV1().Services(f.Namespace)

return f.CreateService(sc, tcpService)
}

func (f *Framework) CreateHeadlessTCPService(cluster ClusterIndex, selectorName string, port int) *corev1.Service {
func (f *Framework) CreateHeadlessTCPService(cluster ClusterIndex, selectorName string, port int32) *corev1.Service {
tcpService := f.NewService(fmt.Sprintf("test-svc-%s", selectorName), "tcp", port, corev1.ProtocolTCP,
map[string]string{TestAppLabel: selectorName}, true)
sc := KubeClients[cluster].CoreV1().Services(f.Namespace)
@@ -121,7 +121,7 @@ func (f *Framework) NewNginxService(cluster ClusterIndex) *corev1.Service {
return f.CreateService(sc, &nginxService)
}

func (f *Framework) CreateTCPServiceWithoutSelector(cluster ClusterIndex, svcName, portName string, port int) *corev1.Service {
func (f *Framework) CreateTCPServiceWithoutSelector(cluster ClusterIndex, svcName, portName string, port int32) *corev1.Service {
serviceSpec := f.NewService(svcName, portName, port, corev1.ProtocolTCP, nil, false)
sc := KubeClients[cluster].CoreV1().Services(f.Namespace)

6 changes: 6 additions & 0 deletions test/e2e/framework/test_context.go
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ import (
"flag"
"os"
"strings"
"time"

"github.com/onsi/ginkgo/v2/types"
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -87,3 +88,8 @@ func ValidateFlags(t *TestContextType) {
klog.Fatalf("at least one kubernetes context must be specified.")
}
}

func (t *TestContextType) OperationTimeoutToDuration() time.Duration {
//nolint:gosec // Ignore G115: integer overflow conversion uint -> int64
return time.Duration(TestContext.OperationTimeout) * time.Second
}