From 26643fc14181500f0d4527c5aa6909a4d546b148 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 28 Aug 2017 22:21:54 -0700 Subject: [PATCH 1/2] Fix logs/fs commands This PR fixes an assignment to a nil map in the api pkg related to accessing logs and the filesystem of allocations. Fixes https://github.com/hashicorp/nomad/issues/3115 --- api/fs.go | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/api/fs.go b/api/fs.go index e2fbf8181b02..45840fb0e49a 100644 --- a/api/fs.go +++ b/api/fs.go @@ -55,6 +55,14 @@ func (a *AllocFS) List(alloc *Allocation, path string, q *QueryOptions) ([]*Allo if err != nil { return nil, nil, err } + + if q == nil { + q = &QueryOptions{} + } + if q.Params == nil { + q.Params = make(map[string]string) + } + q.Params["path"] = path var resp []*AllocFileInfo @@ -72,6 +80,14 @@ func (a *AllocFS) Stat(alloc *Allocation, path string, q *QueryOptions) (*AllocF if err != nil { return nil, nil, err } + + if q == nil { + q = &QueryOptions{} + } + if q.Params == nil { + q.Params = make(map[string]string) + } + q.Params["path"] = path var resp AllocFileInfo @@ -89,6 +105,14 @@ func (a *AllocFS) ReadAt(alloc *Allocation, path string, offset int64, limit int if err != nil { return nil, err } + + if q == nil { + q = &QueryOptions{} + } + if q.Params == nil { + q.Params = make(map[string]string) + } + q.Params["path"] = path q.Params["offset"] = strconv.FormatInt(offset, 10) q.Params["limit"] = strconv.FormatInt(limit, 10) @@ -107,6 +131,14 @@ func (a *AllocFS) Cat(alloc *Allocation, path string, q *QueryOptions) (io.ReadC if err != nil { return nil, err } + + if q == nil { + q = &QueryOptions{} + } + if q.Params == nil { + q.Params = make(map[string]string) + } + q.Params["path"] = path r, err := nodeClient.rawQuery(fmt.Sprintf("/v1/client/fs/cat/%s", alloc.ID), q) @@ -131,6 +163,14 @@ func (a *AllocFS) Stream(alloc *Allocation, path, origin string, offset int64, if err != nil { return nil, err } + + if q == nil { + q = &QueryOptions{} + } + if q.Params == nil { + q.Params = make(map[string]string) + } + q.Params["path"] = path q.Params["offset"] = strconv.FormatInt(offset, 10) q.Params["origin"] = origin @@ -195,9 +235,14 @@ func (a *AllocFS) Logs(alloc *Allocation, follow bool, task, logType, origin str if err != nil { return nil, err } + if q == nil { q = &QueryOptions{} } + if q.Params == nil { + q.Params = make(map[string]string) + } + q.Params["follow"] = strconv.FormatBool(follow) q.Params["task"] = task q.Params["type"] = logType From 7da50ff28d41d9fa4d8d7f2018bb86bea8c32305 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 28 Aug 2017 22:24:53 -0700 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb5598c393d..f17342196f9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.6.2 (August 28, 2017) + +BUG FIXES: + * api/cli: Fix logs and fs api and command [GH-3116] + ## 0.6.1 (August 28, 2017) __BACKWARDS INCOMPATIBILITIES:__