Skip to content

Commit

Permalink
Merge pull request #1401 from alvaroaleman/fix-sa
Browse files Browse the repository at this point in the history
🐛 Manager leader election: Don't reset restcfg UserAgent
  • Loading branch information
k8s-ci-robot committed Mar 1, 2021
2 parents 1d02366 + 51f0fde commit da5d0bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ func New(config *rest.Config, options Options) (Manager, error) {
}

// Create the resource lock to enable leader election)
leaderConfig := config
if options.LeaderElectionConfig != nil {
leaderConfig = options.LeaderElectionConfig
leaderConfig := options.LeaderElectionConfig
if leaderConfig == nil {
leaderConfig = rest.CopyConfig(config)
}
resourceLock, err := options.newResourceLock(leaderConfig, recorderProvider, leaderelection.Options{
LeaderElection: options.LeaderElection,
Expand Down
14 changes: 14 additions & 0 deletions pkg/manager/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,20 @@ var _ = Describe("manger.Manager", func() {
close(done)
})

It("should not manipulate the provided config", func() {
originalCfg := rest.CopyConfig(cfg)
// The options object is shared by multiple tests, copy it
// into our scope so we manipulate it for this testcase only
options := options
options.newResourceLock = nil
m, err := New(cfg, options)
Expect(err).NotTo(HaveOccurred())
for _, cb := range callbacks {
cb(m)
}
Expect(m.GetConfig()).To(Equal(originalCfg))
})

It("should stop when context is cancelled", func(done Done) {
m, err := New(cfg, options)
Expect(err).NotTo(HaveOccurred())
Expand Down

0 comments on commit da5d0bc

Please sign in to comment.