Skip to content
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

Restore Error Return When Non-Leader Calls LeaderSettingsChanged #10301

Merged
merged 1 commit into from Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions worker/uniter/runner/context/leader.go
Expand Up @@ -74,10 +74,6 @@ func (ctx *leadershipContext) WriteLeaderSettings(settings map[string]string) er
// `apiserver/leadership.LeadershipSettingsAccessor.Merge`, and as of
// 2015-02-19 it's better to stay eager.
err := ctx.ensureLeader()
if err == errIsMinion {
logger.Warningf("skipping write settings; not the leader")
return nil
}
if err == nil {
// Clear local settings; if we need them again we should use the values
// as merged by the server. But we don't need to get them again right now;
Expand Down
9 changes: 4 additions & 5 deletions worker/uniter/runner/context/leader_test.go
Expand Up @@ -201,17 +201,16 @@ func (s *LeaderSuite) TestWriteLeaderSettingsMinion(c *gc.C) {
s.CheckCalls(c, []testing.StubCall{{
FuncName: "ClaimLeader",
}}, func() {
// We are not the leader.
// The first call fails...
s.tracker.results = []StubTicket{false}
err := s.context.WriteLeaderSettings(map[string]string{"blah": "blah"})
// No error, no call to Merge.
c.Check(err, jc.ErrorIsNil)
c.Check(err, gc.ErrorMatches, "cannot write settings: not the leader")
})

s.CheckCalls(c, nil, func() {
// ctx.isMinion is now true. No call to claim leader.
// The second doesn't even try.
err := s.context.WriteLeaderSettings(map[string]string{"blah": "blah"})
c.Check(err, jc.ErrorIsNil)
c.Check(err, gc.ErrorMatches, "cannot write settings: not the leader")
})
}

Expand Down