Skip to content

Commit

Permalink
Merge pull request #9299 from wallyworld/merge-2.4-20181010
Browse files Browse the repository at this point in the history
#9299

## Description of change

Merge 2.4 into develop, picking up these PRs:
#9287 container networking, manually provisioned machines
#9296 more robust cmr controller connectivity
#9251 Fix the exporting of the series of the application when exporting a bundle
#9293 bundle deploy panic
#9285 tomb.Go shouldn't be called multiple times from a non-tomb managed goroutine
#9263 Add back the state of each unit in a relation to goal state
#9235 handle maas partitions in a storage constraint
#9191 Add a default retry inside 'juju status'
#9177 latest ec2 instance types
#9180 fix space check before upgrade
#9159 mongo collection size

## QA steps

bootstrap smoke test
  • Loading branch information
jujubot committed Oct 11, 2018
2 parents 2aeaefb + b824234 commit f364d72
Show file tree
Hide file tree
Showing 59 changed files with 13,967 additions and 7,703 deletions.
8 changes: 4 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
name = "github.com/hashicorp/raft-boltdb"

[[constraint]]
revision = "bc5b7e5db16683db8ddffa7eef67b53706a4618a"
revision = "735c14e2335ad2d8112482794d69629c0517476c"
name = "github.com/juju/bundlechanges"

[[constraint]]
Expand All @@ -73,7 +73,7 @@
name = "github.com/juju/gojsonschema"

[[constraint]]
revision = "abe11904dd8cd40f0777b7704ae60348a876542e"
revision = "8a8cec793ba70659ba95f1b9a491ba807169bfc3"
name = "github.com/juju/gomaasapi"

