Skip to content

Commit

Permalink
Merge branch 'develop' into tomb.v1-tomb.v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Veebers committed May 31, 2018
2 parents 06507ff + 4d6ae83 commit 3ea2f9e
Show file tree
Hide file tree
Showing 466 changed files with 5,563 additions and 3,285 deletions.
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,37 @@ Continuous integration is automated through Jenkins:
The bot runs on all commits during the PRE process,
as well as handles merges. Use the `$$merge$$` comment to land PR's.


Static Analysis
---------------

Static Analysis of the code is provided by [gometalinter](https://github.com/alecthomas/gometalinter).

The Static Analysis runs every linter in parallel over the juju code base with
the aim to spot any potential errors that should be resolved. As a default all
the linters are disabled and only a selection of linters are run on each pass.
The linters that are run, are known to pass with the state of the current code
base.

You can independantly run the linters on the code base to validate any issues
before committing or pushing using the following command from the root of the
repo:

```shell
./scripts/gometalinter.bash
```

If you already have the git hook installed for pre-pushing, then the linters
will also run during that check.

Adding new linters can be done, by editing the `./scripts/gometalinter.bash`
file to also including/removing the desired linters.

Additionally to turn off the linter check for pushing or verifying then
setting the environment variable `IGNORE_GOMETALINTER` before hand will cause
this to happen.


Community
=========

Expand Down
2 changes: 1 addition & 1 deletion acceptancetests/assess_caas_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
""" Test caas k8s cluster bootstrap
Spinning up k8s cluster and asserting the cluster is `healthy` - in this case, healthy means the k8s api server
Expand Down
37 changes: 37 additions & 0 deletions acceptancetests/deploy_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@
__metaclass__ = type


LXD_PROFILE = """
name: juju-{model_name}
config:
boot.autostart: "true"
linux.kernel_modules: ip_tables,ip6_tables,netlink_diag,nf_nat,overlay
raw.lxc: |
lxc.apparmor.profile=unconfined
lxc.mount.auto=proc:rw sys:rw
lxc.cap.drop=
security.nesting: "true"
security.privileged: "true"
description: ""
devices:
aadisable:
path: /sys/module/nf_conntrack/parameters/hashsize
source: /dev/null
type: disk
aadisable1:
path: /sys/module/apparmor/parameters/enabled
source: /dev/null
type: disk
"""


class NoExistingController(Exception):
pass

Expand Down Expand Up @@ -112,9 +136,22 @@ def deploy_dummy_stack(client, charm_series, use_charmstore=False):


def deploy_caas_stack(bundle_path, client, timeout=3600):
# workaround to ensure lxd profile
model_name = client.model_name
profile = LXD_PROFILE.format(model_name=model_name)
with subprocess.Popen(('echo', profile), stdout=subprocess.PIPE) as echo:
subprocess.check_output(
('lxc', 'profile', 'edit', 'juju-%s' % model_name),
stdin=echo.stdout
).decode('UTF-8').strip()

client.deploy_bundle(bundle_path, static_bundle=True)
# Wait for the deployment to finish.
client.wait_for_started(timeout=timeout)
# wait for cluster to stablize
client.wait_for_workloads()
# get current status with tabular format for better debugging
client.juju(client._show_status, ('--format', 'tabular'))
return CaasClient(client)


Expand Down
2 changes: 1 addition & 1 deletion acceptancetests/jujupy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,7 @@ def __init__(self, client):
self.client.juju('scp', ('kubernetes-master/0:config', self.kube_config_path))

# ensure kubectl by scp from master
self.client.juju('scp', ('kubernetes-master/0:/snap/bin/kubectl', self.kubectl_path))
self.client.juju('scp', ('kubernetes-master/0:/snap/kubectl/current/kubectl', self.kubectl_path))

self.client.controller_juju('add-k8s', (self.cloud_name,))
log.debug('added caas cloud, now all clouds are -> \n%s', self.client.list_clouds(format='yaml'))
Expand Down
4 changes: 2 additions & 2 deletions acceptancetests/repository/bundles-kubernetes-core-lxd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
expose: true
num_units: 1
options:
channel: 1.10/stable
channel: 1.9/stable
to:
- '0'
kubernetes-worker:
Expand All @@ -52,7 +52,7 @@ services:
expose: true
num_units: 1
options:
channel: 1.10/stable
channel: 1.9/stable
docker_runtime: apt
proxy-extra-args: proxy-mode=userspace
to:
Expand Down
2 changes: 1 addition & 1 deletion agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (

"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/os/series"
"github.com/juju/utils"
"github.com/juju/utils/series"
"github.com/juju/utils/shell"
"github.com/juju/version"
"gopkg.in/juju/names.v2"
Expand Down
2 changes: 1 addition & 1 deletion agent/agentbootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
coreraft "github.com/hashicorp/raft"
"github.com/juju/errors"
"github.com/juju/loggo"
"github.com/juju/os/series"
"github.com/juju/utils"
"github.com/juju/utils/clock"
"github.com/juju/utils/series"
"gopkg.in/juju/names.v2"
"gopkg.in/mgo.v2"

Expand Down
2 changes: 1 addition & 1 deletion agent/agentbootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"net"
"path/filepath"

"github.com/juju/os/series"
gitjujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
"github.com/juju/utils/series"
gc "gopkg.in/check.v1"
"gopkg.in/juju/names.v2"

Expand Down
2 changes: 1 addition & 1 deletion agent/tools/symlinks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"path/filepath"
"time"

"github.com/juju/os/series"
jc "github.com/juju/testing/checkers"
"github.com/juju/utils"
"github.com/juju/utils/arch"
"github.com/juju/utils/series"
"github.com/juju/utils/symlink"
"github.com/juju/version"
gc "gopkg.in/check.v1"
Expand Down
4 changes: 2 additions & 2 deletions api/action/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ func (c *Client) Cancel(arg params.Entities) (params.ActionResults, error) {
}

// applicationsCharmActions is a batched query for the charm.Actions for a slice
// of services by Entity.
// of applications by Entity.
func (c *Client) applicationsCharmActions(arg params.Entities) (params.ApplicationsCharmActionsResults, error) {
results := params.ApplicationsCharmActionsResults{}
err := c.facade.FacadeCall("ApplicationsCharmsActions", arg, &results)
return results, err
}

// ApplicationCharmActions is a single query which uses ApplicationsCharmsActions to
// get the charm.Actions for a single Service by tag.
// get the charm.Actions for a single Application by tag.
func (c *Client) ApplicationCharmActions(arg params.Entity) (map[string]params.ActionSpec, error) {
tags := params.Entities{Entities: []params.Entity{{Tag: arg.Tag}}}
results, err := c.applicationsCharmActions(tags)
Expand Down
2 changes: 1 addition & 1 deletion api/action/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (s *actionSuite) TestApplicationCharmActions(c *gc.C) {
expectedErr string
expectedResult map[string]params.ActionSpec
}{{
description: "result from wrong service",
description: "result from wrong application",
patchResults: []params.ApplicationCharmActionsResult{
{
ApplicationTag: names.NewApplicationTag("bar").String(),
Expand Down
2 changes: 1 addition & 1 deletion api/action/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (c *Client) RunOnAllMachines(commands string, timeout time.Duration) ([]par
}

// Run the Commands specified on the machines identified through the ids
// provided in the machines, services and units slices.
// provided in the machines, applications and units slices.
func (c *Client) Run(run params.RunParams) ([]params.ActionResult, error) {
var results params.ActionResults
err := c.facade.FacadeCall("Run", run, &results)
Expand Down
2 changes: 1 addition & 1 deletion api/allwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (o orderedDeltas) kindPriority(kind string) int {
switch kind {
case "machine":
return 1
case "service":
case "application":
return 2
case "relation":
return 3
Expand Down
4 changes: 2 additions & 2 deletions api/annotations/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func (s *annotationsMockSuite) TestSetEntitiesAnnotation(c *gc.C) {
annts := map[string]string{"annotation1": "test"}
annts2 := map[string]string{"annotation2": "test"}
setParams := map[string]map[string]string{
"charmA": annts,
"serviceB": annts2,
"charmA": annts,
"applicationB": annts2,
}
apiCaller := basetesting.APICallerFunc(
func(objType string,
Expand Down
18 changes: 9 additions & 9 deletions api/application/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

var logger = loggo.GetLogger("juju.api.application")

// Client allows access to the service API end point.
// Client allows access to the application API end point.
type Client struct {
base.ClientFacade
st base.APICallCloser
Expand All @@ -39,9 +39,9 @@ func NewClient(st base.APICallCloser) *Client {
}

// SetMetricCredentials sets the metric credentials for the application specified.
func (c *Client) SetMetricCredentials(service string, credentials []byte) error {
func (c *Client) SetMetricCredentials(application string, credentials []byte) error {
creds := []params.ApplicationMetricCredential{
{service, credentials},
{application, credentials},
}
p := params.ApplicationMetricCredentials{creds}
results := new(params.ErrorResults)
Expand All @@ -61,7 +61,7 @@ func (c *Client) ModelUUID() string {
return tag.Id()
}

// DeployArgs holds the arguments to be sent to Client.ServiceDeploy.
// DeployArgs holds the arguments to be sent to Client.ApplicationDeploy.
type DeployArgs struct {

// CharmID identifies the charm to deploy.
Expand Down Expand Up @@ -154,11 +154,11 @@ func (c *Client) Deploy(args DeployArgs) error {
return errors.Trace(results.OneError())
}

// GetCharmURL returns the charm URL the given service is
// GetCharmURL returns the charm URL the given application is
// running at present.
func (c *Client) GetCharmURL(serviceName string) (*charm.URL, error) {
func (c *Client) GetCharmURL(applicationName string) (*charm.URL, error) {
result := new(params.StringResult)
args := params.ApplicationGet{ApplicationName: serviceName}
args := params.ApplicationGet{ApplicationName: applicationName}
err := c.facade.FacadeCall("GetCharmURL", args, result)
if err != nil {
return nil, errors.Trace(err)
Expand Down Expand Up @@ -242,7 +242,7 @@ func describeV5(config map[string]interface{}) (map[string]interface{}, error) {
}

// SetCharmConfig holds the configuration for setting a new revision of a charm
// on a service.
// on a application.
type SetCharmConfig struct {
// ApplicationName is the name of the application to set the charm on.
ApplicationName string
Expand Down Expand Up @@ -278,7 +278,7 @@ type SetCharmConfig struct {
StorageConstraints map[string]storage.Constraints `json:"storage-constraints,omitempty"`
}

// SetCharm sets the charm for a given service.
// SetCharm sets the charm for a given application.
func (c *Client) SetCharm(cfg SetCharmConfig) error {
var storageConstraints map[string]params.StorageConstraints
if len(cfg.StorageConstraints) > 0 {
Expand Down
14 changes: 7 additions & 7 deletions api/application/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func newClientV4(f basetesting.APICallerFunc) *application.Client {
return application.NewClient(basetesting.BestVersionCaller{f, 4})
}

func (s *applicationSuite) TestSetServiceMetricCredentials(c *gc.C) {
func (s *applicationSuite) TestSetApplicationMetricCredentials(c *gc.C) {
var called bool
client := newClient(func(objType string, version int, id, request string, a, response interface{}) error {
called = true
Expand All @@ -47,19 +47,19 @@ func (s *applicationSuite) TestSetServiceMetricCredentials(c *gc.C) {
args, ok := a.(params.ApplicationMetricCredentials)
c.Assert(ok, jc.IsTrue)
c.Assert(args.Creds, gc.HasLen, 1)
c.Assert(args.Creds[0].ApplicationName, gc.Equals, "serviceA")
c.Assert(args.Creds[0].ApplicationName, gc.Equals, "applicationA")
c.Assert(args.Creds[0].MetricCredentials, gc.DeepEquals, []byte("creds 1"))

result := response.(*params.ErrorResults)
result.Results = make([]params.ErrorResult, 1)
return nil
})
err := client.SetMetricCredentials("serviceA", []byte("creds 1"))
err := client.SetMetricCredentials("applicationA", []byte("creds 1"))
c.Assert(err, jc.ErrorIsNil)
c.Assert(called, jc.IsTrue)
}

func (s *applicationSuite) TestSetServiceMetricCredentialsFails(c *gc.C) {
func (s *applicationSuite) TestSetApplicationMetricCredentialsFails(c *gc.C) {
var called bool
client := newClient(func(objType string, version int, id, request string, a, response interface{}) error {
called = true
Expand Down Expand Up @@ -88,7 +88,7 @@ func (s *applicationSuite) TestDeploy(c *gc.C) {
c.Assert(args.Applications, gc.HasLen, 1)
app := args.Applications[0]
c.Assert(app.CharmURL, gc.Equals, "cs:trusty/a-charm-1")
c.Assert(app.ApplicationName, gc.Equals, "serviceA")
c.Assert(app.ApplicationName, gc.Equals, "applicationA")
c.Assert(app.Series, gc.Equals, "series")
c.Assert(app.NumUnits, gc.Equals, 1)
c.Assert(app.ConfigYAML, gc.Equals, "configYAML")
Expand All @@ -112,7 +112,7 @@ func (s *applicationSuite) TestDeploy(c *gc.C) {
CharmID: charmstore.CharmID{
URL: charm.MustParseURL("trusty/a-charm-1"),
},
ApplicationName: "serviceA",
ApplicationName: "applicationA",
Series: "series",
NumUnits: 1,
ConfigYAML: "configYAML",
Expand Down Expand Up @@ -227,7 +227,7 @@ func (s *applicationSuite) TestAddUnitsAttachStorageMultipleUnits(c *gc.C) {
c.Assert(called, jc.IsFalse)
}

func (s *applicationSuite) TestServiceGetCharmURL(c *gc.C) {
func (s *applicationSuite) TestApplicationGetCharmURL(c *gc.C) {
var called bool
client := newClient(func(objType string, version int, id, request string, a, response interface{}) error {
called = true
Expand Down
14 changes: 7 additions & 7 deletions api/applicationscaler/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewAPI(caller base.APICaller, newWatcher NewWatcherFunc) *API {
}
}

// Watch returns a StringsWatcher that delivers the names of services
// Watch returns a StringsWatcher that delivers the names of applications
// that may need to be rescaled.
func (api *API) Watch() (watcher.StringsWatcher, error) {
var result params.StringsWatchResult
Expand All @@ -50,15 +50,15 @@ func (api *API) Watch() (watcher.StringsWatcher, error) {
// Rescale requests that all supplied application names be rescaled to
// their minimum configured sizes. It returns the first error it
// encounters.
func (api *API) Rescale(services []string) error {
func (api *API) Rescale(applications []string) error {
args := params.Entities{
Entities: make([]params.Entity, len(services)),
Entities: make([]params.Entity, len(applications)),
}
for i, service := range services {
if !names.IsValidApplication(service) {
return errors.NotValidf("application name %q", service)
for i, application := range applications {
if !names.IsValidApplication(application) {
return errors.NotValidf("application name %q", application)
}
tag := names.NewApplicationTag(service)
tag := names.NewApplicationTag(application)
args.Entities[i].Tag = tag.String()
}
var results params.ErrorResults
Expand Down
Loading

0 comments on commit 3ea2f9e

Please sign in to comment.