Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
cert-rotator: Add retry to cluster upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Suraj Deshmukh <suraj@kinvolk.io>
  • Loading branch information
surajssd committed Jun 23, 2021
1 parent 2fa6cc4 commit 75e0bfb
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions cli/cmd/cluster/certificate-rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ import (

log "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"

"github.com/kinvolk/lokomotive/pkg/k8sutil"
"github.com/kinvolk/lokomotive/pkg/platform"
)

const (
retryInterval = 10 * time.Second
retryTimeout = 30 * time.Minute
)

type certificateRotator struct {
clientSet *kubernetes.Clientset
newCACert string
Expand Down Expand Up @@ -99,8 +105,22 @@ func rotateControlPlaneCerts(contextLogger *log.Entry, cc clusterConfig) error {

contextLogger.Log(log.InfoLevel, "Applying a controlplane update with the new CA")

if err := c.upgradeControlPlane(contextLogger, kubeconfig); err != nil {
return fmt.Errorf("running controlplane upgrade: %v", err)
var upgradeErr error

err = wait.PollImmediate(retryInterval, retryTimeout, func() (bool, error) {
if upgradeErr = c.upgradeControlPlane(contextLogger, kubeconfig); upgradeErr != nil {
return false, nil
}

return true, nil
})

if upgradeErr != nil {
return fmt.Errorf("running controlplane upgrade: %w", upgradeErr)
}

if err != nil {
return fmt.Errorf("control plane did not upgrade after multiple retries: %w", err)
}

cs, err := k8sutil.NewClientset(kubeconfig)
Expand Down

0 comments on commit 75e0bfb

Please sign in to comment.