Skip to content

Commit

Permalink
Merge pull request #10308 from manadart/2.5-into-2.6
Browse files Browse the repository at this point in the history
#10308

## Description of change

This brings forward #10301 and syncs the branches around recent forward/back porting.
  • Loading branch information
jujubot committed Jun 11, 2019
2 parents 38d081d + 85da568 commit 0ef49c3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
10 changes: 5 additions & 5 deletions environs/manual/winrmprovisioner/winrmprovisioner.go
Expand Up @@ -141,15 +141,15 @@ func InitAdministratorUser(args *manual.ProvisionMachineArgs) error {

logger.Infof("Trying http client as user %s on %s", args.Host, args.User)
if err = args.WinRM.Client.Ping(); err != nil {
logger.Debugf("WinRM unsecure listener is not enabled on %s", args.Host)
logger.Debugf("WinRM insecure listener is not enabled on %s", args.Host)
return errors.Annotatef(err, "cannot provision, because all winrm default connections failed")
}

defClient := args.WinRM.Client
logger.Infof("Trying to enable https client certificate authentication")
if args.WinRM.Client, err = enableCertAuth(args); err != nil {
logger.Infof("Cannot enable client auth cert authentication for winrm")
logger.Infof("Reverting back to usecure client interaction")
logger.Infof("Reverting back to insecure client interaction")
args.WinRM.Client = defClient
return nil
}
Expand All @@ -160,8 +160,8 @@ func InitAdministratorUser(args *manual.ProvisionMachineArgs) error {
return nil
}

logger.Infof("Winrm https connection is broken, can't retrieve a response")
logger.Infof("Reverting back to usecure client interactions")
logger.Infof("Winrm https connection is broken, cannot retrieve a response")
logger.Infof("Reverting back to insecure client interactions")
args.WinRM.Client = defClient

return nil
Expand Down Expand Up @@ -413,7 +413,7 @@ func DetectSeriesAndHardwareCharacteristics(host string, cli manual.WinrmClientA
return hc, series, nil
}

// initHC it will initialize the hardware characterisrics struct with the
// initHC it will initialize the hardware characteristics struct with the
// parsed and checked info slice string
// info description :
// - info[0] the arch of the machine
Expand Down
2 changes: 1 addition & 1 deletion provider/openstack/credentials.go
Expand Up @@ -146,7 +146,7 @@ func (c OpenstackCredentials) DetectCredentials() (*cloud.CloudCredential, error
func (c OpenstackCredentials) detectCredential() (*cloud.Credential, string, string, error) {
creds, err := identity.CredentialsFromEnv()
if err != nil {
return nil, "", "", errors.Errorf("failed to retrieve cred from env : %v", err)
return nil, "", "", errors.Errorf("failed to retrieve credential from env : %v", err)
}
if creds.TenantName == "" {
logger.Debugf("neither OS_TENANT_NAME nor OS_PROJECT_NAME environment variable not set")
Expand Down
2 changes: 1 addition & 1 deletion provider/openstack/provider.go
Expand Up @@ -205,7 +205,7 @@ func (EnvironProvider) DetectRegions() ([]cloud.Region, error) {
// return return a region using them.
creds, err := identity.CredentialsFromEnv()
if err != nil {
return nil, errors.Errorf("failed to retrieve cred from env : %v", err)
return nil, errors.Errorf("failed to retrieve credential from env : %v", err)
}
if creds.Region == "" {
return nil, errors.NewNotFound(nil, "OS_REGION_NAME environment variable not set")
Expand Down
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

0 comments on commit 0ef49c3

Please sign in to comment.