-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not allow discovery api call for helm templating to stop the …
…agent (#222) * do not allow discovery api call for helm templating to stop the agent * bump default number of reconciles to 20 * update logic * fix lint
- Loading branch information
Showing
4 changed files
with
57 additions
and
36 deletions.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package helpers | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"k8s.io/apimachinery/pkg/util/wait" | ||
) | ||
|
||
// BackgroundPollUntilContextCancel spawns a new goroutine that runs the condition function on interval. | ||
// If syncFirstRun is set to true, it will execute the condition function synchronously first and then start | ||
// polling. Since error is returned synchronously, the only way to check for it is to use syncFirstRun. | ||
// Background poller does not sync errors. It can be stopped externally by cancelling the provided context. | ||
func BackgroundPollUntilContextCancel(ctx context.Context, interval time.Duration, immediate, syncFirstRun bool, condition wait.ConditionWithContextFunc) (err error) { | ||
if syncFirstRun { | ||
_, err = condition(ctx) | ||
} | ||
|
||
go func() { | ||
_ = wait.PollUntilContextCancel(ctx, interval, immediate, condition) | ||
}() | ||
|
||
return 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