diff --git a/Makefile b/Makefile
index 3ece210047c..44598aef817 100644
--- a/Makefile
+++ b/Makefile
@@ -182,18 +182,22 @@ ifeq ($(BUILD_ENTERPRISE_READY),true)
$(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/compliance && ./compliance.test -test.v -test.timeout=120s -test.coverprofile=ccompliance.out || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/emoji && ./emoji.test -test.v -test.timeout=120s -test.coverprofile=cemoji.out || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/saml && ./saml.test -test.v -test.timeout=60s -test.coverprofile=csaml.out || exit 1
+ $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/cluster && ./cluster.test -test.v -test.timeout=60s -test.coverprofile=ccluster.out || exit 1
$(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/account_migration && ./account_migration.test -test.v -test.timeout=60s -test.coverprofile=caccount_migration.out || exit 1
tail -n +2 cldap.out >> ecover.out
tail -n +2 ccompliance.out >> ecover.out
tail -n +2 cemoji.out >> ecover.out
tail -n +2 csaml.out >> ecover.out
+ tail -n +2 ccluster.out >> ecover.out
tail -n +2 caccount_migration.out >> ecover.out
- rm -f cldap.out ccompliance.out cemoji.out csaml.out caccount_migration.out
+ rm -f cldap.out ccompliance.out cemoji.out csaml.out ccluster.out caccount_migration.out
+
rm -r ldap.test
rm -r compliance.test
rm -r emoji.test
rm -r saml.test
+ rm -r cluster.test
rm -r account_migration.test
rm -f config/*.crt
rm -f config/*.key
diff --git a/api/admin.go b/api/admin.go
index a50271f8bca..cab55e7d36d 100644
--- a/api/admin.go
+++ b/api/admin.go
@@ -46,6 +46,7 @@ func InitAdmin() {
BaseRoutes.Admin.Handle("/add_certificate", ApiAdminSystemRequired(addCertificate)).Methods("POST")
BaseRoutes.Admin.Handle("/remove_certificate", ApiAdminSystemRequired(removeCertificate)).Methods("POST")
BaseRoutes.Admin.Handle("/saml_cert_status", ApiAdminSystemRequired(samlCertificateStatus)).Methods("GET")
+ BaseRoutes.Admin.Handle("/cluster_status", ApiAdminSystemRequired(getClusterStatus)).Methods("GET")
}
func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -54,13 +55,32 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
+ lines, err := GetLogs()
+ if err != nil {
+ c.Err = err
+ return
+ }
+
+ if einterfaces.GetClusterInterface() != nil {
+ clines, err := einterfaces.GetClusterInterface().GetLogs()
+ if err != nil {
+ c.Err = err
+ return
+ }
+
+ lines = append(lines, clines...)
+ }
+
+ w.Write([]byte(model.ArrayToJson(lines)))
+}
+
+func GetLogs() ([]string, *model.AppError) {
var lines []string
if utils.Cfg.LogSettings.EnableFile {
-
file, err := os.Open(utils.GetLogFileLocation(utils.Cfg.LogSettings.FileLocation))
if err != nil {
- c.Err = model.NewLocAppError("getLogs", "api.admin.file_read_error", nil, err.Error())
+ return nil, model.NewLocAppError("getLogs", "api.admin.file_read_error", nil, err.Error())
}
defer file.Close()
@@ -73,7 +93,21 @@ func getLogs(c *Context, w http.ResponseWriter, r *http.Request) {
lines = append(lines, "")
}
- w.Write([]byte(model.ArrayToJson(lines)))
+ return lines, nil
+}
+
+func getClusterStatus(c *Context, w http.ResponseWriter, r *http.Request) {
+
+ if !c.HasSystemAdminPermissions("getClusterStatus") {
+ return
+ }
+
+ infos := make([]*model.ClusterInfo, 0)
+ if einterfaces.GetClusterInterface() != nil {
+ infos = einterfaces.GetClusterInterface().GetClusterInfos()
+ }
+
+ w.Write([]byte(model.ClusterInfosToJson(infos)))
}
func getAllAudits(c *Context, w http.ResponseWriter, r *http.Request) {
@@ -150,11 +184,26 @@ func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
+ if *utils.Cfg.ClusterSettings.Enable {
+ c.Err = model.NewLocAppError("saveConfig", "ent.cluster.save_config.error", nil, "")
+ return
+ }
+
c.LogAudit("")
+ //oldCfg := utils.Cfg
utils.SaveConfig(utils.CfgFileName, cfg)
utils.LoadConfig(utils.CfgFileName)
+ // Future feature is to sync the configuration files
+ // if einterfaces.GetClusterInterface() != nil {
+ // err := einterfaces.GetClusterInterface().ConfigChanged(cfg, oldCfg, true)
+ // if err != nil {
+ // c.Err = err
+ // return
+ // }
+ // }
+
rdata := map[string]string{}
rdata["status"] = "OK"
w.Write([]byte(model.MapToJson(rdata)))
diff --git a/api/admin_test.go b/api/admin_test.go
index 64ad7d69bfd..a4420ccbc5e 100644
--- a/api/admin_test.go
+++ b/api/admin_test.go
@@ -25,6 +25,18 @@ func TestGetLogs(t *testing.T) {
}
}
+func TestGetClusterInfos(t *testing.T) {
+ th := Setup().InitSystemAdmin().InitBasic()
+
+ if _, err := th.BasicClient.GetClusterStatus(); err == nil {
+ t.Fatal("Shouldn't have permissions")
+ }
+
+ if _, err := th.SystemAdminClient.GetClusterStatus(); err != nil {
+ t.Fatal(err)
+ }
+}
+
func TestGetAllAudits(t *testing.T) {
th := Setup().InitBasic().InitSystemAdmin()
diff --git a/api/context.go b/api/context.go
index 9a2f9b9ead9..08f41aa6dd7 100644
--- a/api/context.go
+++ b/api/context.go
@@ -14,13 +14,13 @@ import (
"github.com/gorilla/mux"
goi18n "github.com/nicksnyder/go-i18n/i18n"
+ "github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
)
var sessionCache *utils.Cache = utils.NewLru(model.SESSION_CACHE_SIZE)
-var statusCache *utils.Cache = utils.NewLru(model.STATUS_CACHE_SIZE)
var allowedMethods []string = []string{
"POST",
@@ -148,7 +148,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set(model.HEADER_REQUEST_ID, c.RequestId)
- w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v", model.CurrentVersion, utils.CfgLastModified))
+ w.Header().Set(model.HEADER_VERSION_ID, fmt.Sprintf("%v.%v", model.CurrentVersion, utils.CfgHash))
+ if einterfaces.GetClusterInterface() != nil {
+ w.Header().Set(model.HEADER_CLUSTER_ID, einterfaces.GetClusterInterface().GetClusterId())
+ }
// Instruct the browser not to display us in an iframe unless is the same origin for anti-clickjacking
if !h.isApi {
@@ -554,6 +557,10 @@ func RemoveAllSessionsForUserId(userId string) {
}
}
}
+
+ if einterfaces.GetClusterInterface() != nil {
+ einterfaces.GetClusterInterface().RemoveAllSessionsForUserId(userId)
+ }
}
func AddSessionToCache(session *model.Session) {
diff --git a/api/general.go b/api/general.go
index 233484e43dc..24855b82163 100644
--- a/api/general.go
+++ b/api/general.go
@@ -69,7 +69,6 @@ func ping(c *Context, w http.ResponseWriter, r *http.Request) {
m := make(map[string]string)
m["version"] = model.CurrentVersion
m["server_time"] = fmt.Sprintf("%v", model.GetMillis())
- m["node_id"] = ""
w.Write([]byte(model.MapToJson(m)))
}
diff --git a/api/status.go b/api/status.go
index 2a5a73c4a8d..d19105e3b96 100644
--- a/api/status.go
+++ b/api/status.go
@@ -7,11 +7,23 @@ import (
"net/http"
l4g "github.com/alecthomas/log4go"
+
+ "github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
)
+var statusCache *utils.Cache = utils.NewLru(model.STATUS_CACHE_SIZE)
+
+func AddStatusCache(status *model.Status) {
+ statusCache.Add(status.UserId, status)
+
+ if einterfaces.GetClusterInterface() != nil {
+ einterfaces.GetClusterInterface().UpdateStatus(status)
+ }
+}
+
func InitStatus() {
l4g.Debug(utils.T("api.status.init.debug"))
@@ -69,7 +81,7 @@ func SetStatusOnline(userId string, sessionId string) {
status.LastActivityAt = model.GetMillis()
}
- statusCache.Add(status.UserId, status)
+ AddStatusCache(status)
achan := Srv.Store.Session().UpdateLastActivityAt(sessionId, model.GetMillis())
@@ -98,7 +110,7 @@ func SetStatusOnline(userId string, sessionId string) {
func SetStatusOffline(userId string) {
status := &model.Status{userId, model.STATUS_OFFLINE, model.GetMillis()}
- statusCache.Add(status.UserId, status)
+ AddStatusCache(status)
if result := <-Srv.Store.Status().SaveOrUpdate(status); result.Err != nil {
l4g.Error(utils.T("api.status.save_status.error"), userId, result.Err)
@@ -125,7 +137,7 @@ func SetStatusAwayIfNeeded(userId string) {
status.Status = model.STATUS_AWAY
- statusCache.Add(status.UserId, status)
+ AddStatusCache(status)
if result := <-Srv.Store.Status().SaveOrUpdate(status); result.Err != nil {
l4g.Error(utils.T("api.status.save_status.error"), userId, result.Err)
diff --git a/api/web_hub.go b/api/web_hub.go
index 455189f7009..85aa01a6d8b 100644
--- a/api/web_hub.go
+++ b/api/web_hub.go
@@ -5,6 +5,8 @@ package api
import (
l4g "github.com/alecthomas/log4go"
+
+ "github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
)
@@ -31,14 +33,30 @@ var hub = &Hub{
func Publish(message *model.WebSocketEvent) {
hub.Broadcast(message)
+
+ if einterfaces.GetClusterInterface() != nil {
+ einterfaces.GetClusterInterface().Publish(message)
+ }
+}
+
+func PublishSkipClusterSend(message *model.WebSocketEvent) {
+ hub.Broadcast(message)
}
func InvalidateCacheForUser(userId string) {
hub.invalidateUser <- userId
+
+ if einterfaces.GetClusterInterface() != nil {
+ einterfaces.GetClusterInterface().InvalidateCacheForUser(userId)
+ }
}
func InvalidateCacheForChannel(channelId string) {
hub.invalidateChannel <- channelId
+
+ if einterfaces.GetClusterInterface() != nil {
+ einterfaces.GetClusterInterface().InvalidateCacheForChannel(channelId)
+ }
}
func (h *Hub) Register(webConn *WebConn) {
diff --git a/config/config.json b/config/config.json
index fdb8fd75521..9b9bcb67095 100644
--- a/config/config.json
+++ b/config/config.json
@@ -211,5 +211,10 @@
"AppDownloadLink": "https://about.mattermost.com/downloads/",
"AndroidAppDownloadLink": "https://about.mattermost.com/mattermost-android-app/",
"IosAppDownloadLink": "https://about.mattermost.com/mattermost-ios-app/"
+ },
+ "ClusterSettings": {
+ "Enable": false,
+ "InterNodeListenAddress": ":8075",
+ "InterNodeUrls": []
}
}
diff --git a/einterfaces/cluster.go b/einterfaces/cluster.go
new file mode 100644
index 00000000000..921576ad289
--- /dev/null
+++ b/einterfaces/cluster.go
@@ -0,0 +1,32 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package einterfaces
+
+import (
+ "github.com/mattermost/platform/model"
+)
+
+type ClusterInterface interface {
+ StartInterNodeCommunication()
+ StopInterNodeCommunication()
+ GetClusterInfos() []*model.ClusterInfo
+ RemoveAllSessionsForUserId(userId string)
+ InvalidateCacheForUser(userId string)
+ InvalidateCacheForChannel(channelId string)
+ Publish(event *model.WebSocketEvent)
+ UpdateStatus(status *model.Status)
+ GetLogs() ([]string, *model.AppError)
+ GetClusterId() string
+ ConfigChanged(previousConfig *model.Config, newConfig *model.Config, sendToOtherServer bool) *model.AppError
+}
+
+var theClusterInterface ClusterInterface
+
+func RegisterClusterInterface(newInterface ClusterInterface) {
+ theClusterInterface = newInterface
+}
+
+func GetClusterInterface() ClusterInterface {
+ return theClusterInterface
+}
diff --git a/i18n/en.json b/i18n/en.json
index 6ed6d6ebe99..79b0079e9f8 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -2203,6 +2203,10 @@
"id": "ent.brand.save_brand_image.too_large.app_error",
"translation": "Unable to open image. Image is too large."
},
+ {
+ "id": "ent.cluster.licence_disable.app_error",
+ "translation": "Clustering functionality disabled by current license. Please contact your system administrator about upgrading your enterprise license."
+ },
{
"id": "ent.compliance.licence_disable.app_error",
"translation": "Compliance functionality disabled by current license. Please contact your system administrator about upgrading your enterprise license."
@@ -4678,5 +4682,45 @@
{
"id": "web.watcher_fail.error",
"translation": "Failed to add directory to watcher %v"
+ },
+ {
+ "id": "ent.cluster.starting.info",
+ "translation": "Cluster internode communication is listening on %v with hostname=%v id=%v"
+ },
+ {
+ "id": "ent.cluster.save_config.error",
+ "translation": "System Console is set to read-only when High Availability is enabled."
+ },
+ {
+ "id": "ent.cluster.config_changed.info",
+ "translation": "Cluster configuration has changed for id=%v. Attempting to restart cluster service. To ensure the cluster is configured correctly you should not rely on this restart because we detected a core configuration change."
+ },
+ {
+ "id": "ent.cluster.stopping.info",
+ "translation": "Cluster internode communication is stopping on %v with hostname=%v id=%v"
+ },
+ {
+ "id": "ent.cluster.ping_failed.info",
+ "translation": "Cluster ping failed with hostname=%v on=%v with id=%v"
+ },
+ {
+ "id": "ent.cluster.ping_success.info",
+ "translation": "Cluster ping successful with hostname=%v on=%v with id=%v self=%v"
+ },
+ {
+ "id": "ent.cluster.incompatibile.warn",
+ "translation": "Potential incompatibile version detected for clustering with %v"
+ },
+ {
+ "id": "ent.cluster.incompatibile_config.warn",
+ "translation": "Potential incompatibile config detected for clustering with %v"
+ },
+ {
+ "id": "ent.cluster.debug_fail.debug",
+ "translation": "Cluster send failed at `%v` detail=%v, extra=%v, retry number=%v"
+ },
+ {
+ "id": "ent.cluster.final_fail.error",
+ "translation": "Cluster send final fail at `%v` detail=%v, extra=%v, retry number=%v"
}
]
diff --git a/mattermost.go b/mattermost.go
index 1b93fe8dfa8..1f0325b79aa 100644
--- a/mattermost.go
+++ b/mattermost.go
@@ -149,12 +149,20 @@ func main() {
complianceI.StartComplianceDailyJob()
}
+ if einterfaces.GetClusterInterface() != nil {
+ einterfaces.GetClusterInterface().StartInterNodeCommunication()
+ }
+
// wait for kill signal before attempting to gracefully shutdown
// the running service
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-c
+ if einterfaces.GetClusterInterface() != nil {
+ einterfaces.GetClusterInterface().StopInterNodeCommunication()
+ }
+
api.StopServer()
}
}
diff --git a/model/client.go b/model/client.go
index b9a5d883066..3aff3c93119 100644
--- a/model/client.go
+++ b/model/client.go
@@ -20,6 +20,7 @@ import (
const (
HEADER_REQUEST_ID = "X-Request-ID"
HEADER_VERSION_ID = "X-Version-ID"
+ HEADER_CLUSTER_ID = "X-Cluster-ID"
HEADER_ETAG_SERVER = "ETag"
HEADER_ETAG_CLIENT = "If-None-Match"
HEADER_FORWARDED = "X-Forwarded-For"
@@ -808,6 +809,15 @@ func (c *Client) GetLogs() (*Result, *AppError) {
}
}
+func (c *Client) GetClusterStatus() ([]*ClusterInfo, *AppError) {
+ if r, err := c.DoApiGet("/admin/cluster_status", "", ""); err != nil {
+ return nil, err
+ } else {
+ defer closeBody(r)
+ return ClusterInfosFromJson(r.Body), nil
+ }
+}
+
func (c *Client) GetAllAudits() (*Result, *AppError) {
if r, err := c.DoApiGet("/admin/audits", "", ""); err != nil {
return nil, err
diff --git a/model/cluster_info.go b/model/cluster_info.go
new file mode 100644
index 00000000000..7c3384ae20f
--- /dev/null
+++ b/model/cluster_info.go
@@ -0,0 +1,66 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "encoding/json"
+ "io"
+)
+
+type ClusterInfo struct {
+ Id string `json:"id"`
+ Version string `json:"version"`
+ ConfigHash string `json:"config_hash"`
+ InterNodeUrl string `json:"internode_url"`
+ Hostname string `json:"hostname"`
+ LastSuccessfulPing int64 `json:"last_ping"`
+ IsAlive bool `json:"is_alive"`
+}
+
+func (me *ClusterInfo) ToJson() string {
+ b, err := json.Marshal(me)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func ClusterInfoFromJson(data io.Reader) *ClusterInfo {
+ decoder := json.NewDecoder(data)
+ var me ClusterInfo
+ err := decoder.Decode(&me)
+ if err == nil {
+ return &me
+ } else {
+ return nil
+ }
+}
+
+func (me *ClusterInfo) HaveEstablishedInitialContact() bool {
+ if me.Id != "" {
+ return true
+ }
+
+ return false
+}
+
+func ClusterInfosToJson(objmap []*ClusterInfo) string {
+ if b, err := json.Marshal(objmap); err != nil {
+ return ""
+ } else {
+ return string(b)
+ }
+}
+
+func ClusterInfosFromJson(data io.Reader) []*ClusterInfo {
+ decoder := json.NewDecoder(data)
+
+ var objmap []*ClusterInfo
+ if err := decoder.Decode(&objmap); err != nil {
+ return make([]*ClusterInfo, 0)
+ } else {
+ return objmap
+ }
+}
diff --git a/model/cluster_info_test.go b/model/cluster_info_test.go
new file mode 100644
index 00000000000..d6348f5d1a0
--- /dev/null
+++ b/model/cluster_info_test.go
@@ -0,0 +1,32 @@
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestClusterInfoJson(t *testing.T) {
+ cluster := ClusterInfo{Id: NewId(), InterNodeUrl: NewId(), Hostname: NewId()}
+ json := cluster.ToJson()
+ result := ClusterInfoFromJson(strings.NewReader(json))
+
+ if cluster.Id != result.Id {
+ t.Fatal("Ids do not match")
+ }
+}
+
+func TestClusterInfosJson(t *testing.T) {
+ cluster := ClusterInfo{Id: NewId(), InterNodeUrl: NewId(), Hostname: NewId()}
+ clusterInfos := make([]*ClusterInfo, 1)
+ clusterInfos[0] = &cluster
+ json := ClusterInfosToJson(clusterInfos)
+ result := ClusterInfosFromJson(strings.NewReader(json))
+
+ if clusterInfos[0].Id != result[0].Id {
+ t.Fatal("Ids do not match")
+ }
+
+}
diff --git a/model/config.go b/model/config.go
index b239c83cad0..7fe575e58e4 100644
--- a/model/config.go
+++ b/model/config.go
@@ -80,6 +80,12 @@ type ServiceSettings struct {
RestrictCustomEmojiCreation *string
}
+type ClusterSettings struct {
+ Enable *bool
+ InterNodeListenAddress *string
+ InterNodeUrls []string
+}
+
type SSOSettings struct {
Enable bool
Secret string
@@ -297,6 +303,7 @@ type Config struct {
LocalizationSettings LocalizationSettings
SamlSettings SamlSettings
NativeAppSettings NativeAppSettings
+ ClusterSettings ClusterSettings
}
func (o *Config) ToJson() string {
@@ -707,6 +714,20 @@ func (o *Config) SetDefaults() {
*o.ServiceSettings.RestrictCustomEmojiCreation = RESTRICT_EMOJI_CREATION_ALL
}
+ if o.ClusterSettings.InterNodeListenAddress == nil {
+ o.ClusterSettings.InterNodeListenAddress = new(string)
+ *o.ClusterSettings.InterNodeListenAddress = ":8075"
+ }
+
+ if o.ClusterSettings.Enable == nil {
+ o.ClusterSettings.Enable = new(bool)
+ *o.ClusterSettings.Enable = false
+ }
+
+ if o.ClusterSettings.InterNodeUrls == nil {
+ o.ClusterSettings.InterNodeUrls = []string{}
+ }
+
if o.ComplianceSettings.Enable == nil {
o.ComplianceSettings.Enable = new(bool)
*o.ComplianceSettings.Enable = false
diff --git a/model/license.go b/model/license.go
index a60695890f7..a27b36263e3 100644
--- a/model/license.go
+++ b/model/license.go
@@ -38,6 +38,7 @@ type Features struct {
GoogleSSO *bool `json:"google_sso"`
Office365SSO *bool `json:"office365_sso"`
Compliance *bool `json:"compliance"`
+ Cluster *bool `json:"cluster"`
CustomBrand *bool `json:"custom_brand"`
MHPNS *bool `json:"mhpns"`
SAML *bool `json:"saml"`
@@ -81,6 +82,11 @@ func (f *Features) SetDefaults() {
*f.Compliance = *f.FutureFeatures
}
+ if f.Cluster == nil {
+ f.Cluster = new(bool)
+ *f.Cluster = *f.FutureFeatures
+ }
+
if f.CustomBrand == nil {
f.CustomBrand = new(bool)
*f.CustomBrand = *f.FutureFeatures
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index c9e435f34ec..79d1d809a49 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -502,7 +502,7 @@ func (s SqlUserStore) GetEtagForDirectProfiles(userId string) StoreChannel {
result.Data = fmt.Sprintf("%v.%v.0.%v.%v", model.CurrentVersion, model.GetMillis(), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
} else {
allIds := strings.Join(ids, "")
- result.Data = fmt.Sprintf("%v.%v.%v.%v.%v", model.CurrentVersion, md5.Sum([]byte(allIds)), len(ids), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
+ result.Data = fmt.Sprintf("%v.%x.%v.%v.%v", model.CurrentVersion, md5.Sum([]byte(allIds)), len(ids), utils.Cfg.PrivacySettings.ShowFullName, utils.Cfg.PrivacySettings.ShowEmailAddress)
}
storeChannel <- result
diff --git a/utils/config.go b/utils/config.go
index 868e96b510d..a1a6becd186 100644
--- a/utils/config.go
+++ b/utils/config.go
@@ -4,6 +4,7 @@
package utils
import (
+ "crypto/md5"
"encoding/json"
"fmt"
"io/ioutil"
@@ -26,7 +27,7 @@ const (
var Cfg *model.Config = &model.Config{}
var CfgDiagnosticId = ""
-var CfgLastModified int64 = 0
+var CfgHash = ""
var CfgFileName string = ""
var ClientCfg map[string]string = map[string]string{}
@@ -157,11 +158,10 @@ func LoadConfig(fileName string) {
map[string]interface{}{"Filename": fileName, "Error": err.Error()}))
}
- if info, err := file.Stat(); err != nil {
+ if _, err := file.Stat(); err != nil {
panic(T("utils.config.load_config.getting.panic",
map[string]interface{}{"Filename": fileName, "Error": err.Error()}))
} else {
- CfgLastModified = info.ModTime().Unix()
CfgFileName = fileName
}
@@ -185,6 +185,7 @@ func LoadConfig(fileName string) {
}
Cfg = &config
+ CfgHash = fmt.Sprintf("%x", md5.Sum([]byte(Cfg.ToJson())))
RegenerateClientConfig()
// Actions that need to run every time the config is loaded
@@ -298,6 +299,10 @@ func getClientConfig(c *model.Config) map[string]string {
props["SamlLoginButtonText"] = *c.SamlSettings.LoginButtonText
}
+ if *License.Features.Cluster {
+ props["EnableCluster"] = strconv.FormatBool(*c.ClusterSettings.Enable)
+ }
+
if *License.Features.GoogleSSO {
props["EnableSignUpWithGoogle"] = strconv.FormatBool(c.GoogleSettings.Enable)
}
diff --git a/utils/license.go b/utils/license.go
index 971b05912f2..246cc553e98 100644
--- a/utils/license.go
+++ b/utils/license.go
@@ -122,6 +122,7 @@ func getClientLicense(l *model.License) map[string]string {
props["LDAP"] = strconv.FormatBool(*l.Features.LDAP)
props["MFA"] = strconv.FormatBool(*l.Features.MFA)
props["SAML"] = strconv.FormatBool(*l.Features.SAML)
+ props["Cluster"] = strconv.FormatBool(*l.Features.Cluster)
props["GoogleSSO"] = strconv.FormatBool(*l.Features.GoogleSSO)
props["Office365SSO"] = strconv.FormatBool(*l.Features.Office365SSO)
props["Compliance"] = strconv.FormatBool(*l.Features.Compliance)
diff --git a/webapp/client/client.jsx b/webapp/client/client.jsx
index 59887100293..28d1210111b 100644
--- a/webapp/client/client.jsx
+++ b/webapp/client/client.jsx
@@ -4,6 +4,7 @@
import request from 'superagent';
const HEADER_X_VERSION_ID = 'x-version-id';
+const HEADER_X_CLUSTER_ID = 'x-cluster-id';
const HEADER_TOKEN = 'token';
const HEADER_BEARER = 'BEARER';
const HEADER_AUTH = 'Authorization';
@@ -12,6 +13,7 @@ export default class Client {
constructor() {
this.teamId = '';
this.serverVersion = '';
+ this.clusterId = '';
this.logToConsole = false;
this.useToken = false;
this.token = '';
@@ -152,6 +154,11 @@ export default class Client {
if (res.header[HEADER_X_VERSION_ID]) {
this.serverVersion = res.header[HEADER_X_VERSION_ID];
}
+
+ this.clusterId = res.header[HEADER_X_CLUSTER_ID];
+ if (res.header[HEADER_X_CLUSTER_ID]) {
+ this.clusterId = res.header[HEADER_X_CLUSTER_ID];
+ }
}
if (err) {
@@ -295,6 +302,15 @@ export default class Client {
end(this.handleResponse.bind(this, 'getLogs', success, error));
}
+ getClusterStatus(success, error) {
+ return request.
+ get(`${this.getAdminRoute()}/cluster_status`).
+ set(this.defaultHeaders).
+ type('application/json').
+ accept('application/json').
+ end(this.handleResponse.bind(this, 'getClusterStatus', success, error));
+ }
+
getServerAudits(success, error) {
return request.
get(`${this.getAdminRoute()}/audits`).
diff --git a/webapp/components/admin_console/admin_sidebar.jsx b/webapp/components/admin_console/admin_sidebar.jsx
index 569885f98e0..2e7915baf04 100644
--- a/webapp/components/admin_console/admin_sidebar.jsx
+++ b/webapp/components/admin_console/admin_sidebar.jsx
@@ -178,6 +178,7 @@ export default class AdminSidebar extends React.Component {
let oauthSettings = null;
let ldapSettings = null;
let samlSettings = null;
+ let clusterSettings = null;
let complianceSettings = null;
let license = null;
@@ -213,6 +214,20 @@ export default class AdminSidebar extends React.Component {
);
}
+ if (global.window.mm_license.Cluster === 'true') {
+ clusterSettings = (
+
+
|
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
|---|