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