[[constraint]]
Expand Down
38 changes: 28 additions & 10 deletions apiserver/common/crossmodel/crossmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,42 @@ func PublishRelationChange(backend Backend, relationTag names.Tag, change params
logger.Debugf("application tag for token %+v is %v", change.ApplicationToken, applicationTag)

// If the remote model has destroyed the relation, do it here also.
forceCleanUp := change.ForceCleanup != nil && *change.ForceCleanup
if dyingOrDead {
logger.Debugf("remote side of %v died", relationTag)
logger.Debugf("remote consuming side of %v died", relationTag)
if forceCleanUp {
logger.Debugf("forcing cleanup of units for %v", applicationTag.Id())
remoteUnits, err := rel.AllRemoteUnits(applicationTag.Id())
if err != nil {
return errors.Trace(err)
}
logger.Debugf("got %v relation units to clean", len(remoteUnits))
for _, ru := range remoteUnits {
if err := ru.LeaveScope(); err != nil {
return errors.Trace(err)
}
}
}

if err := rel.Destroy(); err != nil {
return errors.Trace(err)
}
// See if we need to remove the remote application proxy - we do this
// on the offering side as there is 1:1 between proxy and consuming app.
if applicationTag != nil {
remoteApp, err := backend.RemoteApplication(applicationTag.Id())
if err != nil && !errors.IsNotFound(err) {
remoteApp, err := backend.RemoteApplication(applicationTag.Id())
if err != nil && !errors.IsNotFound(err) {
return errors.Trace(err)
}
if err == nil && remoteApp.IsConsumerProxy() {
logger.Debugf("destroy consuming app proxy for %v", applicationTag.Id())
if err := remoteApp.Destroy(); err != nil {
return errors.Trace(err)
}
if err == nil && remoteApp.IsConsumerProxy() {
logger.Debugf("destroy consuming app proxy for %v", applicationTag.Id())
if err := remoteApp.Destroy(); err != nil {
return errors.Trace(err)
}
}
}

// If we are forcing cleanup, we can exit early here.
if forceCleanUp {
return nil
}
}

Expand Down
4 changes: 4 additions & 0 deletions apiserver/common/crossmodel/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ type Relation interface {
// with the supplied ID.
RemoteUnit(unitId string) (RelationUnit, error)

// AllRemoteUnits returns all the RelationUnits for the remote
// application units for a given application.
AllRemoteUnits(appName string) ([]RelationUnit, error)

// Endpoints returns the endpoints that constitute the relation.
Endpoints() []state.Endpoint

Expand Down
12 changes: 12 additions & 0 deletions apiserver/common/crossmodel/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ func (r relationShim) RemoteUnit(unitId string) (RelationUnit, error) {
return relationUnitShim{ru}, nil
}

func (r relationShim) AllRemoteUnits(appName string) ([]RelationUnit, error) {
all, err := r.Relation.AllRemoteUnits(appName)
if err != nil {
return nil, errors.Trace(err)
}
result := make([]RelationUnit, len(all))
for i, ru := range all {
result[i] = relationUnitShim{ru}
}
return result, nil
}

func (r relationShim) Unit(unitId string) (RelationUnit, error) {
unit, err := r.st.Unit(unitId)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions apiserver/common/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ func NewMultiNotifyWatcher(w ...state.NotifyWatcher) *MultiNotifyWatcher {
for _, w := range w {
// Consume the first event of each watcher.
<-w.Changes()
wCopy := w
m.tomb.Go(func() error {
go func(wCopy state.NotifyWatcher) {
defer wg.Done()
return wCopy.Wait()
})
wCopy.Wait()
}(w)
// Copy events from the watcher to the staging channel.
go copyEvents(staging, w.Changes(), &m.tomb)
}
Expand Down
36 changes: 25 additions & 11 deletions apiserver/facades/agent/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,9 @@ func (ctx *prepareOrGetContext) SetError(idx int, err *params.Error) {
ctx.result.Results[idx].Error = err
}

func (ctx *prepareOrGetContext) ProcessOneContainer(env environs.Environ, callContext context.ProviderCallContext, idx int, host, container *state.Machine) error {
func (ctx *prepareOrGetContext) ProcessOneContainer(
env environs.Environ, callContext context.ProviderCallContext, idx int, host, container *state.Machine,
) error {
containerId, err := container.InstanceId()
if ctx.maintain {
if err == nil {
Expand All @@ -877,10 +879,9 @@ func (ctx *prepareOrGetContext) ProcessOneContainer(env environs.Environ, callCo
}
// The only error we allow is NotProvisioned
if err != nil && !errors.IsNotProvisioned(err) {
return err
return errors.Trace(err)
}

supportContainerAddresses := environs.SupportsContainerAddresses(callContext, env)
bridgePolicy := containerizer.BridgePolicy{
NetBondReconfigureDelay: env.Config().NetBondReconfigureDelay(),
ContainerNetworkingMethod: env.Config().ContainerNetworkingMethod(),
Expand All @@ -891,12 +892,23 @@ func (ctx *prepareOrGetContext) ProcessOneContainer(env environs.Environ, callCo
// into things we'd like to tell the Host machine to create, and then *it*
// reports back what actually exists when its done.
if err := bridgePolicy.PopulateContainerLinkLayerDevices(host, container); err != nil {
return err
return errors.Trace(err)
}

containerDevices, err := container.AllLinkLayerDevices()
if err != nil {
return err
return errors.Trace(err)
}

// We do not ask the provider to allocate addresses for manually provisioned
// machines as we do not expect such machines to be recognised (LP:1796106).
askProviderForAddress := false
hostIsManual, err := host.IsManual()
if err != nil {
return errors.Trace(err)
}
if !hostIsManual {
askProviderForAddress = environs.SupportsContainerAddresses(callContext, env)
}

preparedInfo := make([]network.InterfaceInfo, len(containerDevices))
Expand All @@ -910,7 +922,7 @@ func (ctx *prepareOrGetContext) ProcessOneContainer(env environs.Environ, callCo
}
parentAddrs, err := parentDevice.Addresses()
if err != nil {
return err
return errors.Trace(err)
}

info := network.InterfaceInfo{
Expand All @@ -927,7 +939,7 @@ func (ctx *prepareOrGetContext) ProcessOneContainer(env environs.Environ, callCo
if len(parentAddrs) > 0 {
logger.Debugf("host machine device %q has addresses %v", parentDevice.Name(), parentAddrs)
firstAddress := parentAddrs[0]
if supportContainerAddresses {
if askProviderForAddress {
parentDeviceSubnet, err := firstAddress.Subnet()
if err != nil {
return errors.Annotatef(err,
Expand Down Expand Up @@ -962,15 +974,17 @@ func (ctx *prepareOrGetContext) ProcessOneContainer(env environs.Environ, callCo
hostInstanceId, err := host.InstanceId()
if err != nil {
// this should have already been checked in the processEachContainer helper
return err
return errors.Trace(err)
}

allocatedInfo := preparedInfo
if supportContainerAddresses {
if askProviderForAddress {
// supportContainerAddresses already checks that we can cast to an environ.Networking
networking := env.(environs.Networking)
allocatedInfo, err = networking.AllocateContainerAddresses(callContext, hostInstanceId, container.MachineTag(), preparedInfo)
allocatedInfo, err = networking.AllocateContainerAddresses(
callContext, hostInstanceId, container.MachineTag(), preparedInfo)
if err != nil {
return err
return errors.Trace(err)
}
logger.Debugf("got allocated info from provider: %+v", allocatedInfo)
} else {
Expand Down
49 changes: 17 additions & 32 deletions apiserver/facades/agent/uniter/goal-state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,9 @@ func (s *uniterGoalStateSuite) TestGoalStatesSingleRelation(c *gc.C) {
Result: &params.GoalState{
Units: expectedUnitWordpress,
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
},
},
},
Expand Down Expand Up @@ -226,11 +224,9 @@ func (s *uniterGoalStateSuite) TestGoalStatesDeadUnitsExcluded(c *gc.C) {
Result: &params.GoalState{
Units: expected2UnitsWordPress,
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
},
},
},
Expand All @@ -248,11 +244,9 @@ func (s *uniterGoalStateSuite) TestGoalStatesDeadUnitsExcluded(c *gc.C) {
"wordpress/0": expectedUnitStatus,
},
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
},
},
},
Expand Down Expand Up @@ -303,11 +297,9 @@ func (s *uniterGoalStateSuite) TestGoalStatesSingleRelationDyingUnits(c *gc.C) {
Result: &params.GoalState{
Units: expected2UnitsWordPress,
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
},
},
},
Expand All @@ -330,11 +322,9 @@ func (s *uniterGoalStateSuite) TestGoalStatesSingleRelationDyingUnits(c *gc.C) {
},
},
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
},
},
},
Expand All @@ -358,11 +348,9 @@ func (s *uniterGoalStateSuite) TestGoalStatesCrossModelRelation(c *gc.C) {
"wordpress/0": expectedUnitStatus,
},
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
},
},
},
Expand Down Expand Up @@ -391,11 +379,9 @@ func (s *uniterGoalStateSuite) TestGoalStatesCrossModelRelation(c *gc.C) {
"wordpress/0": expectedUnitStatus,
},
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
"ctrl1:admin/default.mysql": expectedRelationStatus,
},
},
Expand Down Expand Up @@ -442,12 +428,11 @@ func (s *uniterGoalStateSuite) TestGoalStatesMultipleRelations(c *gc.C) {
Result: &params.GoalState{
Units: expected2UnitsWordPress,
Relations: map[string]params.UnitsGoalState{
"db": {
"wordpress": expectedRelationStatus,
},
"server": {
"mysql": expectedRelationStatus,
"mysql1": expectedRelationStatus,
"mysql": expectedRelationStatus,
"mysql/0": expectedUnitStatus,
"mysql1": expectedRelationStatus,
"mysql1/0": expectedUnitStatus,
},
},
},
Expand Down

0 comments on commit f364d72

Please sign in to comment.