Skip to content

Commit 0e4aaaf

Browse files
authored
fix(atls): apply updated certificates when TLS secrets change (#2674) (#374)
1 parent 98c1491 commit 0e4aaaf

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

internal/controller/apisixtls_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (r *ApisixTlsReconciler) listApisixTlsForSecret(ctx context.Context, obj cl
248248
ctx,
249249
r.Client,
250250
r.Log,
251-
&apiv2.ApisixConsumerList{},
251+
&apiv2.ApisixTlsList{},
252252
client.MatchingFields{
253253
indexer.SecretIndexRef: indexer.GenIndexKey(secret.GetNamespace(), secret.GetName()),
254254
},

test/e2e/crds/v2/tls.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,27 @@ spec:
146146
WithHost("api6.com").
147147
Expect().
148148
Status(200)
149+
150+
err = s.NewKubeTlsSecret("test-tls-secret", framework.TestCert, framework.TestKey)
151+
Expect(err).NotTo(HaveOccurred(), "updating TLS secret")
152+
153+
Eventually(func() error {
154+
tlss, err := s.DefaultDataplaneResource().SSL().List(context.Background())
155+
if err != nil {
156+
return err
157+
}
158+
if len(tlss) != 1 {
159+
return fmt.Errorf("expected 1 tls, got %d", len(tls))
160+
}
161+
certs := tlss[0].Certificates
162+
if len(certs) != 1 {
163+
return fmt.Errorf("expected 1 certificate, got %d", len(certs))
164+
}
165+
if !strings.Contains(certs[0].Certificate, framework.TestCert) {
166+
return fmt.Errorf("certificate not updated yet")
167+
}
168+
return nil
169+
}).WithTimeout(30*time.Second).ProbeEvery(1*time.Second).ShouldNot(HaveOccurred(), "tls secret updated in dataplane")
149170
})
150171

151172
It("ApisixTls with mTLS test", func() {

0 commit comments

Comments
 (0)