Skip to content

Commit 85a6e3e

Browse files
certrotation: exit when received cabundle is empty
When different controllers update the same CA bundle a conflict may occur. In that case we return an empty set of certificates and empty error. The sync procedure should exit if either non-empty error received or cabundle is empty, as this ca bundle is later used to detemine whether target cert can be verified. If conflict occurred during CA bundle update we should restart the sync worker again - otherwise this may lead to target certificate unexpectedly regenerated. When service network target certificate is being updated it may be fatal, as the operator will lose its connection to API server and won't be able to receive an updated certificate. Co-Authored-By: Masaki Hatada <[email protected]>
1 parent cf85180 commit 85a6e3e

File tree

2 files changed

+490
-1
lines changed

2 files changed

+490
-1
lines changed

pkg/operator/certrotation/client_cert_rotation_controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,22 @@ func (c CertRotationController) getSigningCertKeyPairLocation() string {
138138

139139
func (c CertRotationController) SyncWorker(ctx context.Context) error {
140140
signingCertKeyPair, _, err := c.RotatedSigningCASecret.EnsureSigningCertKeyPair(ctx)
141-
if err != nil || signingCertKeyPair == nil {
141+
if err != nil {
142142
return err
143143
}
144+
// If no signingCertKeyPair returned due to update conflict or otherwise, return an error
145+
if signingCertKeyPair == nil {
146+
return fmt.Errorf("signingCertKeyPair is nil")
147+
}
144148

145149
cabundleCerts, err := c.CABundleConfigMap.EnsureConfigMapCABundle(ctx, signingCertKeyPair, c.getSigningCertKeyPairLocation())
146150
if err != nil {
147151
return err
148152
}
153+
// If no ca bundle returned due to update conflict or otherwise, return an error
154+
if cabundleCerts == nil {
155+
return fmt.Errorf("cabundleCerts is nil")
156+
}
149157

150158
if _, err := c.RotatedSelfSignedCertKeySecret.EnsureTargetCertKeyPair(ctx, signingCertKeyPair, cabundleCerts); err != nil {
151159
return err

0 commit comments

Comments
 (0)