Skip to content

Commit c0f3fc5

Browse files
committed
Linter
1 parent 987e405 commit c0f3fc5

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

loadtest/castai.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (c *CastAITestServer) GetActions(ctx context.Context, _ string) ([]*castai.
8585
c.log.Info(fmt.Sprintf("No actions to return in %v", c.cfg.TimeoutWaitingForActions))
8686
return nil, nil
8787
case <-ctx.Done():
88-
return nil, fmt.Errorf("context done with cause (%v), err (%v)", context.Cause(ctx), ctx.Err())
88+
return nil, fmt.Errorf("context done with cause (%w), err (%w)", context.Cause(ctx), ctx.Err())
8989
}
9090

9191
// Attempt to drain up to max items from the channel.
@@ -97,7 +97,7 @@ func (c *CastAITestServer) GetActions(ctx context.Context, _ string) ([]*castai.
9797
// If we haven't received enough items, just flush.
9898
return actionsToReturn, nil
9999
case <-ctx.Done():
100-
return nil, fmt.Errorf("context done with cause (%v), err (%v)", context.Cause(ctx), ctx.Err())
100+
return nil, fmt.Errorf("context done with cause (%w), err (%w)", context.Cause(ctx), ctx.Err())
101101
}
102102
}
103103

loadtest/http.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package loadtest
22

33
import (
4+
"context"
45
"encoding/json"
56
"fmt"
67
"net/http"
78

89
"github.com/castai/cluster-controller/internal/castai"
910
)
1011

11-
func NewHttpServer(cfg Config, testServer *CastAITestServer) error {
12-
12+
func NewHttpServer(ctx context.Context, cfg Config, testServer *CastAITestServer) error {
1313
http.HandleFunc("/v1/kubernetes/clusters/{cluster_id}/actions", func(w http.ResponseWriter, r *http.Request) {
1414
result, err := testServer.GetActions(r.Context(), "")
1515
if err != nil {
@@ -27,8 +27,6 @@ func NewHttpServer(cfg Config, testServer *CastAITestServer) error {
2727
http.Error(w, err.Error(), http.StatusInternalServerError)
2828
return
2929
}
30-
31-
return
3230
})
3331

3432
http.HandleFunc("/v1/kubernetes/clusters/{cluster_id}/actions/{action_id}/ack", func(w http.ResponseWriter, r *http.Request) {
@@ -45,8 +43,6 @@ func NewHttpServer(cfg Config, testServer *CastAITestServer) error {
4543
http.Error(w, err.Error(), http.StatusInternalServerError)
4644
return
4745
}
48-
49-
return
5046
})
5147

5248
http.HandleFunc("/v1/kubernetes/clusters/{cluster_id}/actions/logs", func(w http.ResponseWriter, r *http.Request) {
@@ -62,10 +58,8 @@ func NewHttpServer(cfg Config, testServer *CastAITestServer) error {
6258
http.Error(w, err.Error(), http.StatusInternalServerError)
6359
return
6460
}
65-
66-
return
6761
})
6862

63+
//nolint:gosec // Missing timeouts are not a real issue here.
6964
return http.ListenAndServe(fmt.Sprintf(":%d", cfg.Port), nil)
70-
7165
}

loadtest/scenarios/scenario.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func RunScenario(
3737
logger *slog.Logger,
3838
clientset kubernetes.Interface,
3939
) error {
40+
//nolint:gosec // No point to use crypto/rand.
4041
namespaceForTest := fmt.Sprintf("test-namespace-%d", rand.Int31())
4142
logger = logger.With("namespace", namespaceForTest, "scenario", scenario.Name())
4243

loadtest/scenarios/stuck_drain.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
"github.com/castai/cluster-controller/internal/castai"
1818
)
1919

20-
func StuckDrain(nodeCount int, deploymentReplicas int, log *slog.Logger) TestScenario {
20+
func StuckDrain(nodeCount, deploymentReplicas int, log *slog.Logger) TestScenario {
2121
return &stuckDrainScenario{
2222
nodeCount: nodeCount,
2323
deploymentReplicas: deploymentReplicas,
@@ -56,6 +56,7 @@ func (s *stuckDrainScenario) Preparation(ctx context.Context, namespace string,
5656
s.log.Info(fmt.Sprintf("Creating deployment on node %s", nodeName))
5757
deployment, pdb := DeploymentWithStuckPDB(fmt.Sprintf("fake-deployment-%s-%d", node.Name, i))
5858
deployment.ObjectMeta.Namespace = namespace
59+
//nolint:gosec // Not afraid of overflow here.
5960
deployment.Spec.Replicas = lo.ToPtr(int32(s.deploymentReplicas))
6061
deployment.Spec.Template.Spec.NodeName = nodeName
6162
pdb.ObjectMeta.Namespace = namespace

loadtest/scenarios/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func WaitUntil(ctx context.Context, duration time.Duration, condition func() boo
1313
return false
1414
default:
1515
}
16-
if time.Now().Sub(start) > duration {
16+
if time.Since(start) > duration {
1717
return false
1818
}
1919
if condition() {

0 commit comments

Comments
 (0)