mirror of https://github.com/status-im/consul.git
consul: Ignore zero ttl on session
This commit is contained in:
parent
bb1ba3a167
commit
a5a9f051cd
|
@ -2,11 +2,12 @@ package agent
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/consul/consul"
|
||||
"github.com/hashicorp/consul/consul/structs"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/consul/consul"
|
||||
"github.com/hashicorp/consul/consul/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -61,7 +62,7 @@ func (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request)
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
if ttl < structs.SessionTTLMin || ttl > structs.SessionTTLMax {
|
||||
if ttl != 0 && (ttl < structs.SessionTTLMin || ttl > structs.SessionTTLMax) {
|
||||
resp.WriteHeader(400)
|
||||
resp.Write([]byte(fmt.Sprintf("Request TTL '%s', must be between [%v-%v]", args.Session.TTL, structs.SessionTTLMin, structs.SessionTTLMax)))
|
||||
return nil, nil
|
||||
|
|
|
@ -47,7 +47,7 @@ func (s *Session) Apply(args *structs.SessionRequest, reply *string) error {
|
|||
return fmt.Errorf("Session TTL '%s' invalid: %v", args.Session.TTL, err)
|
||||
}
|
||||
|
||||
if ttl < structs.SessionTTLMin || ttl > structs.SessionTTLMax {
|
||||
if ttl != 0 && (ttl < structs.SessionTTLMin || ttl > structs.SessionTTLMax) {
|
||||
return fmt.Errorf("Invalid Session TTL '%d', must be between [%v=%v]",
|
||||
ttl, structs.SessionTTLMin, structs.SessionTTLMax)
|
||||
}
|
||||
|
|
|
@ -1342,7 +1342,7 @@ func (s *StateStore) SessionCreate(index uint64, session *structs.Session) error
|
|||
return fmt.Errorf("Invalid Session TTL '%s': %v", session.TTL, err)
|
||||
}
|
||||
|
||||
if ttl < structs.SessionTTLMin || ttl > structs.SessionTTLMax {
|
||||
if ttl != 0 && (ttl < structs.SessionTTLMin || ttl > structs.SessionTTLMax) {
|
||||
return fmt.Errorf("Invalid Session TTL '%s', must be between [%v-%v]",
|
||||
session.TTL, structs.SessionTTLMin, structs.SessionTTLMax)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue