@@ -29,6 +29,7 @@ import (
2929 "time"
3030
3131 api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
32+ "github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3233 "github.com/rs/zerolog"
3334)
3435
@@ -76,8 +77,10 @@ func createRotateTLSServerCertificatePlan(log zerolog.Logger, spec api.Deploymen
7677}
7778
7879// createRotateTLSCAPlan creates plan to replace a TLS CA and rotate all server.
79- func createRotateTLSCAPlan (log zerolog.Logger , spec api.DeploymentSpec , status api.DeploymentStatus ,
80- getTLSCA func (string ) (string , string , bool , error )) api.Plan {
80+ func createRotateTLSCAPlan (log zerolog.Logger , apiObject k8sutil.APIObject ,
81+ spec api.DeploymentSpec , status api.DeploymentStatus ,
82+ getTLSCA func (string ) (string , string , bool , error ),
83+ createEvent func (evt * k8sutil.Event )) api.Plan {
8184 if ! spec .TLS .IsSecure () {
8285 return nil
8386 }
@@ -93,31 +96,37 @@ func createRotateTLSCAPlan(log zerolog.Logger, spec api.DeploymentSpec, status a
9396 }
9497 var plan api.Plan
9598 if renewalNeeded , reason := tlsCANeedsRenewal (log , cert , spec .TLS ); renewalNeeded {
96- var planSuffix api.Plan
97- plan = append (plan ,
98- api .NewAction (api .ActionTypeRenewTLSCACertificate , 0 , "" , reason ),
99- )
100- status .Members .ForeachServerGroup (func (group api.ServerGroup , members api.MemberStatusList ) error {
101- for _ , m := range members {
102- if m .Phase != api .MemberPhaseCreated {
103- // Only make changes when phase is created
104- continue
99+ if spec .IsDowntimeAllowed () {
100+ var planSuffix api.Plan
101+ plan = append (plan ,
102+ api .NewAction (api .ActionTypeRenewTLSCACertificate , 0 , "" , reason ),
103+ )
104+ status .Members .ForeachServerGroup (func (group api.ServerGroup , members api.MemberStatusList ) error {
105+ for _ , m := range members {
106+ if m .Phase != api .MemberPhaseCreated {
107+ // Only make changes when phase is created
108+ continue
109+ }
110+ if ! group .IsArangod () {
111+ // Sync master/worker is not applicable here
112+ continue
113+ }
114+ plan = append (plan ,
115+ api .NewAction (api .ActionTypeRenewTLSCertificate , group , m .ID ),
116+ api .NewAction (api .ActionTypeRotateMember , group , m .ID , "TLS CA certificate changed" ),
117+ )
118+ planSuffix = append (planSuffix ,
119+ api .NewAction (api .ActionTypeWaitForMemberUp , group , m .ID , "TLS CA certificate changed" ),
120+ )
105121 }
106- if ! group .IsArangod () {
107- // Sync master/worker is not applicable here
108- continue
109- }
110- plan = append (plan ,
111- api .NewAction (api .ActionTypeRenewTLSCertificate , group , m .ID ),
112- api .NewAction (api .ActionTypeRotateMember , group , m .ID , "TLS CA certificate changed" ),
113- )
114- planSuffix = append (planSuffix ,
115- api .NewAction (api .ActionTypeWaitForMemberUp , group , m .ID , "TLS CA certificate changed" ),
116- )
117- }
118- return nil
119- })
120- plan = append (plan , planSuffix ... )
122+ return nil
123+ })
124+ plan = append (plan , planSuffix ... )
125+ } else {
126+ // Rotating the CA results in downtime.
127+ // That is currently not allowed.
128+ createEvent (k8sutil .NewDowntimeNotAllowedEvent (apiObject , "Rotate TLS CA" ))
129+ }
121130 }
122131 return plan
123132}
0 commit comments