Skip to content

Commit

Permalink
Merge branch 'upstream/2.7' into 2.7-into-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
manadart committed Dec 20, 2019
2 parents 82a0d7f + d83d4a1 commit 6aee4c6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 54 deletions.
66 changes: 14 additions & 52 deletions apiserver/facades/agent/uniter/networkinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ package uniter_test
import (
"fmt"
"math/rand"
"sync"
"time"

"github.com/juju/clock/testclock"
"github.com/juju/clock"
"github.com/juju/retry"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
Expand Down Expand Up @@ -199,18 +198,6 @@ func (s *networkInfoSuite) TestNetworksForRelationRemoteRelationNoPublicAddr(c *
}

func (s *networkInfoSuite) TestNetworksForRelationRemoteRelationDelayedPublicAddress(c *gc.C) {
clk := testclock.NewClock(time.Now())
attemptMade := make(chan struct{}, 10)
s.PatchValue(&uniter.PreferredAddressRetryArgs, func() retry.CallArgs {
return retry.CallArgs{
Clock: clk,
Delay: 3 * time.Second,
MaxDuration: 30 * time.Second,
NotifyFunc: func(lastError error, attempt int) {
attemptMade <- struct{}{}
},
}
})
prr := s.newRemoteProReqRelation(c)
err := prr.ru0.AssignToNewMachine()
c.Assert(err, jc.ErrorIsNil)
Expand All @@ -219,49 +206,24 @@ func (s *networkInfoSuite) TestNetworksForRelationRemoteRelationDelayedPublicAdd
machine, err := s.State.Machine(id)
c.Assert(err, jc.ErrorIsNil)

// Set up a public address after at least one attempt
// is made to get it.We record the err for checking later
// as gc.C is not thread safe.
var funcErr error
wg := sync.WaitGroup{}
go func() {
wg.Add(1)
defer wg.Done()
funcErr = clk.WaitAdvance(15*time.Second, time.Second, 1)
if funcErr != nil {
return
}
// Ensure we have a failed attempt to get public address.
select {
case <-attemptMade:
funcErr = clk.WaitAdvance(10*time.Second, time.Second, 1)
if funcErr != nil {
return
}
case <-time.After(coretesting.LongWait):
c.Fatal("waiting for public address attempt")
}

// Now set up the public address.
funcErr = machine.SetProviderAddresses(
network.NewScopedSpaceAddress("4.3.2.1", network.ScopePublic),
)
if funcErr != nil {
return
}
funcErr = clk.WaitAdvance(10*time.Second, time.Second, 1)
if funcErr != nil {
return
s.PatchValue(&uniter.PreferredAddressRetryArgs, func() retry.CallArgs {
return retry.CallArgs{
Clock: clock.WallClock,
Delay: 1 * time.Millisecond,
MaxDuration: coretesting.LongWait,
NotifyFunc: func(lastError error, attempt int) {
// Set the address after one failed retrieval attempt.
if attempt == 1 {
err := machine.SetProviderAddresses(network.NewScopedSpaceAddress("4.3.2.1", network.ScopePublic))
c.Assert(err, jc.ErrorIsNil)
}
},
}
}()
})

boundSpace, ingress, egress, err := s.newNetworkInfo(c, prr.ru0.UnitTag()).NetworksForRelation("", prr.rel, true)
c.Assert(err, jc.ErrorIsNil)

// Ensure there we no errors in the go routine.
wg.Wait()
c.Assert(funcErr, jc.ErrorIsNil)

c.Assert(boundSpace, gc.Equals, network.AlphaSpaceId)
c.Assert(ingress, gc.DeepEquals,
network.SpaceAddresses{network.NewScopedSpaceAddress("4.3.2.1", network.ScopePublic)})
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/agent/uniter/uniter.go
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ func (u *UniterAPI) EnterScope(args params.RelationUnits) (params.ErrorResults,
// ingress-address is the preferred settings attribute name as it more accurately
// reflects the purpose of the attribute value. We'll deprecate private-address.
settings["ingress-address"] = ingressAddress
} else {
} else if err != nil {
logger.Warningf("cannot set ingress/egress addresses for unit %v in relation %v: %v",
unitTag.Id(), relTag, err)
}
Expand Down
3 changes: 3 additions & 0 deletions core/raftlease/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ func (s *Store) runOnLeader(command *Command, stop <-chan struct{}) error {

select {
case <-s.config.Clock.After(s.config.ForwardTimeout):
// TODO (thumper) 2019-12-20, bug 1857072
// Scale testing hit this a *lot*,
// perhaps we need to consider batching messages to run on the leader?
logger.Infof("timeout")
s.record(command.Operation, "timeout", start)
return lease.ErrTimeout
Expand Down
2 changes: 1 addition & 1 deletion provider/ec2/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (environProvider) Version() int {

// Open is specified in the EnvironProvider interface.
func (p environProvider) Open(args environs.OpenParams) (environs.Environ, error) {
logger.Infof("opening model %q", args.Config.Name())
logger.Debugf("opening model %q", args.Config.Name())

e := new(environ)
e.name = args.Config.Name()
Expand Down
5 changes: 5 additions & 0 deletions state/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -2649,6 +2649,7 @@ func (a *Application) Status() (status.StatusInfo, error) {
// This in turn implies the application status document is likely to be
// inaccurate, so we return aggregated unit statuses instead.
//
// TODO(thumper) 2019-12-20: bug 1857075
// TODO(fwereade): this is completely wrong and will produce bad results
// in not-very-challenging scenarios. The leader unit remains responsible
// for setting the application status in a timely way, *whether or not the
Expand All @@ -2664,6 +2665,10 @@ func (a *Application) Status() (status.StatusInfo, error) {
for _, unit := range units {
unitStatus, err := unit.Status()
if err != nil {
// Sometimes as units are being removed, we may hit a not found error here.
if errors.IsNotFound(err) {
continue
}
return status.StatusInfo{}, errors.Annotatef(err, "deriving application status from %q", unit.Name())
}
unitStatuses = append(unitStatuses, unitStatus)
Expand Down

0 comments on commit 6aee4c6

Please sign in to comment.