Skip to content

Commit

Permalink
Merge branch '2.9' of github.com:juju/juju into fix/lp-1935953
Browse files Browse the repository at this point in the history
  • Loading branch information
ycliuhw committed Aug 23, 2021
2 parents b042688 + da51e55 commit e1e9279
Show file tree
Hide file tree
Showing 1,075 changed files with 15,875 additions and 5,676 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/microk8s-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
cp -r canonical-osm/charms/interfaces/juju-relation-mysql mysql
sudo pip3 install -r requirements.txt -r test-requirements.txt
sudo pip3 install tox
python3 ./scripts/cli.py microk8s setup --test-mode --config caas-image-repo=$DOCKER_USERNAME --services ''
KUBEFLOW_AUTH_PASSWORD=foobar python3 ./scripts/cli.py --debug deploy-to uk8s --cloud microk8s --bundle edge --channel stable
Expand All @@ -98,7 +99,7 @@ jobs:
sg microk8s <<EOF
set -eux
cd bundle-kubeflow
./tests/run.sh -m edge
tox -e tests -- -m edge
EOF
- name: Juju status
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/update-brew-formulae.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- cron: '0 */12 * * *'
jobs:
update-brew-tap:
if: ${{ github.repository == "juju/juju" }}
runs-on: ubuntu-latest
steps:
- name: Update Homebrew formulae
Expand Down
4 changes: 3 additions & 1 deletion acceptancetests/assess_caas_deploy_kubeflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def prepare(caas_client, caas_provider, build):

caas_client.sh('rm', '-rf', f'{KUBEFLOW_DIR}')
caas_client.sh('git', 'clone', KUBEFLOW_REPO_URI, KUBEFLOW_DIR)
caas_client.sh('pip3', 'install', 'tox')
caas_client.sh(
'pip3', 'install',
'-r', f'{KUBEFLOW_DIR}/requirements.txt',
Expand Down Expand Up @@ -354,7 +355,8 @@ def run_test(caas_provider, caas_client, k8s_model, bundle, build):
# TODO: tmp fix, remove me later once current kubeflow master branch published.
caas_client.sh('git', 'reset', '--hard', '5e0b6fcb')

run("sg", "microk8s", "-c", f"{KUBEFLOW_DIR}/tests/run.sh -m {bundle}")
run("tox", "-e", "tests", "--", f"-m {bundle} -k 'not selenium'")
run("tox", "-e", "tests", "--", f"-m {bundle} -k 'selenium'")


def dump_k8s_log(artifacts_dir, file_name, content):
Expand Down
35 changes: 7 additions & 28 deletions api/caasapplicationprovisioner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,19 @@ import (
// Client allows access to the CAAS application provisioner API endpoint.
type Client struct {
facade base.FacadeCaller
*charmscommon.CharmsClient
*charmscommon.CharmInfoClient
*charmscommon.ApplicationCharmInfoClient
}

// NewClient returns a client used to access the CAAS Application Provisioner API.
func NewClient(caller base.APICaller) *Client {
facadeCaller := base.NewFacadeCaller(caller, "CAASApplicationProvisioner")
charmsClient := charmscommon.NewCharmsClient(facadeCaller)
charmInfoClient := charmscommon.NewCharmInfoClient(facadeCaller)
appCharmInfoClient := charmscommon.NewApplicationCharmInfoClient(facadeCaller)
return &Client{
facade: facadeCaller,
CharmsClient: charmsClient,
facade: facadeCaller,
CharmInfoClient: charmInfoClient,
ApplicationCharmInfoClient: appCharmInfoClient,
}
}

Expand Down Expand Up @@ -209,30 +212,6 @@ func filesystemAttachmentFromParams(in params.KubernetesFilesystemAttachmentPara
}, nil
}

// ApplicationCharmURL finds the CharmURL for an application.
func (c *Client) ApplicationCharmURL(appName string) (*charm.URL, error) {
args := params.Entities{Entities: []params.Entity{{
Tag: names.NewApplicationTag(appName).String(),
}}}
var result params.StringResults
if err := c.facade.FacadeCall("ApplicationCharmURLs", args, &result); err != nil {
return nil, errors.Trace(err)
}
if len(result.Results) != 1 {
return nil, errors.Errorf("expected 1 result, got %d",
len(result.Results))
}
res := result.Results[0]
if res.Error != nil {
return nil, errors.Annotatef(maybeNotFound(res.Error), "unable to fetch charm url for %s", appName)
}
url, err := charm.ParseURL(res.Result)
if err != nil {
return nil, errors.Annotatef(err, "invalid charm url %q", res.Result)
}
return url, nil
}

// SetOperatorStatus updates the provisioning status of an operator.
func (c *Client) SetOperatorStatus(appName string, status status.Status, message string, data map[string]interface{}) error {
var result params.ErrorResults
Expand Down
20 changes: 0 additions & 20 deletions api/caasapplicationprovisioner/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,26 +301,6 @@ func (s *provisionerSuite) TestGarbageCollect(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)
}

func (s *provisionerSuite) TestApplicationCharmURL(c *gc.C) {
client := newClient(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, "CAASApplicationProvisioner")
c.Check(id, gc.Equals, "")
c.Check(request, gc.Equals, "ApplicationCharmURLs")
c.Assert(arg, jc.DeepEquals, params.Entities{Entities: []params.Entity{{"application-gitlab"}}})
c.Assert(result, gc.FitsTypeOf, &params.StringResults{})
*(result.(*params.StringResults)) = params.StringResults{
Results: []params.StringResult{{
Result: "cs:charm",
}},
}
return nil
})

