Skip to content

Commit

Permalink
requeue spoke token controller until the application-manager SA secre…
Browse files Browse the repository at this point in the history
…t token is ready (#410)

Signed-off-by: Xiangjing Li <[email protected]>
  • Loading branch information
xiangjingli authored Sep 25, 2024
1 parent b71622d commit 32a1ee2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/controller/spoketoken/spoke_token_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (

const (
secretSuffix = "-cluster-secret"
requeuAfter = 5
requeuAfter = 1
infrastructureConfigName = "cluster"
appAddonName = "application-manager"
)
Expand Down Expand Up @@ -359,6 +359,13 @@ func (r *ReconcileAgentToken) createOrUpdateApplicationManagerSecret(sa *corev1.

// if there exists the secret with the application-manager name, it is not associated to the application-manager SA, need to delete and re-create it
if err == nil {
if ApplicationManagerSecret.Annotations != nil && ApplicationManagerSecret.Annotations["kubernetes.io/service-account.name"] == appAddonName {
if ApplicationManagerSecret.Data["token"] == nil {
return "", fmt.Errorf("application manager secret token is not ready yet, requeue after %v min, secret: %v/%v",
requeuAfter, ApplicationManagerSecret.Namespace, ApplicationManagerSecret.Name)
}
}

err = r.Client.Delete(context.TODO(), ApplicationManagerSecret)
if err != nil {
klog.Errorf("failed to delete the invalid application-manager secret, err: %v", err)
Expand Down

0 comments on commit 32a1ee2

Please sign in to comment.