Skip to content

Commit d539b65

Browse files
authored
Merge pull request #46 from kubescape/feature/reduced-timeouts
Adding reduced timeouts
2 parents 41dacb0 + db06b33 commit d539b65

File tree

8 files changed

+9
-8
lines changed

8 files changed

+9
-8
lines changed

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_cassandra.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (d *CassandraDiscovery) Discover(sessionHandler servicediscovery.ISessionHa
5454
Username: Username,
5555
Password: Password,
5656
}
57-
cluster.Timeout = time.Second * 3
57+
cluster.Timeout = time.Millisecond * 500
5858

5959
// Create a session
6060
session, err := cluster.CreateSession()

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_etcd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (d *EtcdDiscovery) Discover(sessionHandler servicediscovery.ISessionHandler
4444
zapLogger := zap.NewNop()
4545
config := clientv3.Config{
4646
Endpoints: endpoints,
47-
DialTimeout: 3 * time.Second,
47+
DialTimeout: 500 * time.Millisecond,
4848
Logger: zapLogger,
4949
LogConfig: &zap.Config{
5050
Level: zap.NewAtomicLevelAt(zap.ErrorLevel),

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_kafka.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package applicationlayerdiscovery
22

33
import (
44
"fmt"
5+
"time"
56

67
log "github.com/sirupsen/logrus"
78

@@ -47,7 +48,7 @@ func (k *KafkaDiscovery) Discover(sessionHandler servicediscovery.ISessionHandle
4748
config := sarama.NewConfig()
4849
config.Producer.RequiredAcks = sarama.WaitForAll
4950
config.Producer.Retry.Max = 1
50-
config.Producer.Timeout = 3
51+
config.Producer.Timeout = 500 * time.Millisecond
5152
config.Producer.Return.Successes = true
5253

5354
// Create a new SyncProducer

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_kubeapi.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (d *KubeApiServerDiscovery) Discover(sessionHandler servicediscovery.ISessi
5050
}
5151

5252
// Create an http.Client with the custom transport
53-
client := &http.Client{Transport: tr, Timeout: time.Second * 3}
53+
client := &http.Client{Transport: tr, Timeout: time.Millisecond * 500}
5454

5555
// Send a GET request to the Kubernetes API server
5656
resp, err := client.Get(url)

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_mongodb.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (d *MongoDBDiscovery) Protocol() string {
4545

4646
func (d *MongoDBDiscovery) Discover(sessionHandler servicediscovery.ISessionHandler, presentationLayerDiscoveryResult servicediscovery.IPresentationDiscoveryResult) (servicediscovery.IApplicationDiscoveryResult, error) {
4747
clientOptions := options.Client().ApplyURI(fmt.Sprintf("mongodb://%s:%d", sessionHandler.GetHost(), sessionHandler.GetPort()))
48-
connectionTimeout := 3 * time.Second
48+
connectionTimeout := 500 * time.Millisecond
4949
clientOptions.Timeout = &connectionTimeout
5050
ctx := context.Background()
5151
client, err := mongo.Connect(ctx, clientOptions)

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_postgresql.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (d *PostgresDiscovery) Protocol() string {
4343

4444
func (d *PostgresDiscovery) Discover(sessionHandler servicediscovery.ISessionHandler, presentationLayerDiscoveryResult servicediscovery.IPresentationDiscoveryResult) (servicediscovery.IApplicationDiscoveryResult, error) {
4545
// Set a timeout of 30 ms
46-
db, err := sql.Open("postgres", fmt.Sprintf("host=%s port=%d user=postgres sslmode=disable connect_timeout=3", sessionHandler.GetHost(), sessionHandler.GetPort()))
46+
db, err := sql.Open("postgres", fmt.Sprintf("host=%s port=%d user=postgres sslmode=disable connect_timeout=1", sessionHandler.GetHost(), sessionHandler.GetPort()))
4747
if err != nil {
4848
log.Debugf("Error while connecting to postgresql: %s", err.Error())
4949
return &PostgresDiscoveryResult{

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_rabbitmq.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (d *RabbitMQDiscovery) Protocol() string {
4444
func (d *RabbitMQDiscovery) Discover(sessionHandler servicediscovery.ISessionHandler, presentationLayerDiscoveryResult servicediscovery.IPresentationDiscoveryResult) (servicediscovery.IApplicationDiscoveryResult, error) {
4545
connectionString := fmt.Sprintf("amqp://%s:%d", sessionHandler.GetHost(), sessionHandler.GetPort())
4646
config := amqp.Config{
47-
Dial: amqp.DefaultDial(time.Second * 3),
47+
Dial: amqp.DefaultDial(time.Millisecond * 500),
4848
}
4949
conn, err := amqp.DialConfig(connectionString, config)
5050
if err != nil {

pkg/networkscanner/servicediscovery/applicationlayerdiscovery/al_redis.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (d *RedisDiscovery) Discover(sessionHandler servicediscovery.ISessionHandle
4444
Addr: fmt.Sprintf("%s:%d", sessionHandler.GetHost(), sessionHandler.GetPort()),
4545
Password: "", // No password for now, modify as needed
4646
DB: 0, // Use default DB
47-
DialTimeout: 3 * time.Second,
47+
DialTimeout: 500 * time.Millisecond,
4848
MaxRetries: 1,
4949
})
5050

0 commit comments

Comments
 (0)