Skip to content

Commit

Permalink
Remove inbuild dashboard since we are moving to use a separate charm
Browse files Browse the repository at this point in the history
  • Loading branch information
wallyworld committed Sep 29, 2021
1 parent 3d7d6b0 commit 0897b55
Show file tree
Hide file tree
Showing 62 changed files with 70 additions and 4,800 deletions.
2 changes: 1 addition & 1 deletion acceptancetests/assess_endpoint_bindings.py
Expand Up @@ -296,7 +296,7 @@ def machine_spaces_for_bundle(bundle):

def bootstrap_and_test(bootstrap_manager, bundle_path, machine):
shutil.copy(bundle_path, bootstrap_manager.log_dir)
with bootstrap_manager.booted_context(False, no_gui=True):
with bootstrap_manager.booted_context(False):
client = bootstrap_manager.client
log.info("Deploying bundle.")
client.deploy(bundle_path)
Expand Down
11 changes: 3 additions & 8 deletions acceptancetests/jujupy/client.py
Expand Up @@ -865,7 +865,7 @@ def get_cloud_region(cloud, region):
def get_bootstrap_args(
self, upload_tools, config_filename, bootstrap_series=None,
arch=None, credential=None, auto_upgrade=False,
metadata_source=None, no_gui=False, agent_version=None,
metadata_source=None, agent_version=None,
db_snap_path=None, db_snap_asserts_path=None, force=False,
config_options=None):
"""Return the bootstrap arguments for the substrate."""
Expand Down Expand Up @@ -906,8 +906,6 @@ def get_bootstrap_args(
args.append('--auto-upgrade')
if self.env.bootstrap_to is not None:
args.extend(['--to', self.env.bootstrap_to])
if no_gui:
args.append('--no-dashboard')
if db_snap_path and db_snap_asserts_path:
args.extend(['--db-snap', db_snap_path,
'--db-snap-asserts', db_snap_asserts_path])
Expand Down Expand Up @@ -1010,7 +1008,7 @@ def update_user_name(self):

def bootstrap(self, upload_tools=False, bootstrap_series=None, arch=None,
credential=None, auto_upgrade=False, metadata_source=None,
no_gui=False, agent_version=None, db_snap_path=None,
agent_version=None, db_snap_path=None,
db_snap_asserts_path=None, mongo_memory_profile=None,
caas_image_repo=None, force=False, db_snap_channel=None,
config_options=None):
Expand All @@ -1027,7 +1025,6 @@ def bootstrap(self, upload_tools=False, bootstrap_series=None, arch=None,
credential=credential,
auto_upgrade=auto_upgrade,
metadata_source=metadata_source,
no_gui=no_gui,
agent_version=agent_version,
db_snap_path=db_snap_path,
db_snap_asserts_path=db_snap_asserts_path,
Expand All @@ -1041,8 +1038,7 @@ def bootstrap(self, upload_tools=False, bootstrap_series=None, arch=None,

@contextmanager
def bootstrap_async(self, upload_tools=False, bootstrap_series=None,
auto_upgrade=False, metadata_source=None,
no_gui=False):
auto_upgrade=False, metadata_source=None):
self._check_bootstrap()
with self._bootstrap_config() as config_filename:
args = self.get_bootstrap_args(
Expand All @@ -1052,7 +1048,6 @@ def bootstrap_async(self, upload_tools=False, bootstrap_series=None,
credential=None,
auto_upgrade=auto_upgrade,
metadata_source=metadata_source,
no_gui=no_gui,
)
self.update_user_name()
with self.juju_async('bootstrap', args, include_e=False):
Expand Down
13 changes: 0 additions & 13 deletions acceptancetests/jujupy/tests/test_client.py
Expand Up @@ -448,19 +448,6 @@ def test_bootstrap_auto_upgrade(self):
'--config', config_file.name, '--default-model', 'foo',
'--agent-version', '2.0', '--auto-upgrade'), include_e=False)

def test_bootstrap_no_gui(self):
env = JujuData('foo', {'type': 'bar', 'region': 'baz'})
client = ModelClient(env, '2.0-zeta1', None)
with patch_juju_call(client) as mock:
with observable_temp_file() as config_file:
client.bootstrap(no_gui=True)
mock.assert_called_with(
'bootstrap', (
'--constraints', 'mem=2G',
'bar/baz', 'foo',
'--config', config_file.name, '--default-model', 'foo',
'--agent-version', '2.0', '--no-dashboard'), include_e=False)

def test_bootstrap_metadata(self):
env = JujuData('foo', {'type': 'bar', 'region': 'baz'})
client = ModelClient(env, '2.0-zeta1', None)
Expand Down
3 changes: 1 addition & 2 deletions agent/tools/export_test.go
Expand Up @@ -23,6 +23,5 @@ var (
)

const (
ToolsFile = toolsFile
DashboardArchiveFile = dashboardArchiveFile
ToolsFile = toolsFile
)
47 changes: 0 additions & 47 deletions agent/tools/tools_test.go
Expand Up @@ -11,7 +11,6 @@ import (
"path/filepath"
"sort"

"github.com/juju/errors"
jc "github.com/juju/testing/checkers"
"github.com/juju/version/v2"
gc "gopkg.in/check.v1"
Expand Down Expand Up @@ -171,47 +170,6 @@ func (t *ToolsSuite) TestReadToolsErrors(c *gc.C) {
c.Assert(err, gc.ErrorMatches, "invalid agent metadata in directory .*")
}

func (t *ToolsSuite) TestReadDashboardArchiveErrorNotFound(c *gc.C) {
dashboard, err := agenttools.ReadDashboardArchive(t.dataDir)
c.Assert(err, gc.ErrorMatches, "Dashboard metadata not found")
c.Assert(err, jc.Satisfies, errors.IsNotFound)
c.Assert(dashboard, gc.IsNil)
}

func (t *ToolsSuite) TestReadDashboardArchiveErrorNotValid(c *gc.C) {
dir := agenttools.SharedDashboardDir(t.dataDir)
err := os.MkdirAll(dir, agenttools.DirPerm)
c.Assert(err, jc.ErrorIsNil)

err = ioutil.WriteFile(filepath.Join(dir, agenttools.DashboardArchiveFile), []byte(" \t\n"), 0644)
c.Assert(err, jc.ErrorIsNil)

dashboard, err := agenttools.ReadDashboardArchive(t.dataDir)
c.Assert(err, gc.ErrorMatches, "invalid Dashboard metadata in directory .*")
c.Assert(dashboard, gc.IsNil)
}

func (t *ToolsSuite) TestReadDashboardArchiveSuccess(c *gc.C) {
dir := agenttools.SharedDashboardDir(t.dataDir)
err := os.MkdirAll(dir, agenttools.DirPerm)
c.Assert(err, jc.ErrorIsNil)

expectDashboard := coretest.DashboardArchive{
Version: version.MustParse("2.0.42"),
URL: "file:///path/to/dashboard",
SHA256: "hash",
Size: 47,
}
b, err := json.Marshal(expectDashboard)
c.Assert(err, jc.ErrorIsNil)
err = ioutil.WriteFile(filepath.Join(dir, agenttools.DashboardArchiveFile), b, 0644)
c.Assert(err, jc.ErrorIsNil)

dshboard, err := agenttools.ReadDashboardArchive(t.dataDir)
c.Assert(err, jc.ErrorIsNil)
c.Assert(*dshboard, gc.Equals, expectDashboard)
}

func (t *ToolsSuite) TestChangeAgentTools(c *gc.C) {
files := []*testing.TarFile{
testing.NewTarFile("jujuc", agenttools.DirPerm, "juju executable"),
Expand Down Expand Up @@ -262,11 +220,6 @@ func (t *ToolsSuite) TestSharedToolsDir(c *gc.C) {
c.Assert(dir, gc.Equals, "/var/lib/juju/tools/1.2.3-ubuntu-amd64")
}

func (t *ToolsSuite) TestSharedDashboardDir(c *gc.C) {
dir := agenttools.SharedDashboardDir("/var/lib/juju")
c.Assert(dir, gc.Equals, "/var/lib/juju/dashboard")
}

// assertToolsContents asserts that the directory for the tools
// has the given contents.
func (t *ToolsSuite) assertToolsContents(c *gc.C, testTools *coretest.Tools, files []*testing.TarFile) {
Expand Down
31 changes: 3 additions & 28 deletions agent/tools/toolsdir.go
Expand Up @@ -23,10 +23,9 @@ import (
)

const (
dirPerm = 0755
filePerm = 0644
dashboardArchiveFile = "downloaded-dashboard.txt"
toolsFile = "downloaded-tools.txt"
dirPerm = 0755
filePerm = 0644
toolsFile = "downloaded-tools.txt"
)

// SharedToolsDir returns the directory that is used to
Expand All @@ -36,12 +35,6 @@ func SharedToolsDir(dataDir string, vers version.Binary) string {
return path.Join(dataDir, "tools", vers.String())
}

// SharedDashboardDir returns the directory that is used to store release archives
// of the Juju Dashboard within the dataDir directory.
func SharedDashboardDir(dataDir string) string {
return path.Join(dataDir, "dashboard")
}

// ToolsDir returns the directory that is used/ to store binaries for
// the tools used by the given agent within the given dataDir directory.
// Conventionally it is a symbolic link to the actual tools directory.
Expand Down Expand Up @@ -174,24 +167,6 @@ func ReadTools(dataDir string, vers version.Binary) (*coretools.Tools, error) {
return &tools, nil
}

// ReadDashboardArchive reads the Dashboard information from the dataDir directory.
// The Dashboard information is JSON encoded in a text file, "downloaded-dashboard.txt".
func ReadDashboardArchive(dataDir string) (*coretools.DashboardArchive, error) {
dir := SharedDashboardDir(dataDir)
toolsData, err := ioutil.ReadFile(path.Join(dir, dashboardArchiveFile))
if err != nil {
if os.IsNotExist(err) {
return nil, errors.NotFoundf("Dashboard metadata")
}
return nil, fmt.Errorf("cannot read Dashboard metadata in directory %q: %v", dir, err)
}
var dashboard coretools.DashboardArchive
if err := json.Unmarshal(toolsData, &dashboard); err != nil {
return nil, fmt.Errorf("invalid Dashboard metadata in directory %q: %v", dir, err)
}
return &dashboard, nil
}

// ChangeAgentTools atomically replaces the agent-specific symlink
// under dataDir so it points to the previously unpacked
// version vers. It returns the new tools read.
Expand Down
12 changes: 4 additions & 8 deletions api/apiclient.go
Expand Up @@ -16,6 +16,7 @@ import (
"net"
"net/http"
"net/url"
"strconv"
"strings"
"sync/atomic"
"time"
Expand Down Expand Up @@ -544,14 +545,9 @@ func (st *state) apiEndpoint(path, query string) (*url.URL, error) {
}

// ControllerAPIURL returns the URL to use to connect to the controller API.
func ControllerAPIURL(addr string) string {
urlStr, _ := url.QueryUnescape(apiURL(addr, "").String())
return urlStr
}

// ModelAPITemplateURL returns a URL template to use to connect to a model API.
func ModelAPITemplateURL(addr string) string {
urlStr, _ := url.QueryUnescape(apiURL(addr, "${modelUUID}").String())
func ControllerAPIURL(addr string, port int) string {
hp := net.JoinHostPort(addr, strconv.Itoa(port))
urlStr, _ := url.QueryUnescape(apiURL(hp, "").String())
return urlStr
}

Expand Down
103 changes: 0 additions & 103 deletions api/controller/dashboard.go

This file was deleted.

0 comments on commit 0897b55

Please sign in to comment.