Loading charts/redis/templates/redis-master-svc.yaml +3 −25 Original line number Diff line number Diff line apiVersion: v1 kind: Service metadata: name: {{ template "redis.fullname" . }}-master labels: app: {{ template "redis.name" . }} chart: {{ template "redis.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" meepOrigin: {{ .Values.meepOrigin }} annotations: {{- if .Values.master.service.annotations }} {{ toYaml .Values.master.service.annotations | indent 4 }} {{- end }} spec: type: {{ .Values.master.service.type }} {{ if eq .Values.master.service.type "LoadBalancer" -}} {{ if .Values.master.service.loadBalancerIP -}} loadBalancerIP: {{ .Values.master.service.loadBalancerIP }} {{ end -}} {{- end -}} ports: - name: redis port: 6379 targetPort: redis {{- if .Values.master.service.nodePort }} nodePort: {{ .Values.master.service.nodePort }} {{- end }} selector: app: {{ template "redis.name" . }} release: "{{ .Release.Name }}" {{- if .Values.cluster.enabled }} role: master {{- end }} charts/redis/values.yaml +3 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ master: disableCommands: "" persistence: enabled: false service: type: NodePort nodePort: 30379 meepOrigin: core go-apps/meep-ctrl-engine/go.mod +6 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ module github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-ctrl-engine go 1.12 require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-virt-engine-client v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-watchdog v0.0.0 github.com/KromDaniel/jonson v0.0.0-20180630143114-d2f9c3c389db // indirect github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351 github.com/flimzy/diff v0.1.5 // indirect Loading Loading @@ -39,4 +39,8 @@ require ( sigs.k8s.io/yaml v1.1.0 // indirect ) replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-virt-engine-client => ../../go-packages/meep-virt-engine-client replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger => ../../go-packages/meep-logger replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis => ../../go-packages/meep-redis replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-watchdog => ../../go-packages/meep-watchdog go-apps/meep-ctrl-engine/go.sum +2 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190415100556-4a65cf94b679 h1:tzVWzOrXxwAwdSCMrf+mbNrZFxwS0+HLP4m2qxtfdhk= Loading @@ -80,6 +81,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= Loading go-apps/meep-ctrl-engine/server/ctrl-engine.go +24 −67 Original line number Diff line number Diff line Loading @@ -16,13 +16,14 @@ import ( "net/http" "sort" "strings" "time" "github.com/flimzy/kivik" _ "github.com/go-kivik/couchdb" "github.com/gorilla/mux" log "github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-ctrl-engine/log" ve "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-virt-engine-client" watchdog "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-watchdog" ) const scenarioDBName = "scenarios" Loading @@ -39,9 +40,8 @@ const NOUP = "2" const NB_CORE_PODS = 9 //although virt-engine is not a pod yet... it is considered as one as is appended to the list of pods var virtEngine *ve.APIClient var db *kivik.DB var virtWatchdog *watchdog.Watchdog var clientServiceMapList []ClientServiceMap Loading Loading @@ -292,15 +292,17 @@ func CtrlEngineInit() (err error) { } log.Info("Connected to Active DB") // Create client for Virtualization Engine API veCfg := ve.NewConfiguration() veCfg.BasePath = "http://meep-virt-engine/v1" virtEngine = ve.NewAPIClient(veCfg) if virtEngine == nil { log.Debug("Cannot find the Virtualization Engine API") // Setup for virt-engine monitoring virtWatchdog, err = watchdog.NewWatchdog("", "meep-virt-engine") if err != nil { log.Error("Failed to initialize virt-engine watchdog. Error: ", err) return err } err = virtWatchdog.Start(time.Second, 3*time.Second) if err != nil { log.Error("Failed to start virt-engine watchdog. Error: ", err) return err } log.Info("Created Virt Engine client") return nil } Loading Loading @@ -492,56 +494,28 @@ func ceActivateScenario(w http.ResponseWriter, r *http.Request) { } // Retrieve scenario to activate from DB // !!!!! IMPORTANT NOTE !!!!! // Scenario stored in DB is unmarshalled into a VE Scenario object var veScenario ve.Scenario err = getScenario(false, db, scenarioName, &veScenario) err = getScenario(false, db, scenarioName, &activeScenario) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) return } // Populate active external client service map populateClientServiceMap(&activeScenario) // Set active scenario in DB rev, err := addScenario(db, activeScenarioName, veScenario) _, err = addScenario(db, activeScenarioName, activeScenario) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } log.Debug("Active scenario set with rev: ", rev) // Activate scenario in virtualization Engine //lint:ignore SA1012 context.TODO not supported here resp, err := virtEngine.ScenarioDeploymentApi.ActivateScenario(nil, veScenario) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) _ = removeScenario(db, activeScenarioName) return } // Retrieve active scenario stored in DB err = getScenario(false, db, activeScenarioName, &activeScenario) if err != nil { log.Error("Scenario not active") http.Error(w, "Scenario not active", http.StatusBadRequest) _ = removeScenario(db, activeScenarioName) return } // Populate active external client service map populateClientServiceMap(&activeScenario) // Return response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if resp != nil { w.WriteHeader(resp.StatusCode) } else { w.WriteHeader(http.StatusOK) } } // ceGetActiveScenario retrieves the deployed scenario status func ceGetActiveScenario(w http.ResponseWriter, r *http.Request) { Loading Loading @@ -589,7 +563,7 @@ func ceGetActiveScenario(w http.ResponseWriter, r *http.Request) { // ceGetActiveClientServiceMaps retrieves the deployed scenario external client service mappings // NOTE: query parameters 'client' and 'service' may be specified to filter results func ceGetActiveClientServiceMaps(w http.ResponseWriter, r *http.Request) { log.Debug("ceGetActiveClientServiceMaps") //log.Debug("ceGetActiveClientServiceMaps") var filteredList *[]ClientServiceMap // Retrieve client ID & service name from query parameters Loading Loading @@ -690,23 +664,14 @@ func ceTerminateScenario(w http.ResponseWriter, r *http.Request) { err = RedisDBPublish(channelCtrlActive, "") if err != nil { log.Error(err.Error()) } // Terminate scenario in virtualization Engine //lint:ignore SA1012 context.TODO not supported here resp, err := virtEngine.ScenarioDeploymentApi.TerminateScenario(nil, scenario.Name) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if resp != nil { w.WriteHeader(resp.StatusCode) } else { w.WriteHeader(http.StatusOK) } } func ceGetEventList(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") Loading Loading @@ -1123,16 +1088,8 @@ func ceGetStates(w http.ResponseWriter, r *http.Request) { // ***** virt-engine is not a pod yet, but we need to make sure it is started to have a functional system var podStatus PodStatus podStatus.Name = "virt-engine" //we do not care about the content of the answer, simply that there is one //lint:ignore SA1012 context.TODO not supported here _, resp, _ := virtEngine.ScenarioDeploymentApi.GetActiveScenario(nil, "dummy") if resp != nil { if resp.StatusCode == http.StatusOK { if virtWatchdog.IsAlive() { podStatus.LogicalState = "Running" } else { podStatus.LogicalState = "InternalError" } } else { podStatus.LogicalState = "NotRunning" } Loading Loading
charts/redis/templates/redis-master-svc.yaml +3 −25 Original line number Diff line number Diff line apiVersion: v1 kind: Service metadata: name: {{ template "redis.fullname" . }}-master labels: app: {{ template "redis.name" . }} chart: {{ template "redis.chart" . }} release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" meepOrigin: {{ .Values.meepOrigin }} annotations: {{- if .Values.master.service.annotations }} {{ toYaml .Values.master.service.annotations | indent 4 }} {{- end }} spec: type: {{ .Values.master.service.type }} {{ if eq .Values.master.service.type "LoadBalancer" -}} {{ if .Values.master.service.loadBalancerIP -}} loadBalancerIP: {{ .Values.master.service.loadBalancerIP }} {{ end -}} {{- end -}} ports: - name: redis port: 6379 targetPort: redis {{- if .Values.master.service.nodePort }} nodePort: {{ .Values.master.service.nodePort }} {{- end }} selector: app: {{ template "redis.name" . }} release: "{{ .Release.Name }}" {{- if .Values.cluster.enabled }} role: master {{- end }}
charts/redis/values.yaml +3 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ master: disableCommands: "" persistence: enabled: false service: type: NodePort nodePort: 30379 meepOrigin: core
go-apps/meep-ctrl-engine/go.mod +6 −2 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ module github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-ctrl-engine go 1.12 require ( github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-virt-engine-client v0.0.0 github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-watchdog v0.0.0 github.com/KromDaniel/jonson v0.0.0-20180630143114-d2f9c3c389db // indirect github.com/KromDaniel/rejonson v0.0.0-20180822072824-00b5bcf2b351 github.com/flimzy/diff v0.1.5 // indirect Loading Loading @@ -39,4 +39,8 @@ require ( sigs.k8s.io/yaml v1.1.0 // indirect ) replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-virt-engine-client => ../../go-packages/meep-virt-engine-client replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger => ../../go-packages/meep-logger replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-redis => ../../go-packages/meep-redis replace github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-watchdog => ../../go-packages/meep-watchdog
go-apps/meep-ctrl-engine/go.sum +2 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190415100556-4a65cf94b679 h1:tzVWzOrXxwAwdSCMrf+mbNrZFxwS0+HLP4m2qxtfdhk= Loading @@ -80,6 +81,7 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= Loading
go-apps/meep-ctrl-engine/server/ctrl-engine.go +24 −67 Original line number Diff line number Diff line Loading @@ -16,13 +16,14 @@ import ( "net/http" "sort" "strings" "time" "github.com/flimzy/kivik" _ "github.com/go-kivik/couchdb" "github.com/gorilla/mux" log "github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-ctrl-engine/log" ve "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-virt-engine-client" watchdog "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-watchdog" ) const scenarioDBName = "scenarios" Loading @@ -39,9 +40,8 @@ const NOUP = "2" const NB_CORE_PODS = 9 //although virt-engine is not a pod yet... it is considered as one as is appended to the list of pods var virtEngine *ve.APIClient var db *kivik.DB var virtWatchdog *watchdog.Watchdog var clientServiceMapList []ClientServiceMap Loading Loading @@ -292,15 +292,17 @@ func CtrlEngineInit() (err error) { } log.Info("Connected to Active DB") // Create client for Virtualization Engine API veCfg := ve.NewConfiguration() veCfg.BasePath = "http://meep-virt-engine/v1" virtEngine = ve.NewAPIClient(veCfg) if virtEngine == nil { log.Debug("Cannot find the Virtualization Engine API") // Setup for virt-engine monitoring virtWatchdog, err = watchdog.NewWatchdog("", "meep-virt-engine") if err != nil { log.Error("Failed to initialize virt-engine watchdog. Error: ", err) return err } err = virtWatchdog.Start(time.Second, 3*time.Second) if err != nil { log.Error("Failed to start virt-engine watchdog. Error: ", err) return err } log.Info("Created Virt Engine client") return nil } Loading Loading @@ -492,56 +494,28 @@ func ceActivateScenario(w http.ResponseWriter, r *http.Request) { } // Retrieve scenario to activate from DB // !!!!! IMPORTANT NOTE !!!!! // Scenario stored in DB is unmarshalled into a VE Scenario object var veScenario ve.Scenario err = getScenario(false, db, scenarioName, &veScenario) err = getScenario(false, db, scenarioName, &activeScenario) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) return } // Populate active external client service map populateClientServiceMap(&activeScenario) // Set active scenario in DB rev, err := addScenario(db, activeScenarioName, veScenario) _, err = addScenario(db, activeScenarioName, activeScenario) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } log.Debug("Active scenario set with rev: ", rev) // Activate scenario in virtualization Engine //lint:ignore SA1012 context.TODO not supported here resp, err := virtEngine.ScenarioDeploymentApi.ActivateScenario(nil, veScenario) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) _ = removeScenario(db, activeScenarioName) return } // Retrieve active scenario stored in DB err = getScenario(false, db, activeScenarioName, &activeScenario) if err != nil { log.Error("Scenario not active") http.Error(w, "Scenario not active", http.StatusBadRequest) _ = removeScenario(db, activeScenarioName) return } // Populate active external client service map populateClientServiceMap(&activeScenario) // Return response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if resp != nil { w.WriteHeader(resp.StatusCode) } else { w.WriteHeader(http.StatusOK) } } // ceGetActiveScenario retrieves the deployed scenario status func ceGetActiveScenario(w http.ResponseWriter, r *http.Request) { Loading Loading @@ -589,7 +563,7 @@ func ceGetActiveScenario(w http.ResponseWriter, r *http.Request) { // ceGetActiveClientServiceMaps retrieves the deployed scenario external client service mappings // NOTE: query parameters 'client' and 'service' may be specified to filter results func ceGetActiveClientServiceMaps(w http.ResponseWriter, r *http.Request) { log.Debug("ceGetActiveClientServiceMaps") //log.Debug("ceGetActiveClientServiceMaps") var filteredList *[]ClientServiceMap // Retrieve client ID & service name from query parameters Loading Loading @@ -690,23 +664,14 @@ func ceTerminateScenario(w http.ResponseWriter, r *http.Request) { err = RedisDBPublish(channelCtrlActive, "") if err != nil { log.Error(err.Error()) } // Terminate scenario in virtualization Engine //lint:ignore SA1012 context.TODO not supported here resp, err := virtEngine.ScenarioDeploymentApi.TerminateScenario(nil, scenario.Name) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusNotFound) return } // Send response w.Header().Set("Content-Type", "application/json; charset=UTF-8") if resp != nil { w.WriteHeader(resp.StatusCode) } else { w.WriteHeader(http.StatusOK) } } func ceGetEventList(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") Loading Loading @@ -1123,16 +1088,8 @@ func ceGetStates(w http.ResponseWriter, r *http.Request) { // ***** virt-engine is not a pod yet, but we need to make sure it is started to have a functional system var podStatus PodStatus podStatus.Name = "virt-engine" //we do not care about the content of the answer, simply that there is one //lint:ignore SA1012 context.TODO not supported here _, resp, _ := virtEngine.ScenarioDeploymentApi.GetActiveScenario(nil, "dummy") if resp != nil { if resp.StatusCode == http.StatusOK { if virtWatchdog.IsAlive() { podStatus.LogicalState = "Running" } else { podStatus.LogicalState = "InternalError" } } else { podStatus.LogicalState = "NotRunning" } Loading