Skip to content

Commit 29d038b

Browse files
committed
Merge branch '2.9' into merge-2.9-20211126
2 parents 89faeee + 739511a commit 29d038b

File tree

270 files changed

+8260
-3479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

270 files changed

+8260
-3479
lines changed

.github/workflows/update-brew-formulae.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- cron: '0 */12 * * *'
77
jobs:
88
update-brew-tap:
9-
if: ${{ github.repository == "juju/juju" }}
9+
if: github.repository_owner == 'juju'
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Update Homebrew formulae

acceptancetests/assess_add_credentials.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def get_credentials(env, creds_path=juju_home):
101101
:return: Dict of credential information
102102
"""
103103
with open(os.path.join(creds_path, 'credentials.yaml')) as f:
104-
creds_dict = yaml.load(f)
104+
creds_dict = yaml.safe_load(f)
105105
cred = creds_dict['credentials'][env]
106106
return cred
107107

@@ -126,7 +126,7 @@ def verify_credentials_match(env, cred):
126126
:param cred: Dict of credential information
127127
"""
128128
with open(os.path.join(os.environ['JUJU_DATA'], 'credentials.yaml')) as f:
129-
test_creds = yaml.load(f)
129+
test_creds = yaml.safe_load(f)
130130
test_creds = test_creds['credentials'][env][env]
131131
if not test_creds == cred['credentials']:
132132
error = 'Credential miss-match after manual add'

acceptancetests/assess_network_health.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def setup_spaces(maas, bundle=None):
534534
return
535535
with open(bundle) as f:
536536
data = f.read()
537-
bundle_yaml = yaml.load(data)
537+
bundle_yaml = yaml.safe_load(data)
538538
existing_spaces = maas.spaces()
539539
new_spaces = _setup_spaces(bundle_yaml, existing_spaces)
540540
for space in new_spaces:

acceptancetests/jujupy/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def from_cloud_region(cls, cloud, region, config, clouds, juju_home):
320320
@classmethod
321321
def for_existing(cls, juju_data_dir, controller_name, model_name):
322322
with open(get_bootstrap_config_path(juju_data_dir)) as f:
323-
all_bootstrap = yaml.load(f)
323+
all_bootstrap = yaml.safe_load(f)
324324
ctrl_config = all_bootstrap['controllers'][controller_name]
325325
config = ctrl_config['controller-config']
326326
# config is expected to have a 1.x style of config, so mash up

acceptancetests/repository/trusty/haproxy/hooks/charmhelpers/core/services/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def __init__(self, *args):
179179
self.required_options = args
180180
self['config'] = hookenv.config()
181181
with open(os.path.join(hookenv.charm_dir(), 'config.yaml')) as fp:
182-
self.config = yaml.load(fp).get('options', {})
182+
self.config = yaml.safe_load(fp).get('options', {})
183183

184184
def __bool__(self):
185185
for option in self.required_options:
@@ -227,7 +227,7 @@ def read_context(self, file_name):
227227
if not os.path.isabs(file_name):
228228
file_name = os.path.join(hookenv.charm_dir(), file_name)
229229
with open(file_name, 'r') as file_stream:
230-
data = yaml.load(file_stream)
230+
data = yaml.safe_load(file_stream)
231231
if not data:
232232
raise OSError("%s is empty" % file_name)
233233
return data

acceptancetests/repository/trusty/haproxy/hooks/hooks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ def update_service_ports(old_service_ports=None, new_service_ports=None):
274274
# update_sysctl: create a sysctl.conf file from YAML-formatted 'sysctl' config
275275
# -----------------------------------------------------------------------------
276276
def update_sysctl(config_data):
277-
sysctl_dict = yaml.load(config_data.get("sysctl", "{}"))
277+
sysctl_dict = yaml.safe_load(config_data.get("sysctl", "{}"))
278278
if sysctl_dict:
279279
sysctl_file = open("/etc/sysctl.d/50-haproxy.conf", "w")
280280
for key in sysctl_dict:

acceptancetests/tests/test_deploy_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_dump_juju_timings(self):
212212
dump_juju_timings(client, fake_dir)
213213
with open(os.path.join(fake_dir,
214214
'juju_command_times.yaml')) as out_file:
215-
file_data = yaml.load(out_file)
215+
file_data = yaml.safe_load(out_file)
216216
self.assertEqual(file_data, expected)
217217

218218
def test_check_token(self):

