Skip to content

Commit

Permalink
renaming tool(s) to agent binary(ies)
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiamac committed Nov 2, 2017
1 parent 7d6f9b4 commit 191fe8e
Show file tree
Hide file tree
Showing 50 changed files with 159 additions and 159 deletions.
4 changes: 2 additions & 2 deletions agent/tools/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (t *ToolsSuite) TestReadToolsErrors(c *gc.C) {
vers := version.MustParseBinary("1.2.3-precise-amd64")
testTools, err := agenttools.ReadTools(t.dataDir, vers)
c.Assert(testTools, gc.IsNil)
c.Assert(err, gc.ErrorMatches, "cannot read tools metadata in tools directory: .*")
c.Assert(err, gc.ErrorMatches, "cannot read agent binaries metadata in the expected directory: .*")

dir := agenttools.SharedToolsDir(t.dataDir, vers)
err = os.MkdirAll(dir, agenttools.DirPerm)
Expand All @@ -163,7 +163,7 @@ func (t *ToolsSuite) TestReadToolsErrors(c *gc.C) {

testTools, err = agenttools.ReadTools(t.dataDir, vers)
c.Assert(testTools, gc.IsNil)
c.Assert(err, gc.ErrorMatches, "invalid tools metadata in tools directory .*")
c.Assert(err, gc.ErrorMatches, "invalid agent binaries metadata in the expected directory .*")
}

func (t *ToolsSuite) TestReadGUIArchiveErrorNotFound(c *gc.C) {
Expand Down
8 changes: 4 additions & 4 deletions agent/tools/toolsdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ func UnpackTools(dataDir string, tools *coretools.Tools, r io.Reader) (err error
return err
}
if strings.ContainsAny(hdr.Name, "/\\") {
return fmt.Errorf("bad name %q in tools archive", hdr.Name)
return fmt.Errorf("bad name %q in agent binary archive", hdr.Name)
}
if hdr.Typeflag != tar.TypeReg {
return fmt.Errorf("bad file type %c in file %q in tools archive", hdr.Typeflag, hdr.Name)
return fmt.Errorf("bad file type %c in file %q in agent binary archive", hdr.Typeflag, hdr.Name)
}
name := path.Join(dir, hdr.Name)
if err := writeFile(name, os.FileMode(hdr.Mode&0777), tr); err != nil {
Expand Down Expand Up @@ -169,11 +169,11 @@ func ReadTools(dataDir string, vers version.Binary) (*coretools.Tools, error) {
dir := SharedToolsDir(dataDir, vers)
toolsData, err := ioutil.ReadFile(path.Join(dir, toolsFile))
if err != nil {
return nil, fmt.Errorf("cannot read tools metadata in tools directory: %v", err)
return nil, fmt.Errorf("cannot read agent binaries metadata in the expected directory: %v", err)
}
var tools coretools.Tools
if err := json.Unmarshal(toolsData, &tools); err != nil {
return nil, fmt.Errorf("invalid tools metadata in tools directory %q: %v", dir, err)
return nil, fmt.Errorf("invalid agent binaries metadata in the expected directory %q: %v", dir, err)
}
return &tools, nil
}
Expand Down
2 changes: 1 addition & 1 deletion api/migrationmaster/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (c *Client) Export() (migration.SerializedModel, error) {
for _, toolsInfo := range serialized.Tools {
v, err := version.ParseBinary(toolsInfo.Version)
if err != nil {
return migration.SerializedModel{}, errors.Annotate(err, "error parsing tools version")
return migration.SerializedModel{}, errors.Annotate(err, "error parsing agent binaries version")
}
tools[v] = toolsInfo.URI
}
Expand Down
6 changes: 3 additions & 3 deletions apiserver/common/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (t *ToolsGetter) oneAgentTools(canRead AuthFunc, tag names.Tag, agentVersio
}
tooler, ok := entity.(state.AgentTooler)
if !ok {
return nil, NotSupportedError(tag, "agent tools")
return nil, NotSupportedError(tag, "agent binaries")
}
existingTools, err := tooler.AgentTools()
if err != nil {
Expand Down Expand Up @@ -185,7 +185,7 @@ func (t *ToolsSetter) setOneAgentVersion(tag names.Tag, vers version.Binary, can
}
entity, ok := entity0.(state.AgentTooler)
if !ok {
return NotSupportedError(tag, "agent tools")
return NotSupportedError(tag, "agent binaries")
}
return entity.SetAgentVersion(vers)
}
Expand Down Expand Up @@ -297,7 +297,7 @@ func (f *ToolsFinder) matchingStorageTools(args params.FindToolsParams) (coretoo
for i, m := range allMetadata {
vers, err := version.ParseBinary(m.Version)
if err != nil {
return nil, errors.Annotatef(err, "unexpectedly bad version %q in tools storage", m.Version)
return nil, errors.Annotatef(err, "unexpectedly bad version %q in agent binaries storage", m.Version)
}
list[i] = &coretools.Tools{
Version: vers,
Expand Down
4 changes: 2 additions & 2 deletions apiserver/facades/client/client/instanceconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func InstanceConfig(st *state.State, machineId, nonce, dataDir string) (*instanc
Arch: *hc.Arch,
})
if err != nil {
return nil, errors.Annotate(err, "finding tools")
return nil, errors.Annotate(err, "finding agent binaries")
}
if findToolsResult.Error != nil {
return nil, errors.Annotate(findToolsResult.Error, "finding tools")
return nil, errors.Annotate(findToolsResult.Error, "finding agent binaries")
}
toolsList := findToolsResult.List

Expand Down
2 changes: 1 addition & 1 deletion apiserver/facades/client/client/instanceconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ func (s *machineConfigSuite) TestMachineConfigNoTools(c *gc.C) {
machines, err := s.APIState.Client().AddMachines([]params.AddMachineParams{apiParams})
c.Assert(err, jc.ErrorIsNil)
_, err = client.InstanceConfig(s.State, machines[0].Machine, apiParams.Nonce, "")
c.Assert(err, gc.ErrorMatches, "finding tools: "+coretools.ErrNoMatches.Error())
c.Assert(err, gc.ErrorMatches, "finding agent binaries: "+coretools.ErrNoMatches.Error())
}
2 changes: 1 addition & 1 deletion apiserver/facades/client/modelmanager/modelmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ func (s *modelManagerStateSuite) TestCreateModelBadAgentVersion(c *gc.C) {
errMatch: "failed to create config: agent-version .* cannot be greater than the controller .*",
}, {
value: smaller.String(),
errMatch: "failed to create config: no tools found for version .*",
errMatch: "failed to create config: no agent binaries found for version .*",
},
} {
c.Logf("test %d", i)
Expand Down
4 changes: 2 additions & 2 deletions apiserver/facades/controller/agenttools/agenttools.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func checkToolsAvailability(newEnviron newEnvironFunc, modelCfg *config.Config,
vers, err = finder(env, currentVersion.Major, currentVersion.Minor, preferredStream, coretools.Filter{})
}
if err != nil {
return version.Zero, errors.Annotatef(err, "cannot find available tools")
return version.Zero, errors.Annotatef(err, "cannot find available agent binaries")
}
// Newest also returns a list of the items in this list matching with the
// newest version.
Expand Down Expand Up @@ -125,7 +125,7 @@ func updateToolsAvailability(modelGetter ModelGetter, newEnviron newEnvironFunc,
return errors.Annotate(err, "cannot get latest version")
}
if ver == version.Zero {
logger.Debugf("tools lookup returned version Zero, this should only happen during bootstrap.")
logger.Debugf("agent binaries lookup returned version Zero, this should only happen during bootstrap.")
return nil
}
return update(model, ver)
Expand Down
22 changes: 11 additions & 11 deletions apiserver/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,18 @@ func (h *toolsDownloadHandler) processGet(r *http.Request, st *state.State) ([]b
}
storage, err := st.ToolsStorage()
if err != nil {
return nil, errors.Annotate(err, "error getting tools storage")
return nil, errors.Annotate(err, "error getting agent binaries storage")
}
defer storage.Close()
_, reader, err := storage.Open(version.String())
if errors.IsNotFound(err) {
// Tools could not be found in tools storage,
// so look for them in simplestreams, fetch
// them and cache in tools storage.
logger.Infof("%v tools not found locally, fetching", version)
logger.Infof("%v agent binaries not found locally, fetching", version)
reader, err = h.fetchAndCacheTools(version, storage, st)
if err != nil {
err = errors.Annotate(err, "error fetching tools")
err = errors.Annotate(err, "error fetching agent binaries")
}
}
if err != nil {
Expand All @@ -130,7 +130,7 @@ func (h *toolsDownloadHandler) processGet(r *http.Request, st *state.State) ([]b
defer reader.Close()
data, err := ioutil.ReadAll(reader)
if err != nil {
return nil, errors.Annotate(err, "failed to read tools tarball")
return nil, errors.Annotate(err, "failed to read agent binaries tarball")
}
return data, nil
}
Expand All @@ -150,7 +150,7 @@ func (h *toolsDownloadHandler) fetchAndCacheTools(v version.Binary, stor binarys
}

// No need to verify the server's identity because we verify the SHA-256 hash.
logger.Infof("fetching %v tools from %v", v, tools.URL)
logger.Infof("fetching %v agent binaries from %v", v, tools.URL)
resp, err := utils.GetNonValidatingHTTPClient().Get(tools.URL)
if err != nil {
return nil, err
Expand Down Expand Up @@ -181,7 +181,7 @@ func (h *toolsDownloadHandler) fetchAndCacheTools(v version.Binary, stor binarys
SHA256: tools.SHA256,
}
if err := stor.Add(bytes.NewReader(data), metadata); err != nil {
return nil, errors.Annotate(err, "error caching tools")
return nil, errors.Annotate(err, "error caching agent binaries")
}
return ioutil.NopCloser(bytes.NewReader(data)), nil
}
Expand All @@ -194,7 +194,7 @@ func (h *toolsDownloadHandler) sendTools(w http.ResponseWriter, statusCode int,
if _, err := w.Write(tarball); err != nil {
return errors.Trace(sendError(
w,
errors.NewBadRequest(errors.Annotatef(err, "failed to write tools"), ""),
errors.NewBadRequest(errors.Annotatef(err, "failed to write agent binaries"), ""),
))
}
return nil
Expand All @@ -210,7 +210,7 @@ func (h *toolsUploadHandler) processPost(r *http.Request, st *state.State) (*too
}
toolsVersion, err := version.ParseBinary(binaryVersionParam)
if err != nil {
return nil, errors.NewBadRequest(err, fmt.Sprintf("invalid tools version %q", binaryVersionParam))
return nil, errors.NewBadRequest(err, fmt.Sprintf("invalid agent binaries version %q", binaryVersionParam))
}

// Make sure the content type is x-tar-gz.
Expand All @@ -230,7 +230,7 @@ func (h *toolsUploadHandler) processPost(r *http.Request, st *state.State) (*too
if seriesParam := query.Get("series"); seriesParam != "" {
cloneSeries = strings.Split(seriesParam, ",")
}
logger.Debugf("request to upload tools: %s", toolsVersion)
logger.Debugf("request to upload agent binaries: %s", toolsVersion)
logger.Debugf("additional series: %s", cloneSeries)

toolsVersions := []version.Binary{toolsVersion}
Expand Down Expand Up @@ -275,7 +275,7 @@ func (h *toolsUploadHandler) handleUpload(r io.Reader, toolsVersions []version.B
return nil, err
}
if len(data) == 0 {
return nil, errors.BadRequestf("no tools uploaded")
return nil, errors.BadRequestf("no agent binaries uploaded")
}

// TODO(wallyworld): check integrity of tools tarball.
Expand All @@ -287,7 +287,7 @@ func (h *toolsUploadHandler) handleUpload(r io.Reader, toolsVersions []version.B
Size: int64(len(data)),
SHA256: sha256,
}
logger.Debugf("uploading tools %+v to storage", metadata)
logger.Debugf("uploading agent binaries %+v to storage", metadata)
if err := storage.Add(bytes.NewReader(data), metadata); err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions apiserver/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *toolsSuite) TestUploadFailsWithNoTools(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

resp := s.uploadRequest(c, s.toolsURI(c, "?binaryVersion=1.18.0-quantal-amd64"), "application/x-tar-gz", tempFile.Name())
s.assertErrorResponse(c, resp, http.StatusBadRequest, "no tools uploaded")
s.assertErrorResponse(c, resp, http.StatusBadRequest, "no agent binaries uploaded")
}

func (s *toolsSuite) TestUploadFailsWithInvalidContentType(c *gc.C) {
Expand Down Expand Up @@ -456,7 +456,7 @@ func (s *toolsSuite) TestDownloadFetchesAndVerifiesSize(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

resp := s.downloadRequest(c, tools.Version, "")
s.assertErrorResponse(c, resp, http.StatusBadRequest, "error fetching tools: size mismatch for .*")
s.assertErrorResponse(c, resp, http.StatusBadRequest, "error fetching agent binaries: size mismatch for .*")
s.assertToolsNotStored(c, tools.Version.String())
}

Expand All @@ -476,7 +476,7 @@ func (s *toolsSuite) TestDownloadFetchesAndVerifiesHash(c *gc.C) {
c.Assert(err, jc.ErrorIsNil)

resp := s.downloadRequest(c, tools.Version, "")
s.assertErrorResponse(c, resp, http.StatusBadRequest, "error fetching tools: hash mismatch for .*")
s.assertErrorResponse(c, resp, http.StatusBadRequest, "error fetching agent binaries: hash mismatch for .*")
s.assertToolsNotStored(c, tools.Version.String())
}

Expand Down
8 changes: 4 additions & 4 deletions cloudconfig/instancecfg/instancecfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,12 +520,12 @@ func (cfg *InstanceConfig) ToolsList() coretools.List {
// all usage-sites are updated to pass through non-empty URLs.
func (cfg *InstanceConfig) SetTools(toolsList coretools.List) error {
if len(toolsList) == 0 {
return errors.New("need at least 1 tools")
return errors.New("need at least 1 agent binary")
}
var tools *coretools.Tools
for _, listed := range toolsList {
if listed == nil {
return errors.New("nil entry in tools list")
return errors.New("nil entry in agent binaries list")
}
info := *listed
info.URL = ""
Expand All @@ -534,7 +534,7 @@ func (cfg *InstanceConfig) SetTools(toolsList coretools.List) error {
continue
}
if !reflect.DeepEqual(info, *tools) {
return errors.Errorf("tools info mismatch (%v, %v)", *tools, info)
return errors.Errorf("agent binaries info mismatch (%v, %v)", *tools, info)
}
}
cfg.tools = copyToolsList(toolsList)
Expand Down Expand Up @@ -579,7 +579,7 @@ func (cfg *InstanceConfig) VerifyConfig() (err error) {
}
if cfg.tools == nil {
// SetTools() has never been called successfully.
return errors.New("missing tools")
return errors.New("missing agent binaries")
}
// We don't need to check cfg.toolsURLs since SetTools() does.
if cfg.APIInfo == nil {
Expand Down
2 changes: 1 addition & 1 deletion cloudconfig/instancecfg/instancecfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (*instancecfgSuite) TestSetToolsDifferentVersions(c *gc.C) {
&coretools.Tools{Version: version.MustParseBinary("2.3.5-trusty-amd64")},
}
err := icfg.SetTools(list)
c.Assert(err, gc.ErrorMatches, `tools info mismatch.*2\.3\.4.*2\.3\.5.*`)
c.Assert(err, gc.ErrorMatches, `agent binaries info mismatch.*2\.3\.4.*2\.3\.5.*`)
c.Assert(icfg.ToolsList(), gc.HasLen, 0)
}

Expand Down
14 changes: 7 additions & 7 deletions cloudconfig/userdatacfg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ func (*cloudinitSuite) TestCloudInitVerify(c *gc.C) {
udata, err := cloudconfig.NewUserdataConfig(&cfg, ci)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Assert(err, gc.ErrorMatches, "invalid machine configuration: missing tools")
c.Assert(err, gc.ErrorMatches, "invalid machine configuration: missing agent binaries")

for i, test := range verifyTests {
c.Logf("test %d. %s", i, test.err)
Expand Down Expand Up @@ -1294,14 +1294,14 @@ func (*cloudinitSuite) TestToolsDownloadCommand(c *gc.C) {
n=1
while true; do
printf "Attempt $n to download tools from %s...\n" 'a'
download 'a' && echo "Tools downloaded successfully." && break
printf "Attempt $n to download agent binaries from %s...\n" 'a'
download 'a' && echo "Agent binaries downloaded successfully." && break
printf "Attempt $n to download tools from %s...\n" 'b'
download 'b' && echo "Tools downloaded successfully." && break
printf "Attempt $n to download agent binaries from %s...\n" 'b'
download 'b' && echo "Agent binaries downloaded successfully." && break
printf "Attempt $n to download tools from %s...\n" 'c'
download 'c' && echo "Tools downloaded successfully." && break
printf "Attempt $n to download agent binaries from %s...\n" 'c'
download 'c' && echo "Agent binaries downloaded successfully." && break
echo "Download failed, retrying in 15s"
sleep 15
Expand Down
8 changes: 4 additions & 4 deletions cloudconfig/userdatacfg_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var logger = loggo.GetLogger("juju.cloudconfig")

const (
// curlCommand is the base curl command used to download tools.
curlCommand = "curl -sSfw 'tools from %{url_effective} downloaded: HTTP %{http_code}; time %{time_total}s; size %{size_download} bytes; speed %{speed_download} bytes/s '"
curlCommand = "curl -sSfw 'agent binaries from %{url_effective} downloaded: HTTP %{http_code}; time %{time_total}s; size %{size_download} bytes; speed %{speed_download} bytes/s '"

// toolsDownloadWaitTime is the number of seconds to wait between
// each iterations of download attempts.
Expand All @@ -48,8 +48,8 @@ const (
n=1
while true; do
{{range .URLs}}
printf "Attempt $n to download tools from %s...\n" {{shquote .}}
{{$curl}} {{shquote .}} && echo "Tools downloaded successfully." && break
printf "Attempt $n to download agent binaries from %s...\n" {{shquote .}}
{{$curl}} {{shquote .}} && echo "Agent binaries downloaded successfully." && break
{{end}}
echo "Download failed, retrying in {{.ToolsDownloadWaitTime}}s"
sleep {{.ToolsDownloadWaitTime}}
Expand Down Expand Up @@ -498,7 +498,7 @@ func toolsDownloadCommand(curlCommand string, urls []string) string {
"URLs": urls,
})
if err != nil {
panic(errors.Annotate(err, "tools download template error"))
panic(errors.Annotate(err, "agent binaries download template error"))
}
return buf.String()
}
2 changes: 1 addition & 1 deletion cloudconfig/userdatacfg_win.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (w *windowsConfigure) ConfigureJuju() error {
tools := w.icfg.ToolsList()[0]
toolsJson, err := json.Marshal(tools)
if err != nil {
return errors.Annotate(err, "while serializing the tools")
return errors.Annotate(err, "while serializing the agent binaries")
}

renderer := w.conf.ShellRenderer()
Expand Down
6 changes: 3 additions & 3 deletions cmd/juju/commands/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ func (c *bootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
f.StringVar(&c.BootstrapImage, "bootstrap-image", "", "Specify the image of the bootstrap machine")
}
f.BoolVar(&c.BuildAgent, "build-agent", false, "Build local version of agent binary before bootstrapping")
f.StringVar(&c.MetadataSource, "metadata-source", "", "Local path to use as tools and/or metadata source")
f.StringVar(&c.MetadataSource, "metadata-source", "", "Local path to use as agent binaries and/or metadata source")
f.StringVar(&c.Placement, "to", "", "Placement directive indicating an instance to bootstrap")
f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "Do not destroy the model if bootstrap fails")
f.BoolVar(&c.AutoUpgrade, "auto-upgrade", false, "Upgrade to the latest patch release tools on first bootstrap")
f.StringVar(&c.AgentVersionParam, "agent-version", "", "Version of tools to use for Juju agents")
f.BoolVar(&c.AutoUpgrade, "auto-upgrade", false, "Upgrade to the latest patch release agent binaries on first bootstrap")
f.StringVar(&c.AgentVersionParam, "agent-version", "", "Version of agent binaries to use for Juju agents")
f.StringVar(&c.CredentialName, "credential", "", "Credentials to use when bootstrapping")
f.Var(&c.config, "config", "Specify a controller configuration file, or one or more configuration\n options\n (--config config.yaml [--config key=value ...])")
f.Var(&c.modelDefaults, "model-default", "Specify a configuration file, or one or more configuration\n options to be set for all models, unless otherwise specified\n (--config config.yaml [--config key=value ...])")
Expand Down
8 changes: 4 additions & 4 deletions cmd/juju/commands/synctools.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ type syncToolsCommand struct {
var _ cmd.Command = (*syncToolsCommand)(nil)

const synctoolsDoc = `
This copies the Juju agent software from the official tools store (located
at https://streams.canonical.com/juju) into a model. It is generally done
when the model is without Internet access.
This copies the Juju agent software from the official agent binaries store
(located at https://streams.canonical.com/juju) into a model.
It is generally done when the model is without Internet access.
Instead of the above site, a local directory can be specified as source.
The online store will, of course, need to be contacted at some point to get
Expand All @@ -73,7 +73,7 @@ See also:
func (c *syncToolsCommand) Info() *cmd.Info {
return &cmd.Info{
Name: "sync-tools",
Purpose: "Copy tools from the official tool store into a local model.",
Purpose: "Copy agent binaries from the official agent store into a local model.",
Doc: synctoolsDoc,
}
}
Expand Down
Loading

0 comments on commit 191fe8e

Please sign in to comment.