diff --git a/command/agent/session_endpoint_test.go b/command/agent/session_endpoint_test.go index ad3d58a822..9052e42385 100644 --- a/command/agent/session_endpoint_test.go +++ b/command/agent/session_endpoint_test.go @@ -34,6 +34,7 @@ func TestSessionCreate(t *testing.T) { body := bytes.NewBuffer(nil) enc := json.NewEncoder(body) raw := map[string]interface{}{ + "Name": "my-cool-session", "Node": srv.agent.config.NodeName, "Checks": []string{consul.SerfCheckID, "consul"}, "LockDelay": "20s", diff --git a/consul/session_endpoint_test.go b/consul/session_endpoint_test.go index 8b59d7a28c..ab3bfb8435 100644 --- a/consul/session_endpoint_test.go +++ b/consul/session_endpoint_test.go @@ -24,6 +24,7 @@ func TestSessionEndpoint_Apply(t *testing.T) { Op: structs.SessionCreate, Session: structs.Session{ Node: "foo", + Name: "my-session", }, } var out string @@ -41,6 +42,12 @@ func TestSessionEndpoint_Apply(t *testing.T) { if s == nil { t.Fatalf("should not be nil") } + if s.Node != "foo" { + t.Fatalf("bad: %v", s) + } + if s.Name != "my-session" { + t.Fatalf("bad: %v", s) + } // Do a delete arg.Op = structs.SessionDestroy diff --git a/consul/structs/structs.go b/consul/structs/structs.go index c42250214d..56ec95c351 100644 --- a/consul/structs/structs.go +++ b/consul/structs/structs.go @@ -354,6 +354,7 @@ type IndexedKeyList struct { type Session struct { CreateIndex uint64 ID string + Name string Node string Checks []string LockDelay time.Duration diff --git a/website/source/docs/agent/http.html.markdown b/website/source/docs/agent/http.html.markdown index 8cfc2ac0bc..8fb232c643 100644 --- a/website/source/docs/agent/http.html.markdown +++ b/website/source/docs/agent/http.html.markdown @@ -930,6 +930,7 @@ body must look like: { "LockDelay": "15s", + "Name": "my-service-lock", "Node": "foobar", "Checks": ["a", "b", "c"] } @@ -941,7 +942,8 @@ value. Small values are treated as seconds, and otherwise it is provided with nanosecond granularity. The `Node` field must refer to a node that is already registered. By default, -the agent will use it's own name. Lastly, the `Checks` field is used to provide +the agent will use it's own name. The `Name` field can be used to provide a human +readable name for the Session. Lastly, the `Checks` field is used to provide a list of associated health checks. By default the "serfHealth" check is provided. It is highly recommended that if you override this list, you include that check.