[ARVADOS] updated: 2.1.0-1513-g060cef87d
Git user
git at public.arvados.org
Mon Nov 1 20:25:49 UTC 2021
Summary of changes:
lib/controller/handler.go | 17 ++++++++++++++-
lib/controller/handler_test.go | 48 ++++++++++++++++++++++++++++++++++++++++++
lib/controller/localdb/conn.go | 8 ++++++-
3 files changed, 71 insertions(+), 2 deletions(-)
via 060cef87da0130005c52be0015593a54a1d34d2b (commit)
via 1662b93fa0943e14ce2aa0f8836bd16aefd640e5 (commit)
via 590a2f655f6a33aec7462b03101b4facfdcb9950 (commit)
from e01b0608e49fbb159c809db346079293e5dc27cb (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 060cef87da0130005c52be0015593a54a1d34d2b
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Mon Nov 1 17:24:44 2021 -0300
fixup
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/lib/controller/handler.go b/lib/controller/handler.go
index 8edf1b0fd..5c1672f56 100644
--- a/lib/controller/handler.go
+++ b/lib/controller/handler.go
@@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"net/http"
+ "net/http/httptest"
"net/url"
"strings"
"sync"
@@ -82,9 +83,10 @@ func (h *Handler) CheckHealth() error {
if err != nil {
return err
}
- _, err = h.localClusterRequest(req)
- if err != nil {
- return err
+ var resp *httptest.ResponseRecorder
+ h.handlerStack.ServeHTTP(resp, req)
+ if resp.Result().StatusCode != http.StatusOK {
+ return fmt.Errorf("%d %s", resp.Result().StatusCode, resp.Result().Status)
}
}
return nil
commit 1662b93fa0943e14ce2aa0f8836bd16aefd640e5
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Mon Nov 1 17:12:14 2021 -0300
17944: Forces vocabulary checking at startup time.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/lib/controller/handler.go b/lib/controller/handler.go
index 51c72b282..8edf1b0fd 100644
--- a/lib/controller/handler.go
+++ b/lib/controller/handler.go
@@ -74,7 +74,20 @@ func (h *Handler) CheckHealth() error {
return err
}
_, _, err = railsproxy.FindRailsAPI(h.Cluster)
- return err
+ if err != nil {
+ return err
+ }
+ if h.Cluster.API.VocabularyPath != "" {
+ req, err := http.NewRequest("GET", "/arvados/v1/vocabulary", nil)
+ if err != nil {
+ return err
+ }
+ _, err = h.localClusterRequest(req)
+ if err != nil {
+ return err
+ }
+ }
+ return nil
}
func (h *Handler) Done() <-chan struct{} {
commit 590a2f655f6a33aec7462b03101b4facfdcb9950
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Mon Nov 1 16:02:20 2021 -0300
17944: Vocabulary check errors return status 400 instead of 500.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/lib/controller/handler_test.go b/lib/controller/handler_test.go
index c99faba73..728c760af 100644
--- a/lib/controller/handler_test.go
+++ b/lib/controller/handler_test.go
@@ -138,6 +138,54 @@ func (s *HandlerSuite) TestVocabularyExport(c *check.C) {
}
}
+func (s *HandlerSuite) TestVocabularyFailedCheckStatus(c *check.C) {
+ voc := `{
+ "strict_tags": false,
+ "tags": {
+ "IDTAGIMPORTANCE": {
+ "strict": true,
+ "labels": [{"label": "Importance"}],
+ "values": {
+ "HIGH": {
+ "labels": [{"label": "High"}]
+ },
+ "LOW": {
+ "labels": [{"label": "Low"}]
+ }
+ }
+ }
+ }
+ }`
+ f, err := os.CreateTemp("", "test-vocabulary-*.json")
+ c.Assert(err, check.IsNil)
+ defer os.Remove(f.Name())
+ _, err = f.WriteString(voc)
+ c.Assert(err, check.IsNil)
+ f.Close()
+ s.cluster.API.VocabularyPath = f.Name()
+
+ req := httptest.NewRequest("POST", "/arvados/v1/collections",
+ strings.NewReader(`{
+ "collection": {
+ "properties": {
+ "IDTAGIMPORTANCE": "Critical"
+ }
+ }
+ }`))
+ req.Header.Set("Authorization", "Bearer "+arvadostest.ActiveToken)
+ req.Header.Set("Content-type", "application/json")
+
+ resp := httptest.NewRecorder()
+ s.handler.ServeHTTP(resp, req)
+ c.Log(resp.Body.String())
+ c.Assert(resp.Code, check.Equals, http.StatusBadRequest)
+ var jresp httpserver.ErrorResponse
+ err = json.Unmarshal(resp.Body.Bytes(), &jresp)
+ c.Check(err, check.IsNil)
+ c.Assert(len(jresp.Errors), check.Equals, 1)
+ c.Check(jresp.Errors[0], check.Matches, `.*tag value.*for key.*is not listed as valid.*`)
+}
+
func (s *HandlerSuite) TestProxyDiscoveryDoc(c *check.C) {
req := httptest.NewRequest("GET", "/discovery/v1/apis/arvados/v1/rest", nil)
resp := httptest.NewRecorder()
diff --git a/lib/controller/localdb/conn.go b/lib/controller/localdb/conn.go
index bec9354b1..e3f89ebf4 100644
--- a/lib/controller/localdb/conn.go
+++ b/lib/controller/localdb/conn.go
@@ -8,6 +8,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "net/http"
"os"
"strings"
@@ -15,6 +16,7 @@ import (
"git.arvados.org/arvados.git/lib/controller/rpc"
"git.arvados.org/arvados.git/sdk/go/arvados"
"git.arvados.org/arvados.git/sdk/go/ctxlog"
+ "git.arvados.org/arvados.git/sdk/go/httpserver"
"github.com/fsnotify/fsnotify"
"github.com/sirupsen/logrus"
)
@@ -60,7 +62,7 @@ func (conn *Conn) checkProperties(ctx context.Context, properties interface{}) e
if err != nil {
return err
}
- return voc.Check(props)
+ return httpErrorf(http.StatusBadRequest, voc.Check(props).Error())
}
func watchVocabulary(logger logrus.FieldLogger, vocPath string, fn func()) {
@@ -205,3 +207,7 @@ func (conn *Conn) GroupContents(ctx context.Context, options arvados.GroupConten
return conn.railsProxy.GroupContents(ctx, options)
}
+
+func httpErrorf(code int, format string, args ...interface{}) error {
+ return httpserver.ErrorWithStatus(fmt.Errorf(format, args...), code)
+}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list