Skip to content

Commit

Permalink
Merge branch '2.8' into merge-2.8-20210727
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Jul 27, 2021
2 parents 33e0259 + e4731a6 commit 2120123
Show file tree
Hide file tree
Showing 92 changed files with 153 additions and 149 deletions.
2 changes: 1 addition & 1 deletion apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names/v4"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
"github.com/juju/ratelimit"
"github.com/juju/worker/v2/dependency"
"github.com/prometheus/client_golang/prometheus"
Expand Down
2 changes: 1 addition & 1 deletion apiserver/basesuite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/juju/clock"
"github.com/juju/loggo"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
"github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/worker/v2/workertest"
Expand Down
2 changes: 1 addition & 1 deletion apiserver/facade/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,5 @@ type ModelPresence interface {

// Hub represents the central hub that the API server has.
type Hub interface {
Publish(topic string, data interface{}) (<-chan struct{}, error)
Publish(topic string, data interface{}) (func(), error)
}
2 changes: 1 addition & 1 deletion apiserver/facades/client/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/names/v4"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils/v2"
"github.com/juju/worker/v2/workertest"
Expand Down
17 changes: 8 additions & 9 deletions apiserver/observer/request_notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ import (
// Hub defines the only method of the apiserver centralhub that
// the observer uses.
type Hub interface {
Publish(topic string, data interface{}) (<-chan struct{}, error)
Publish(topic string, data interface{}) (func(), error)
}

// RequestObserver serves as a sink for API server requests and
// responses.
type RequestObserver struct {
clock clock.Clock
hub Hub
logger loggo.Logger
connLogger loggo.Logger
pingLogger loggo.Logger
apiConnectionCount func() int64
clock clock.Clock
hub Hub
logger loggo.Logger
connLogger loggo.Logger
pingLogger loggo.Logger

// state represents information that's built up as methods on this
// type are called. We segregate this to ensure it's clear what
Expand All @@ -46,8 +45,8 @@ type RequestObserver struct {
}
}

// RequestObservercontext provides information needed for a
// RequestObserverContext to operate correctly.
// RequestObserverContext provides information needed for a
// RequestObserver to operate correctly.
type RequestObserverContext struct {

// Clock is the clock to use for all time operations on this type.
Expand Down
4 changes: 2 additions & 2 deletions apiserver/observer/request_notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ type connectionHub struct {
details apiserver.APIConnection
}

func (hub *connectionHub) Publish(topic string, data interface{}) (<-chan struct{}, error) {
func (hub *connectionHub) Publish(topic string, data interface{}) (func(), error) {
hub.called++
hub.topic = topic
hub.details = data.(apiserver.APIConnection)
return nil, nil
return func() {}, nil
}
2 changes: 1 addition & 1 deletion apiserver/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
// Hub defines the publish method that the handler uses to publish
// messages on the centralhub of the apiserver.
type Hub interface {
Publish(string, interface{}) (<-chan struct{}, error)
Publish(string, interface{}) (func(), error)
}

func newPubSubHandler(h httpContext, hub Hub) http.Handler {
Expand Down
2 changes: 1 addition & 1 deletion apiserver/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
jujuhttp "github.com/juju/http/v2"
"github.com/juju/loggo"
"github.com/juju/names/v4"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"

Expand Down
2 changes: 1 addition & 1 deletion apiserver/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
// that are used. The context uses an interface to allow mocking
// of the hub.
type SharedHub interface {
Publish(topic string, data interface{}) (<-chan struct{}, error)
Publish(topic string, data interface{}) (func(), error)
Subscribe(topic string, handler interface{}) (func(), error)
}

Expand Down
8 changes: 4 additions & 4 deletions apiserver/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/juju/clock"
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
jc "github.com/juju/testing/checkers"
"github.com/juju/worker/v2/workertest"
"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -160,9 +160,9 @@ type stubHub struct {
published []string
}

func (s *stubHub) Publish(topic string, data interface{}) (<-chan struct{}, error) {
func (s *stubHub) Publish(topic string, data interface{}) (func(), error) {
s.published = append(s.published, topic)
return nil, nil
return func() {}, nil
}

func (s *sharedServerContextSuite) TestControllerConfigChanged(c *gc.C) {
Expand All @@ -180,7 +180,7 @@ func (s *sharedServerContextSuite) TestControllerConfigChanged(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

select {
case <-done:
case <-pubsub.Wait(done):
case <-time.After(testing.LongWait):
c.Fatalf("handler didn't")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/juju/common/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func WaitForAgentInitialisation(
strings.HasSuffix(errorMessage, "target machine actively refused it."), // Winsock message for connection refused
strings.HasSuffix(errorMessage, "connection is shut down"),
strings.HasSuffix(errorMessage, "i/o timeout"),
strings.HasSuffix(errorMessage, "network is unreachable"),
strings.HasSuffix(errorMessage, "deadline exceeded"),
strings.HasSuffix(errorMessage, "no api connection available"):
ctx.Verbosef("Still waiting for API to become available: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/jujud/agent/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/juju/loggo"
"github.com/juju/mgo/v2"
"github.com/juju/names/v4"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
"github.com/juju/replicaset"
"github.com/juju/utils/v2"
"github.com/juju/utils/v2/symlink"
Expand Down
2 changes: 1 addition & 1 deletion cmd/jujud/agent/machine/manifolds.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/proxy"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
"github.com/juju/utils/v2/voyeur"
"github.com/juju/version/v2"
"github.com/juju/worker/v2"
Expand Down
6 changes: 3 additions & 3 deletions core/cache/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"sync"

"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"

"github.com/juju/juju/core/status"
)
Expand Down Expand Up @@ -145,7 +145,7 @@ func (a *Application) setDetails(details ApplicationChange) {
})

if a.details.CharmURL != details.CharmURL {
a.hub.Publish(applicationCharmURLChange, appCharmUrlChange{appName: a.details.Name, chURL: details.CharmURL})
_ = a.hub.Publish(applicationCharmURLChange, appCharmUrlChange{appName: a.details.Name, chURL: details.CharmURL})
}

a.details = details
Expand All @@ -156,7 +156,7 @@ func (a *Application) setDetails(details ApplicationChange) {
a.configHash = configHash
a.hashCache = hashCache
a.hashCache.incMisses()
a.hub.Publish(a.topic(applicationConfigChange), hashCache)
_ = a.hub.Publish(a.topic(applicationConfigChange), hashCache)
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/cache/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package cache

import (
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"

"github.com/juju/juju/core/settings"
)
Expand Down Expand Up @@ -87,7 +87,7 @@ func (b *Branch) setDetails(details BranchChange) {
})

b.details = details
b.hub.Publish(branchChange, b.copy())
_ = b.hub.Publish(branchChange, b.copy())
}

// copy returns a copy of the branch, ensuring appropriate deep copying.
Expand Down
2 changes: 1 addition & 1 deletion core/cache/charm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package cache

import (
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"

"github.com/juju/juju/core/lxdprofile"
)
Expand Down
2 changes: 1 addition & 1 deletion core/cache/charmconfigwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package cache
import (
"github.com/juju/collections/set"
"github.com/juju/errors"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"

"github.com/juju/juju/core/settings"
)
Expand Down
6 changes: 3 additions & 3 deletions core/cache/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
"gopkg.in/tomb.v2"
)

Expand Down Expand Up @@ -327,7 +327,7 @@ func (c *Controller) modelWatcher(uuid string) ModelWatcher {
func (c *Controller) updateModel(ch ModelChange) {
model := c.ensureModel(ch.ModelUUID)
model.setDetails(ch)
c.hub.Publish(modelUpdatedTopic, model)
_ = c.hub.Publish(modelUpdatedTopic, model)
}

// removeModel removes the model from the cache.
Expand All @@ -341,7 +341,7 @@ func (c *Controller) removeModel(ch RemoveModel) error {
return errors.Trace(err)
}
delete(c.models, ch.ModelUUID)
c.hub.Publish(modelRemovedTopic, ch.ModelUUID)
_ = c.hub.Publish(modelRemovedTopic, ch.ModelUUID)
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion core/cache/lxdprofilewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/juju/collections/set"
"github.com/juju/errors"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"

"github.com/juju/juju/core/lxdprofile"
)
Expand Down
2 changes: 1 addition & 1 deletion core/cache/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func (m *Machine) setDetails(details MachineChange) {
m.details = details

if provisioned {
m.model.hub.Publish(m.topic(machineProvisioned), nil)
_ = m.model.hub.Publish(m.topic(machineProvisioned), nil)
}

configHash, err := hashSettings(details.Config)
Expand Down
14 changes: 7 additions & 7 deletions core/cache/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/juju/errors"
"github.com/juju/names/v4"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"

"github.com/juju/juju/core/model"
"github.com/juju/juju/core/permission"
Expand Down Expand Up @@ -430,7 +430,7 @@ func (m *Model) removeUnit(ch RemoveUnit) error {

unit, ok := m.units[ch.Name]
if ok {
m.hub.Publish(modelUnitRemove, unit.copy())
_ = m.hub.Publish(modelUnitRemove, unit.copy())
if err := unit.evict(); err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -501,7 +501,7 @@ func (m *Model) updateMachine(ch MachineChange, rm *residentManager) {
if !found {
machine = newMachine(m, rm.new())
m.machines[ch.Id] = machine
m.hub.Publish(modelAddRemoveMachine, []string{ch.Id})
_ = m.hub.Publish(modelAddRemoveMachine, []string{ch.Id})
}
machine.setDetails(ch)

Expand All @@ -515,7 +515,7 @@ func (m *Model) removeMachine(ch RemoveMachine) error {

machine, ok := m.machines[ch.Id]
if ok {
m.hub.Publish(modelAddRemoveMachine, []string{ch.Id})
_ = m.hub.Publish(modelAddRemoveMachine, []string{ch.Id})
if err := machine.evict(); err != nil {
return errors.Trace(err)
}
Expand Down Expand Up @@ -548,7 +548,7 @@ func (m *Model) removeBranch(ch RemoveBranch) error {

branch, ok := m.branches[ch.Id]
if ok {
m.hub.Publish(modelBranchRemove, branch.Name())
_ = m.hub.Publish(modelBranchRemove, branch.Name())
if err := branch.evict(); err != nil {
return errors.Trace(err)
}
Expand All @@ -570,7 +570,7 @@ func (m *Model) setDetails(details ModelChange) {
m.configHash = configHash
m.hashCache = hashCache
m.hashCache.incMisses()
m.hub.Publish(modelConfigChange, hashCache)
_ = m.hub.Publish(modelConfigChange, hashCache)
}

m.updateSummary()
Expand Down Expand Up @@ -764,6 +764,6 @@ func (m *Model) updateSummary() {
visibleTo: m.visibleTo,
hash: hash,
}
m.lastSummaryPublish = m.controllerHub.Publish(modelSummaryUpdatedTopic, payload)
m.lastSummaryPublish = pubsub.Wait(m.controllerHub.Publish(modelSummaryUpdatedTopic, payload))
m.summaryHash = hash
}
2 changes: 1 addition & 1 deletion core/cache/modelwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package cache
import (
"sync"

"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
"gopkg.in/tomb.v2"
)

Expand Down
3 changes: 2 additions & 1 deletion core/cache/modelwatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cache
import (
"time"

"github.com/juju/pubsub/v2"
"github.com/juju/worker/v2/workertest"
"github.com/kr/pretty"
gc "gopkg.in/check.v1"
Expand Down Expand Up @@ -111,7 +112,7 @@ func (s *modelWatcherSuite) TestMultipleUpdates(c *gc.C) {
// We know the events are handled in order, so we only need to wait for the
// last of the three events to have been processed.
select {
case <-handled:
case <-pubsub.Wait(handled):
case <-time.After(testing.LongWait):
c.Errorf("publish event not handled")
}
Expand Down
2 changes: 1 addition & 1 deletion core/cache/package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/juju/collections/set"
"github.com/juju/loggo"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
jujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/worker/v2/workertest"
Expand Down
4 changes: 2 additions & 2 deletions core/cache/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ func (u *Unit) setDetails(details UnitChange) {
// Publish a unit addition event if a unit gets a machine ID for the first
// time, or if this is a subordinate that was not previously in the cache.
if landingOnMachine || newSubordinate {
u.model.hub.Publish(modelUnitAdd, toPublish)
_ = u.model.hub.Publish(modelUnitAdd, toPublish)
}

// Publish change event for those that may be waiting.
u.model.hub.Publish(unitChangeTopic(details.Name), &toPublish)
_ = u.model.hub.Publish(unitChangeTopic(details.Name), &toPublish)
}

// copy returns a copy of the unit, ensuring appropriate deep copying.
Expand Down
2 changes: 1 addition & 1 deletion core/cache/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"

"github.com/juju/collections/set"
"github.com/juju/pubsub"
"github.com/juju/pubsub/v2"
"github.com/juju/worker/v2"
"gopkg.in/tomb.v2"
)
Expand Down
Loading

0 comments on commit 2120123

Please sign in to comment.