Skip to content

Commit dc381ea

Browse files
Fix: Reuse kafka clients (#4049)
Signed-off-by: Javier Aliaga <[email protected]>
1 parent 481e469 commit dc381ea

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

.github/infrastructure/docker-compose-cassandra.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: '2'
22

33
services:
44
cassandra:
5-
image: docker.io/bitnami/cassandra:4.1
5+
image: docker.io/bitnamilegacy/cassandra:4.1
66
ports:
77
- '7000:7000'
88
- '9042:9042'

common/component/kafka/clients.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ func (k *Kafka) latestClients() (*clients, error) {
2222

2323
// case 1: use aws clients with refreshable tokens in the cfg
2424
case k.awsConfig != nil:
25+
if k.clients != nil {
26+
return k.clients, nil
27+
}
28+
2529
awsKafkaOpts := KafkaOptions{
2630
Config: k.config,
2731
ConsumerGroup: k.consumerGroup,
@@ -34,10 +38,12 @@ func (k *Kafka) latestClients() (*clients, error) {
3438
if err != nil {
3539
return nil, fmt.Errorf("failed to get AWS IAM Kafka clients: %w", err)
3640
}
37-
return &clients{
41+
42+
k.clients = &clients{
3843
consumerGroup: awsKafkaClients.ConsumerGroup,
3944
producer: awsKafkaClients.Producer,
40-
}, nil
45+
}
46+
return k.clients, nil
4147

4248
// case 2: normal static auth profile clients
4349
default:

common/component/kafka/kafka.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ func (k *Kafka) ValidateAWS(metadata map[string]string) (awsAuth.Options, error)
301301
AssumeRoleArn: role,
302302
AssumeRoleSessionName: session,
303303
SessionToken: token,
304+
TrustAnchorArn: metadata["trustAnchorArn"],
305+
TrustProfileArn: metadata["trustProfileArn"],
306+
Properties: metadata,
304307
}, nil
305308
}
306309

common/component/kafka/kafka_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,14 @@ func TestValidateAWS(t *testing.T) {
520520
AssumeRoleArn: "testRoleArn",
521521
AssumeRoleSessionName: "testSessionName",
522522
SessionToken: "testSessionToken",
523+
Properties: map[string]string{
524+
"region": "us-east-1",
525+
"accessKey": "testAccessKey",
526+
"secretKey": "testSecretKey",
527+
"assumeRoleArn": "testRoleArn",
528+
"sessionName": "testSessionName",
529+
"sessionToken": "testSessionToken",
530+
},
523531
},
524532
err: nil,
525533
},
@@ -540,6 +548,14 @@ func TestValidateAWS(t *testing.T) {
540548
AssumeRoleArn: "awsRoleArn",
541549
AssumeRoleSessionName: "awsSessionName",
542550
SessionToken: "awsSessionToken",
551+
Properties: map[string]string{
552+
"awsRegion": "us-west-2",
553+
"awsAccessKey": "awsAccessKey",
554+
"awsSecretKey": "awsSecretKey",
555+
"awsIamRoleArn": "awsRoleArn",
556+
"awsStsSessionName": "awsSessionName",
557+
"awsSessionToken": "awsSessionToken",
558+
},
543559
},
544560
err: nil,
545561
},

tests/certification/state/cassandra/docker-compose-cluster.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
cassandra:
4-
image: docker.io/bitnami/cassandra:4.0.1
4+
image: docker.io/bitnamilegacy/cassandra:4.0.1
55
ports:
66
- '7000:7000'
77
- '9042:9042'
@@ -14,7 +14,7 @@ services:
1414
- CASSANDRA_PASSWORD_SEEDER=yes
1515

1616
cassandra2:
17-
image: docker.io/bitnami/cassandra:4.0.1
17+
image: docker.io/bitnamilegacy/cassandra:4.0.1
1818
ports:
1919
- 7001:7000
2020
- 9043:9042

tests/certification/state/cassandra/docker-compose-single.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
cassandra:
4-
image: docker.io/bitnami/cassandra:4.0.1
4+
image: docker.io/bitnamilegacy/cassandra:4.0.1
55
ports:
66
- '7002:7000'
77
- '9044:9042'

0 commit comments

Comments
 (0)