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

Signed-off-by: Xiangjing Li <xiangli@redhat.com>
  • Loading branch information
xiangjingli committed Sep 25, 2024
1 parent b71622d commit 1dcafc7
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 1dcafc7

Please sign in to comment.