forked from actions/actions-runner-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gha: Make client-go rate limiter params configurable #4
Merged
+31
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ type EphemeralRunnerReconciler struct { | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
log := r.Log.WithValues("ephemeralrunner", req.NamespacedName) | ||
log.Info("Start Reconcile") | ||
|
||
ephemeralRunner := new(v1alpha1.EphemeralRunner) | ||
if err := r.Get(ctx, req.NamespacedName, ephemeralRunner); err != nil { | ||
|
@@ -183,6 +184,7 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ | |
return r.updateStatusWithRunnerConfig(ctx, ephemeralRunner, log) | ||
} | ||
|
||
now := time.Now() | ||
secret := new(corev1.Secret) | ||
if err := r.Get(ctx, req.NamespacedName, secret); err != nil { | ||
if !kerrors.IsNotFound(err) { | ||
|
@@ -193,6 +195,7 @@ func (r *EphemeralRunnerReconciler) Reconcile(ctx context.Context, req ctrl.Requ | |
log.Info("Creating new ephemeral runner secret for jitconfig.") | ||
return r.createSecret(ctx, ephemeralRunner, log) | ||
} | ||
log.Info("Get Secret", "duration_ms", time.Since(now).Milliseconds()) | ||
|
||
pod := new(corev1.Pod) | ||
if err := r.Get(ctx, req.NamespacedName, pod); err != nil { | ||
|
@@ -344,8 +347,10 @@ func (r *EphemeralRunnerReconciler) cleanupResources(ctx context.Context, epheme | |
log.Info("Pod is deleted") | ||
|
||
log.Info("Cleaning up the runner jitconfig secret") | ||
now := time.Now() | ||
secret := new(corev1.Secret) | ||
err = r.Get(ctx, types.NamespacedName{Namespace: ephemeralRunner.Namespace, Name: ephemeralRunner.Name}, secret) | ||
log.Info("Get Secret for cleanup", "duration_ms", time.Since(now).Milliseconds()) | ||
switch { | ||
case err == nil: | ||
if secret.ObjectMeta.DeletionTimestamp.IsZero() { | ||
|
@@ -516,7 +521,7 @@ func (r *EphemeralRunnerReconciler) deletePodAsFailed(ctx context.Context, ephem | |
func (r *EphemeralRunnerReconciler) updateStatusWithRunnerConfig(ctx context.Context, ephemeralRunner *v1alpha1.EphemeralRunner, log logr.Logger) (ctrl.Result, error) { | ||
// Runner is not registered with the service. We need to register it first | ||
log.Info("Creating ephemeral runner JIT config") | ||
actionsClient, err := r.actionsClientFor(ctx, ephemeralRunner) | ||
actionsClient, err := r.actionsClientFor(ctx, ephemeralRunner, log) | ||
if err != nil { | ||
return ctrl.Result{}, fmt.Errorf("failed to get actions client for generating JIT config: %v", err) | ||
} | ||
|
@@ -712,11 +717,13 @@ func (r *EphemeralRunnerReconciler) updateRunStatusFromPod(ctx context.Context, | |
return nil | ||
} | ||
|
||
func (r *EphemeralRunnerReconciler) actionsClientFor(ctx context.Context, runner *v1alpha1.EphemeralRunner) (actions.ActionsService, error) { | ||
func (r *EphemeralRunnerReconciler) actionsClientFor(ctx context.Context, runner *v1alpha1.EphemeralRunner, log logr.Logger) (actions.ActionsService, error) { | ||
now := time.Now() | ||
secret := new(corev1.Secret) | ||
if err := r.Get(ctx, types.NamespacedName{Namespace: runner.Namespace, Name: runner.Spec.GitHubConfigSecret}, secret); err != nil { | ||
return nil, fmt.Errorf("failed to get secret: %w", err) | ||
} | ||
log.Info("Get Secret for GitHub client", "duration_ms", time.Since(now).Milliseconds()) | ||
|
||
opts, err := r.actionsClientOptionsFor(ctx, runner) | ||
if err != nil { | ||
|
@@ -782,7 +789,7 @@ func (r *EphemeralRunnerReconciler) actionsClientOptionsFor(ctx context.Context, | |
// runnerRegisteredWithService checks if the runner is still registered with the service | ||
// Returns found=false and err=nil if ephemeral runner does not exist in GitHub service and should be deleted | ||
func (r EphemeralRunnerReconciler) runnerRegisteredWithService(ctx context.Context, runner *v1alpha1.EphemeralRunner, log logr.Logger) (found bool, err error) { | ||
actionsClient, err := r.actionsClientFor(ctx, runner) | ||
actionsClient, err := r.actionsClientFor(ctx, runner, log) | ||
if err != nil { | ||
return false, fmt.Errorf("failed to get Actions client for ScaleSet: %w", err) | ||
} | ||
|
@@ -809,7 +816,7 @@ func (r EphemeralRunnerReconciler) runnerRegisteredWithService(ctx context.Conte | |
} | ||
|
||
func (r *EphemeralRunnerReconciler) deleteRunnerFromService(ctx context.Context, ephemeralRunner *v1alpha1.EphemeralRunner, log logr.Logger) error { | ||
client, err := r.actionsClientFor(ctx, ephemeralRunner) | ||
client, err := r.actionsClientFor(ctx, ephemeralRunner, log) | ||
if err != nil { | ||
return fmt.Errorf("failed to get actions client for runner: %v", err) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the current default values:
https://github.com/kubernetes-sigs/controller-runtime/blob/b88f351e4ba2a4cac3b5fecd1c9fad3e4895e8a1/pkg/client/config/config.go#L101-L106