charmURL, err := client.ApplicationCharmURL("gitlab")
c.Assert(err, jc.ErrorIsNil)
c.Assert(charmURL, jc.DeepEquals, &charm.URL{Schema: "cs", Name: "charm", Revision: -1})
}

func (s *provisionerSuite) TestUpdateUnits(c *gc.C) {
var called bool
client := newClient(func(objType string, version int, id, request string, a, result interface{}) error {
Expand Down
41 changes: 12 additions & 29 deletions api/caasfirewaller/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package caasfirewaller

import (
"github.com/juju/charm/v8"
"github.com/juju/errors"
"github.com/juju/names/v4"

Expand All @@ -21,33 +20,40 @@ import (
// Client allows access to the CAAS firewaller API endpoint.
type Client struct {
facade base.FacadeCaller
*charmscommon.CharmInfoClient
*charmscommon.ApplicationCharmInfoClient
}

// NewClientLegacy returns a client used to access the CAAS unit provisioner API.
func NewClientLegacy(caller base.APICaller) *Client {
facadeCaller := base.NewFacadeCaller(caller, "CAASFirewaller")
charmInfoClient := charmscommon.NewCharmInfoClient(facadeCaller)
appCharmInfoClient := charmscommon.NewApplicationCharmInfoClient(facadeCaller)
return &Client{
facade: facadeCaller,
facade: facadeCaller,
CharmInfoClient: charmInfoClient,
ApplicationCharmInfoClient: appCharmInfoClient,
}
}

// ClientSidecar allows access to the CAAS firewaller API endpoint for sidecar applications.
type ClientSidecar struct {
*Client
*charmscommon.CharmsClient
}

// NewClientSidecar returns a client used to access the CAAS unit provisioner API.
func NewClientSidecar(caller base.APICaller) *ClientSidecar {
// TODO(sidecar): add OpenedPorts and ClosedPorts API for caasfirewallersidecar worker to fetch port mapping changes.
// TODO(juju3): rename to CAASFirewallerSidecar
facadeCaller := base.NewFacadeCaller(caller, "CAASFirewallerEmbedded")
charmsClient := charmscommon.NewCharmsClient(facadeCaller)
charmInfoClient := charmscommon.NewCharmInfoClient(facadeCaller)
appCharmInfoClient := charmscommon.NewApplicationCharmInfoClient(facadeCaller)
return &ClientSidecar{
Client: &Client{
facade: facadeCaller,
facade: facadeCaller,
CharmInfoClient: charmInfoClient,
ApplicationCharmInfoClient: appCharmInfoClient,
},
CharmsClient: charmsClient,
}
}

Expand Down Expand Up @@ -81,29 +87,6 @@ func (c *ClientSidecar) WatchOpenedPorts() (watcher.StringsWatcher, error) {
return w, nil
}

// ApplicationCharmInfo finds the CharmInfo for an application.
func (c *ClientSidecar) ApplicationCharmInfo(appName string) (*charmscommon.CharmInfo, error) {
args := params.Entities{Entities: []params.Entity{{
Tag: names.NewApplicationTag(appName).String(),
}}}
var result params.StringResults
if err := c.facade.FacadeCall("ApplicationCharmURLs", args, &result); err != nil {
return nil, errors.Trace(err)
}
if len(result.Results) != 1 {
return nil, errors.Errorf("expected 1 result, got %d", len(result.Results))
}
res := result.Results[0]
if res.Error != nil {
return nil, errors.Annotatef(res.Error, "unable to fetch charm url for %s", appName)
}
url, err := charm.ParseURL(res.Result)
if err != nil {
return nil, errors.Annotatef(err, "invalid charm url %q", res.Result)
}
return c.CharmsClient.CharmInfo(url.String())
}

func applicationTag(application string) (names.ApplicationTag, error) {
if !names.IsValidApplication(application) {
return names.ApplicationTag{}, errors.NotValidf("application name %q", application)
Expand Down
43 changes: 0 additions & 43 deletions api/caasfirewaller/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package caasfirewaller_test

import (
"github.com/juju/charm/v8"
"github.com/juju/errors"
"github.com/juju/names/v4"
"github.com/juju/testing"
Expand All @@ -14,7 +13,6 @@ import (
"github.com/juju/juju/api/base"
basetesting "github.com/juju/juju/api/base/testing"
"github.com/juju/juju/api/caasfirewaller"
apicommoncharms "github.com/juju/juju/api/common/charms"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/application"
"github.com/juju/juju/core/life"
Expand Down Expand Up @@ -88,47 +86,6 @@ func (s *firewallerSidecarSuite) TestWatchOpenedPorts(c *gc.C) {
c.Assert(err, gc.ErrorMatches, "FAIL")
}

func (s *firewallerSidecarSuite) TestApplicationCharmInfo(c *gc.C) {
apiCaller := basetesting.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, s.objType)
c.Check(version, gc.Equals, 0)
c.Check(id, gc.Equals, "")
switch request {
case "ApplicationCharmURLs":
c.Check(arg, jc.DeepEquals, params.Entities{
Entities: []params.Entity{{
Tag: "application-gitlab",
}},
})
c.Assert(result, gc.FitsTypeOf, &params.StringResults{})
*(result.(*params.StringResults)) = params.StringResults{
Results: []params.StringResult{{
Result: `cs:gitlab-0`,
}},
}
case "CharmInfo":
c.Check(arg, jc.DeepEquals, params.CharmURL{URL: `cs:gitlab-0`})
c.Assert(result, gc.FitsTypeOf, &params.Charm{})
*(result.(*params.Charm)) = params.Charm{
Revision: 1,
URL: `cs:gitlab-0`,
}
default:
return errors.New("should never happen")
}
return nil
})

client := caasfirewaller.NewClientSidecar(apiCaller)
result, err := client.ApplicationCharmInfo("gitlab")
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, jc.DeepEquals, &apicommoncharms.CharmInfo{
Revision: 1,
URL: `cs:gitlab-0`,
Manifest: &charm.Manifest{},
})
}

func (s *firewallerBaseSuite) TestIsExposed(c *gc.C) {
apiCaller := basetesting.APICallerFunc(func(objType string, version int, id, request string, arg, result interface{}) error {
c.Check(objType, gc.Equals, s.objType)
Expand Down
9 changes: 8 additions & 1 deletion api/caasoperatorprovisioner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/juju/version/v2"

"github.com/juju/juju/api/base"
charmscommon "github.com/juju/juju/api/common/charms"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/core/life"
Expand All @@ -20,13 +21,19 @@ import (
// Client allows access to the CAAS operator provisioner API endpoint.
type Client struct {
facade base.FacadeCaller
*charmscommon.CharmInfoClient
*charmscommon.ApplicationCharmInfoClient
}

// NewClient returns a client used to access the CAAS Operator Provisioner API.
func NewClient(caller base.APICaller) *Client {
facadeCaller := base.NewFacadeCaller(caller, "CAASOperatorProvisioner")
charmInfoClient := charmscommon.NewCharmInfoClient(facadeCaller)
appCharmInfoClient := charmscommon.NewApplicationCharmInfoClient(facadeCaller)
return &Client{
facade: facadeCaller,
facade: facadeCaller,
CharmInfoClient: charmInfoClient,
ApplicationCharmInfoClient: appCharmInfoClient,
}
}

Expand Down
20 changes: 19 additions & 1 deletion api/caasunitprovisioner/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/juju/names/v4"

"github.com/juju/juju/api/base"
"github.com/juju/juju/api/common"
charmscommon "github.com/juju/juju/api/common/charms"
apiwatcher "github.com/juju/juju/api/watcher"
"github.com/juju/juju/apiserver/params"
"github.com/juju/juju/caas"
Expand All @@ -23,13 +25,19 @@ import (
// Client allows access to the CAAS unit provisioner API endpoint.
type Client struct {
facade base.FacadeCaller
*charmscommon.CharmInfoClient
*charmscommon.ApplicationCharmInfoClient
}

// NewClient returns a client used to access the CAAS unit provisioner API.
func NewClient(caller base.APICaller) *Client {
facadeCaller := base.NewFacadeCaller(caller, "CAASUnitProvisioner")
charmInfoClient := charmscommon.NewCharmInfoClient(facadeCaller)
appCharmInfoClient := charmscommon.NewApplicationCharmInfoClient(facadeCaller)
return &Client{
facade: facadeCaller,
facade: facadeCaller,
CharmInfoClient: charmInfoClient,
ApplicationCharmInfoClient: appCharmInfoClient,
}
}

Expand Down Expand Up @@ -64,6 +72,16 @@ func (c *Client) WatchApplications() (watcher.StringsWatcher, error) {
return w, nil
}

// WatchApplication returns a NotifyWatcher that notifies of
// changes to the application in the current model.
func (c *Client) WatchApplication(appName string) (watcher.NotifyWatcher, error) {
appTag, err := applicationTag(appName)
if err != nil {
return nil, errors.Trace(err)
}
return common.Watch(c.facade, "Watch", appTag)
}

// ApplicationConfig returns the config for the specified application.
func (c *Client) ApplicationConfig(applicationName string) (application.ConfigAttributes, error) {
var results params.ApplicationGetConfigResults
Expand Down
6 changes: 3 additions & 3 deletions api/charms/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ import (
// Client allows access to the charms API end point.
type Client struct {
base.ClientFacade
*commoncharms.CharmsClient
*commoncharms.CharmInfoClient
facade base.FacadeCaller
}

// NewClient creates a new client for accessing the charms API.
func NewClient(st base.APICallCloser) *Client {
frontend, backend := base.NewClientFacade(st, "Charms")
commonClient := commoncharms.NewCharmsClient(backend)
return &Client{ClientFacade: frontend, CharmsClient: commonClient, facade: backend}
commonClient := commoncharms.NewCharmInfoClient(backend)
return &Client{ClientFacade: frontend, CharmInfoClient: commonClient, facade: backend}
}

// IsMetered returns whether or not the charm is metered.
Expand Down
4 changes: 2 additions & 2 deletions api/charms/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ import (
)

func NewClientWithFacade(facade base.FacadeCaller) *Client {
commonClient := commoncharms.NewCharmsClient(facade)
return &Client{facade: facade, CharmsClient: commonClient}
charmInfoClient := commoncharms.NewCharmInfoClient(facade)
return &Client{facade: facade, CharmInfoClient: charmInfoClient}
}
Loading

0 comments on commit e1e9279

Please sign in to comment.