acceptancetests/tests/test_jujucharm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_to_dir(self):
5858
charm.to_dir(charm_dir)
5959
metafile = os.path.join(charm_dir, 'metadata.yaml')
6060
with open(metafile) as f:
61-
metadata = yaml.load(f)
61+
metadata = yaml.safe_load(f)
6262
expected = {
6363
'name': 'test',
6464
'summary': 'a summary',
@@ -73,7 +73,7 @@ def test_to_repo_dir(self):
7373
charm.to_repo_dir(repo_dir)
7474
metafile = os.path.join(repo_dir, 'wily', 'test', 'metadata.yaml')
7575
with open(metafile) as f:
76-
metadata = yaml.load(f)
76+
metadata = yaml.safe_load(f)
7777
expected = {
7878
'name': 'test',
7979
'summary': 'a summary',

cmd/jujud/agent/addons/addons.go renamed to agent/addons/addons.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"github.com/juju/worker/v3/dependency"
1616
"github.com/prometheus/client_golang/prometheus"
1717

18-
"github.com/juju/juju/agent"
1918
"github.com/juju/juju/core/machinelock"
2019
"github.com/juju/juju/core/presence"
2120
"github.com/juju/juju/core/raftlease"
@@ -34,7 +33,7 @@ func DefaultIntrospectionSocketName(entityTag names.Tag) string {
3433
// IntrospectionConfig defines the various components that the introspection
3534
// worker reports on or needs to start up.
3635
type IntrospectionConfig struct {
37-
Agent agent.Agent
36+
AgentTag names.Tag
3837
Engine *dependency.Engine
3938
StatePoolReporter introspection.Reporter
4039
PubSubReporter introspection.Reporter
@@ -62,7 +61,7 @@ func StartIntrospection(cfg IntrospectionConfig) error {
6261
return nil
6362
}
6463

65-
socketName := cfg.NewSocketName(cfg.Agent.CurrentConfig().Tag())
64+
socketName := cfg.NewSocketName(cfg.AgentTag)
6665
w, err := cfg.WorkerFunc(introspection.Config{
6766
SocketName: socketName,
6867
DepEngine: cfg.Engine,

cmd/jujud/agent/addons/addons_test.go renamed to agent/addons/addons_test.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import (
1717
"github.com/juju/worker/v3/dependency"
1818
gc "gopkg.in/check.v1"
1919

20-
"github.com/juju/juju/agent"
21-
"github.com/juju/juju/cmd/jujud/agent/addons"
20+
"github.com/juju/juju/agent/addons"
2221
agenterrors "github.com/juju/juju/cmd/jujud/agent/errors"
2322
coretesting "github.com/juju/juju/testing"
2423
"github.com/juju/juju/worker/introspection"
@@ -54,7 +53,7 @@ func (s *introspectionSuite) TestStartError(c *gc.C) {
5453
}
5554

5655
cfg := addons.IntrospectionConfig{
57-
Agent: &dummyAgent{},
56+
AgentTag: names.NewMachineTag("42"),
5857
NewSocketName: addons.DefaultIntrospectionSocketName,
5958
WorkerFunc: func(_ introspection.Config) (worker.Worker, error) {
6059
return nil, errors.New("boom")
@@ -83,7 +82,7 @@ func (s *introspectionSuite) TestStartSuccess(c *gc.C) {
8382
c.Assert(err, jc.ErrorIsNil)
8483

8584
cfg := addons.IntrospectionConfig{
86-
Agent: &dummyAgent{},
85+
AgentTag: names.NewMachineTag("42"),
8786
Engine: engine,
8887
NewSocketName: func(tag names.Tag) string { return "bananas" },
8988
WorkerFunc: func(cfg introspection.Config) (worker.Worker, error) {
@@ -113,22 +112,6 @@ func (s *introspectionSuite) TestDefaultIntrospectionSocketName(c *gc.C) {
113112
c.Assert(name, gc.Equals, "jujud-machine-42")
114113
}
115114

116-
type dummyAgent struct {
117-
agent.Agent
118-
}
119-
120-
func (*dummyAgent) CurrentConfig() agent.Config {
121-
return &dummyConfig{}
122-
}
123-
124-
type dummyConfig struct {
125-
agent.Config
126-
}
127-
128-
func (*dummyConfig) Tag() names.Tag {
129-
return names.NewMachineTag("42")
130-
}
131-
132115
type dummyWorker struct {
133116
config introspection.Config
134117
done chan struct{}
File renamed without changes.

api/client.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,19 @@ func (c *Client) FindTools(majorVersion, minorVersion int, osType, arch, agentSt
306306
AgentStream: agentStream,
307307
}
308308
err = c.facade.FacadeCall("FindTools", args, &result)
309+
if err != nil {
310+
return result, errors.Trace(err)
311+
}
312+
if result.Error != nil {
313+
err = result.Error
314+
// We need to deal with older controllers.
315+
if strings.HasSuffix(result.Error.Message, "not valid") {
316+
err = errors.NewNotValid(result.Error, "finding tools")
317+
}
318+
if params.IsCodeNotFound(err) {
319+
err = errors.NewNotFound(err, "finding tools")
320+
}
321+
}
309322
return result, err
310323
}
311324

api/facadeversions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var facadeVersions = map[string]int{
2323
"ApplicationScaler": 1,
2424
"Backups": 3,
2525
"Block": 2,
26-
"Bundle": 5,
26+
"Bundle": 6,
2727
"CAASAgent": 2,
2828
"CAASAdmission": 1,
2929
"CAASApplication": 1,
@@ -41,7 +41,7 @@ var facadeVersions = map[string]int{
4141
"CharmRevisionUpdater": 2,
4242
"Charms": 4,
4343
"Cleaner": 2,
44-
"Client": 3,
44+
"Client": 4,
4545
"Cloud": 7,
4646
"Controller": 11,
4747
"CredentialManager": 1,

api/raftlease/client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
// Logger is a in place interface to represent a logger for consuming.
3030
type Logger interface {
3131
Errorf(string, ...interface{})
32+
Warningf(string, ...interface{})
33+
Infof(string, ...interface{})
3234
Debugf(string, ...interface{})
3335
Tracef(string, ...interface{})
3436
}
@@ -150,7 +152,7 @@ func (c *Client) Request(ctx context.Context, command *raftlease.Command) error
150152
// If we can't find a remote server for any reason, then return an
151153
// ErrDropped. This will cause the lease manager to correctly retry.
152154
if errors.IsNotFound(err) {
153-
c.config.Logger.Errorf("Masking %q with lease.ErrDropped to allow for retries", err)
155+
c.config.Logger.Debugf("Masking %q with lease.ErrDropped to allow for retries", err)
154156
return lease.ErrDropped
155157
}
156158
return errors.Trace(err)
@@ -220,7 +222,7 @@ func (c *Client) handleRetryRequestError(command *raftlease.Command, remote Remo
220222
if notLeaderError.ServerAddress() == "" {
221223
// The raft instance isn't clustered, we don't have a way
222224
// forward, so send back a dropped error.
223-
c.config.Logger.Errorf("No leader found and no cluster available, dropping command: %v", command)
225+
c.config.Logger.Infof("No leader found and no cluster available, dropping command: %v", command)
224226
}
225227

226228
// If it is a not leader error and we haven't got a remote, just
@@ -231,8 +233,8 @@ func (c *Client) handleRetryRequestError(command *raftlease.Command, remote Remo
231233
// Enqueuing into the queue just timed out, we should just
232234
// log this error and try again if possible. The lease manager
233235
// will know if a retry at that level is possible.
234-
c.config.Logger.Errorf("Deadline exceeded enqueuing command.")
235-
return remote, lease.ErrDropped
236+
c.config.Logger.Warningf("Rate limit enqueuing %q command. Deadline exceeded for lease %s model: %v.", command.Operation, command.Lease, command.ModelUUID)
237+
return remote, lease.ErrDeadlineExceeded
236238
}
237239

238240
// If we can't find a remote, we should just return that the error was
@@ -448,7 +450,7 @@ func (c *Client) ensureServers(addresses map[string]string) error {
448450
if err := remote.Wait(); err != nil {
449451
// We don't care in reality about the death rattle of a server, as
450452
// it's already dead to us.
451-
c.config.Logger.Errorf("error waiting for remote server death: %v", err)
453+
c.config.Logger.Warningf("error waiting for remote server death: %v", err)
452454
}
453455
// Ensure we still delete the id from the server list, even though the
454456
// remote Wait might have failed.

api/raftlease/client_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func (s *RaftLeaseClientSuite) TestRequestWithDeadlineExceededError(c *gc.C) {
208208
c.Assert(client.lastKnownRemote, gc.NotNil)
209209

210210
err = client.Request(context.TODO(), cmd)
211-
c.Assert(err, gc.ErrorMatches, `lease operation dropped`)
211+
c.Assert(err, gc.ErrorMatches, `lease deadline exceeded`)
212212

213213
// Ensure that a lease operation that has the deadline exceeded does not
214214
// drop the lastKnownRemote.
@@ -616,9 +616,11 @@ func (s *RaftLeaseRemoteSuite) setupMocks(c *gc.C) *gomock.Controller {
616616

617617
type fakeLogger struct{}
618618

619-
func (fakeLogger) Errorf(string, ...interface{}) {}
620-
func (fakeLogger) Debugf(string, ...interface{}) {}
621-
func (fakeLogger) Tracef(string, ...interface{}) {}
619+
func (fakeLogger) Errorf(string, ...interface{}) {}
620+
func (fakeLogger) Warningf(string, ...interface{}) {}
621+
func (fakeLogger) Infof(string, ...interface{}) {}
622+
func (fakeLogger) Debugf(string, ...interface{}) {}
623+
func (fakeLogger) Tracef(string, ...interface{}) {}
622624

623625
type fakeClientMetrics struct{}
624626

api/state_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func (s *stateSuite) TestAllFacadeVersionsSafeFromMutation(c *gc.C) {
275275
}
276276

277277
func (s *stateSuite) TestBestFacadeVersion(c *gc.C) {
278-
c.Check(s.APIState.BestFacadeVersion("Client"), gc.Equals, 3)
278+
c.Check(s.APIState.BestFacadeVersion("Client"), gc.Equals, 4)
279279
}
280280

281281
func (s *stateSuite) TestAPIHostPortsMovesConnectedValueFirst(c *gc.C) {

apiserver/allfacades.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func AllFacades() *facade.Registry {
158158
reg("Bundle", 3, bundle.NewFacadeV3)
159159
reg("Bundle", 4, bundle.NewFacadeV4)
160160
reg("Bundle", 5, bundle.NewFacadeV5)
161+
reg("Bundle", 6, bundle.NewFacadeV6)
161162
reg("CharmHub", 1, charmhub.NewFacade)
162163
reg("CharmDownloader", 1, charmdownloader.NewFacadeV1)
163164
reg("CharmRevisionUpdater", 2, charmrevisionupdater.NewCharmRevisionUpdaterAPI)
@@ -167,7 +168,8 @@ func AllFacades() *facade.Registry {
167168
reg("Cleaner", 2, cleaner.NewCleanerAPI)
168169
reg("Client", 1, client.NewFacadeV1)
169170
reg("Client", 2, client.NewFacadeV2)
170-
reg("Client", 3, client.NewFacade)
171+
reg("Client", 3, client.NewFacadeV3)
172+
reg("Client", 4, client.NewFacade)
171173
reg("Cloud", 1, cloud.NewFacadeV1)
172174
reg("Cloud", 2, cloud.NewFacadeV2) // adds AddCloud, AddCredentials, CredentialContents, RemoveClouds
173175
reg("Cloud", 3, cloud.NewFacadeV3) // changes signature of UpdateCredentials, adds ModifyCloudAccess

apiserver/common/crossmodel/crossmodel.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,6 @@ func GetOfferingRelationTokens(backend Backend, tag names.RelationTag) (string,
198198
}
199199
appToken, err := backend.GetToken(names.NewApplicationTag(offerName))
200200
if err != nil {
201-
// TODO(babbageclunk): do we need to try getting the appToken
202-
// for the application name instead (opposite of the fallback
203-
// in
204-
// apiserver/facades/controller/crossmodelrelations/crossmodelrelations.go:296)?
205-
// I don't think so because this method is only called from
206-
// API methods that were added after the transition to offer
207-
// name as the app token.
208201
return "", "", errors.Annotatef(err, "getting token for application %q", offerName)
209202
}
210203
return relationToken, appToken, nil

apiserver/common/crossmodel/state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (st stateShim) ControllerTag() names.ControllerTag {
7474
return st.Model.ControllerTag()
7575
}
7676

77-
// ControllerTag returns the tag of the controller in which we are operating.
77+
// ModelTag returns the tag of the model in which we are operating.
7878
// This is a temporary transitional step.
7979
func (st stateShim) ModelTag() names.ModelTag {
8080
return st.Model.ModelTag()

apiserver/common/networkingcommon/linklayer.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ type LinkLayerMachine interface {
108108
// AssertAliveOp returns a transaction operation for asserting
109109
// that the machine is currently alive.
110110
AssertAliveOp() txn.Op
111+
112+
// ModelUUID returns the unique identifier
113+
// for the model that this machine is in.
114+
ModelUUID() string
111115
}
112116

113117
// LinkLayerState describes methods required for sanitising and persisting
@@ -163,14 +167,17 @@ type MachineLinkLayerOp struct {
163167
existingAddrs []LinkLayerAddress
164168
}
165169

166-
// NewMachineLinkLayerOp returns a reference that can be embedded in a model
167-
// operation for updating the input machine's link layer data.
168-
func NewMachineLinkLayerOp(machine LinkLayerMachine, incoming network.InterfaceInfos) *MachineLinkLayerOp {
169-
logger.Infof("processing link-layer devices for machine %q", machine.Id())
170+
// NewMachineLinkLayerOp returns a reference that can be embedded in a
171+
// model operation for updating the input machine's link layer data.
172+
func NewMachineLinkLayerOp(source string, machine LinkLayerMachine, in network.InterfaceInfos) *MachineLinkLayerOp {
173+
logger.Infof(
174+
"processing %s-sourced link-layer devices for machine %q in model %q",
175+
source, machine.Id(), machine.ModelUUID(),
176+
)
170177

171178
return &MachineLinkLayerOp{
172179
machine: machine,
173-
incoming: incoming,
180+
incoming: in,
174181
}
175182
}
176183

0 commit comments

Comments
 (0)