-
Notifications
You must be signed in to change notification settings - Fork 118
Add telemetry job #1448
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
Merged
Merged
Add telemetry job #1448
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c2a49b8
Add telemetry job
pleshakov 744b402
Update internal/mode/static/manager.go
pleshakov d226662
Updated jitter
pleshakov f05598a
Update error message
pleshakov 3050949
Update goreleaser settings
pleshakov bb12043
Fix YAML linting
pleshakov 57b2576
Simplify test for Start of Job
pleshakov be8b4e0
Changed LeaderElectionReleaseOnCancel to false and added a comment
pleshakov 1a27c77
Add an assertion in TestEnableAfterBecameLeader
pleshakov 06832aa
Update minReports and extend the comment
pleshakov b7a40aa
Merge branch 'main' into feature/telemetry-job
pleshakov 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
/* | ||
Package runnables provides helper types for creating runnables for the controller-runtime manager when | ||
leader election is enabled. | ||
*/ | ||
package runnables |
This file contains hidden or 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,62 @@ | ||
package runnables | ||
|
||
import ( | ||
"context" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
) | ||
|
||
// Leader is a Runnable that needs to be run only when the current instance is the leader. | ||
type Leader struct { | ||
manager.Runnable | ||
} | ||
|
||
var ( | ||
_ manager.LeaderElectionRunnable = &Leader{} | ||
_ manager.Runnable = &Leader{} | ||
) | ||
|
||
func (r *Leader) NeedLeaderElection() bool { | ||
return true | ||
} | ||
|
||
// LeaderOrNonLeader is a Runnable that needs to be run regardless of whether the current instance is the leader. | ||
type LeaderOrNonLeader struct { | ||
manager.Runnable | ||
} | ||
|
||
var ( | ||
_ manager.LeaderElectionRunnable = &LeaderOrNonLeader{} | ||
_ manager.Runnable = &LeaderOrNonLeader{} | ||
) | ||
|
||
func (r *LeaderOrNonLeader) NeedLeaderElection() bool { | ||
return false | ||
} | ||
|
||
// EnableAfterBecameLeader is a Runnable that will call the enable function when the current instance becomes | ||
// the leader. | ||
type EnableAfterBecameLeader struct { | ||
enable func(context.Context) | ||
} | ||
|
||
var ( | ||
_ manager.LeaderElectionRunnable = &EnableAfterBecameLeader{} | ||
_ manager.Runnable = &EnableAfterBecameLeader{} | ||
) | ||
|
||
// NewEnableAfterBecameLeader creates a new EnableAfterBecameLeader Runnable. | ||
func NewEnableAfterBecameLeader(enable func(context.Context)) *EnableAfterBecameLeader { | ||
return &EnableAfterBecameLeader{ | ||
enable: enable, | ||
} | ||
} | ||
|
||
func (j *EnableAfterBecameLeader) Start(ctx context.Context) error { | ||
j.enable(ctx) | ||
return nil | ||
} | ||
|
||
func (j *EnableAfterBecameLeader) NeedLeaderElection() bool { | ||
return true | ||
} |
This file contains hidden or 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,38 @@ | ||
package runnables | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestLeader(t *testing.T) { | ||
leader := &Leader{} | ||
|
||
g := NewWithT(t) | ||
g.Expect(leader.NeedLeaderElection()).To(BeTrue()) | ||
} | ||
|
||
func TestLeaderOrNonLeader(t *testing.T) { | ||
leaderOrNonLeader := &LeaderOrNonLeader{} | ||
|
||
g := NewWithT(t) | ||
g.Expect(leaderOrNonLeader.NeedLeaderElection()).To(BeFalse()) | ||
} | ||
|
||
func TestEnableAfterBecameLeader(t *testing.T) { | ||
enabled := false | ||
enableAfterBecameLeader := NewEnableAfterBecameLeader(func(_ context.Context) { | ||
enabled = true | ||
}) | ||
|
||
g := NewWithT(t) | ||
g.Expect(enableAfterBecameLeader.NeedLeaderElection()).To(BeTrue()) | ||
g.Expect(enabled).To(BeFalse()) | ||
|
||
err := enableAfterBecameLeader.Start(context.Background()) | ||
kate-osborn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
g.Expect(err).To(BeNil()) | ||
|
||
g.Expect(enabled).To(BeTrue()) | ||
} |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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,4 @@ | ||
/* | ||
Package telemetry is responsible for collecting and sending product telemetry data. | ||
*/ | ||
package telemetry |
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.
Uh oh!
There was an error while loading. Please reload this page.