Skip to content

Commit

Permalink
update for master uptime
Browse files Browse the repository at this point in the history
  • Loading branch information
ralfyang committed Jun 29, 2020
1 parent 017c896 commit 8fe11b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ func Resource_info()string{
func RnR(){
Check_master()
if AM_I_MASTER == "MASTER" {
communicator.Get_http(klevr_console+"/user/"+User_account_id+"/ackmaster", Api_key_string)
Alive_chk_to_mgm("ok")
if Provider_type == "baremetal" {
println ("Docker_runner here - klevr_beacon_img")
Expand Down
23 changes: 19 additions & 4 deletions webconsole/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func Get_host(user string) string{
Master_info = "master="+strr2[1]
arr_stop = i
}
uri := "/v1/kv/klevr/"+user+"/masters?raw=1"
uri := "/v1/kv/klevr/"+user+"/masters"
communicator.Put_http(API_url+uri, Master_info, API_key_string)
}
}else{
Expand All @@ -150,8 +150,8 @@ func Get_host(user string) string{
// log.Println("Error: Target endpoint will be /health, but current address is: "+endpoint+" please check the range of array from API.")
array_count = array_count + 1
}
uri := "/v1/kv/klevr/"+user+"/masters?raw=1"
communicator.Put_http(API_url+uri, Master_info, API_key_string)
// uri := "/v1/kv/klevr/"+user+"/masters"
// communicator.Put_http(API_url+uri, Master_info, API_key_string)
}
println("fail_countfail_countfail_countfail_countfail_countfail_countfail_countfail_count:",fail_count)
println("array_countarray_countarray_countarray_countarray_countarray_countarray_countarray_countarray_count:",array_count)
Expand Down Expand Up @@ -182,6 +182,14 @@ func Get_info_master(user string){
Get_master(user)
}



func Put_master_ack(user, ack string){
uri := "/v1/kv/klevr/"+user+"/master_ack"
communicator.Put_http(API_url+uri, ack, API_key_string)
}


/// Old hostlist purge
func Hostpool_mgt(user string) string{
/// Define variables
Expand Down Expand Up @@ -229,7 +237,6 @@ func Hostpool_mgt(user string) string{
func Client_receiver(user, hostname, host_ip, host_type, host_alive, master_alive string)string{
uri := "/v1/kv/klevr/"+user+"/hosts/"+hostname+"/health"
data := "last_check="+host_alive+"&ip="+host_ip+"&clientType="+host_type+"&masterConnection="+master_alive
///last_check=1592385021&ip=192.168.2.100&clientType=baremetal&masterConnection=ok
communicator.Put_http(API_url+uri, data, API_key_string)
Buffer_result = data
return Buffer_result
Expand All @@ -252,6 +259,14 @@ func main() {
r.HandleFunc("/apiserver", API_Server_info)
r.HandleFunc("/apikey", API_key)

/// Master ack receiver
r.HandleFunc("/user/{U}/ackmaster", func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
user := vars["U"]
ack_time := fmt.Sprint(time.Now().Unix())
Put_master_ack(user, ack_time)
})

/// Hostinfo receiver
r.HandleFunc("/user/{U}/hostsinfo", func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down

0 comments on commit 8fe11b5

Please sign in to comment.