Skip to content

Commit

Permalink
Merge pull request #545 from DeveloperJim/1.18.x
Browse files Browse the repository at this point in the history
1.18.3 release
  • Loading branch information
DeveloperJim committed Aug 4, 2020
2 parents 9691c6a + 64de1aa commit ddce7e6
Show file tree
Hide file tree
Showing 36 changed files with 6,792 additions and 174 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ cc-agent:pre
cp -R ./install/conf/bcs-k8s-master/bcs-cc-agent ${PACKAGEPATH}/bcs-k8s-master
go build ${LDFLAG} -o ${PACKAGEPATH}/bcs-k8s-master/bcs-cc-agent/bcs-cc-agent ./bcs-k8s/bcs-cc-agent/main.go

bkcmdb-synchronizer:
bkcmdb-synchronizer:pre
mkdir -p ${PACKAGEPATH}/bcs-services/bcs-bkcmdb-synchronizer
go build ${LDFLAG} -o ${PACKAGEPATH}/bcs-services/bcs-bkcmdb-synchronizer/bcs-bkcmdb-synchronizer ./bcs-services/bcs-bkcmdb-synchronizer/main.go

2 changes: 1 addition & 1 deletion bcs-common/common/RegisterDiscover/zkregdiscv.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ func (zkRD *ZkRegDiscv) discoverNodes(path string, servNodes []string) (*Discove
}

return discvEnv, nil
}
}
4 changes: 2 additions & 2 deletions bcs-common/common/types/rc.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ package types

//EnvVar represents an environment variable present in a Container
type EnvVar struct {
Name string `json:"name"`
Value string `json:"value,omitempty"`
Name string `json:"name"`
Value string `json:"value,omitempty"`
ValueFrom *EnvVarSource `json:"valueFrom,omitempty"`
}

Expand Down
2 changes: 1 addition & 1 deletion bcs-common/pkg/mesosdriver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (m *MesosDriverClient) getModuleAddr(clusterid string) (string, error) {
}

//update agent external resources
func (m *MesosDriverClient) UpdateAgentExtendedResources(clusterId string,er *commtypes.ExtendedResource) error {
func (m *MesosDriverClient) UpdateAgentExtendedResources(clusterId string, er *commtypes.ExtendedResource) error {
by, _ := json.Marshal(er)
_, err := m.requestMesosApiserver(clusterId, http.MethodPut, "agentsettings/extendedresource", by)
if err != nil {
Expand Down
28 changes: 1 addition & 27 deletions bcs-k8s/bcs-egress/go.sum

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions bcs-k8s/bcs-gamestatefulset-operator/doc/deploy/01-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ metadata:
release: gamestatefulset
name: gamestatefulsets.tkex.tencent.com
spec:
additionalPrinterColumns:
- JSONPath: .spec.replicas
name: Replicas
type: integer
- JSONPath: .status.readyReplicas
name: ReadyReplicas
type: integer
- JSONPath: .metadata.creationTimestamp
description: Age of the gamestatefulset
name: Age
type: date
group: tkex.tencent.com
names:
kind: GameStatefulSet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rules:
- update
- watch
- delete
- apiGroups: ["tkex"]
- apiGroups: ["tkex.tencent.com"]
resources:
- gamestatefulsets
- gamestatefulsets/status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (s *Scheduler) setVersionWithPodSpec(version *types.Version, spec *bcstype.
//env
container.Docker.Env = make(map[string]string)
for _, env := range c.Env {
if env.ValueFrom!=nil && env.ValueFrom.ResourceFieldRef!=nil && env.ValueFrom.ResourceFieldRef.Resource!="" {
if env.ValueFrom != nil && env.ValueFrom.ResourceFieldRef != nil && env.ValueFrom.ResourceFieldRef.Resource != "" {
switch env.ValueFrom.ResourceFieldRef.Resource {
case "requests.cpu":
container.Docker.Env[env.Name] = fmt.Sprintf("%f", container.Resources.Cpus*1000)
Expand All @@ -293,7 +293,7 @@ func (s *Scheduler) setVersionWithPodSpec(version *types.Version, spec *bcstype.
blog.Errorf("Deployment(%s:%s) Env(%s) ValueFrom(%s) is invalid",
version.ObjectMeta.NameSpace, version.ObjectMeta.Name, env.Name, env.ValueFrom.ResourceFieldRef.Resource)
}
}else {
} else {
container.Docker.Env[env.Name] = env.Value
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"io"
"io/ioutil"
"net/http"
Expand All @@ -27,6 +26,8 @@ import (
"strconv"
"strings"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"

simplejson "github.com/bitly/go-simplejson"
restful "github.com/emicklei/go-restful"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -130,6 +131,7 @@ func (proxy *kubeProxy) customResourceNamespaceValidate(req *http.Request) {
if req.Method != http.MethodPost {
return
}
//todo(DeveloperJim): fix panic when all body is empty
//validate namespace exist
allBytes, err := ioutil.ReadAll(req.Body)
if err != nil {
Expand All @@ -145,7 +147,7 @@ func (proxy *kubeProxy) customResourceNamespaceValidate(req *http.Request) {
}
jsonObj, err := simplejson.NewJson(allBytes)
if err != nil {
blog.Errorf("Custom Resource POST data is not expected json, %s. URL: %s", err.Error(), req.URL.String())
blog.Errorf("Custom Resource POST data is not expected json, %s. URL: %s. origin data: %s", err.Error(), req.URL.String(), string(allBytes))
return
}
meta := jsonObj.Get("metadata")
Expand Down
10 changes: 5 additions & 5 deletions bcs-mesos/bcs-scheduler/src/manager/sched/offer/offerpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type innerOffer struct {
id int64
offerId string
hostname string
offerIp string
offerIp string

isValid bool
createdTime int64
Expand Down Expand Up @@ -439,15 +439,15 @@ func (p *offerPool) addOffers(offers []*mesos.Offer) bool {
}
//calculate offer point
//point, (cpu-allocated/cpu)+(mem-allocated/mem)
offerIp,_ := p.getOfferIp(o)
offerIp, _ := p.getOfferIp(o)
var point float64
agent,err := p.store.FetchAgent(offerIp)
if err!=nil {
agent, err := p.store.FetchAgent(offerIp)
if err != nil {
blog.Errorf("Fetch Agent %s failed: %s, and decline offer", offerIp, err.Error())
p.scheduler.UpdateMesosAgents()
p.declineOffer(o)
continue
}else {
} else {
agentinfo := agent.GetAgentInfo()
point = cpu/agentinfo.CpuTotal + mem/agentinfo.MemTotal
blog.Infof("offer %s point=Cpu(%f/%f)+Mem(%f/%f)=%f", offerIp, cpu, agentinfo.CpuTotal, mem, agentinfo.MemTotal, point)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,8 @@ func (s *Scheduler) deleteDaemonset(daemon *types.BcsDaemonset) {
} else {
blog.Info("delete daemonset(%s): taskGroup(%s) not end status(%s) at current", daemon.GetUuid(), taskgroup.ID, taskgroup.Status)
}
}else {
blog.Infof("delete daemonset(%s): taskGroup(%s) in end status(%s)",daemon.GetUuid(), taskgroup.ID, taskgroup.Status)
} else {
blog.Infof("delete daemonset(%s): taskGroup(%s) in end status(%s)", daemon.GetUuid(), taskgroup.ID, taskgroup.Status)
}
}

Expand Down Expand Up @@ -409,7 +409,7 @@ func (s *Scheduler) deleteDaemonset(daemon *types.BcsDaemonset) {

// Delete a taskgroup:
// the taskgroup will delete from DB, application and service
func (s *Scheduler) DeleteDaemonsetTaskGroup(daemon *types.BcsDaemonset, taskGroup *types.TaskGroup){
func (s *Scheduler) DeleteDaemonsetTaskGroup(daemon *types.BcsDaemonset, taskGroup *types.TaskGroup) {
//delete daemonset pods index
delete(daemon.Pods, taskGroup.ID)
s.deleteTaskGroup(taskGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (mgr *DataCheckMgr) checkTaskgroupWhetherLost(taskGroups []*types.TaskGroup
switch taskGroup.Status {
case types.TASKGROUP_STATUS_RUNNING, types.TASKGROUP_STATUS_STARTING:
updateInterval = 4 * MAX_DATA_UPDATE_INTERVAL
/*case types.TASKGROUP_STATUS_STAGING:
/*case types.TASKGROUP_STATUS_STAGING:
updateInterval = 4 * MAX_STAGING_UPDATE_INTERVAL*/
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ func stateFromMasters(masters []string) (*megos.State, error) {
return mesosClient.GetStateFromCluster()
}

func (s *Scheduler) UpdateMesosAgents(){
func (s *Scheduler) UpdateMesosAgents() {
s.oprMgr.UpdateMesosAgents()
}

Expand Down
6 changes: 3 additions & 3 deletions bcs-mesos/bcs-scheduler/src/manager/sched/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func CreateTaskGroup(version *types.Version, ID string, appInstances uint64, app
task.Command = container.Docker.Command
task.Arguments = container.Docker.Arguments
task.DataClass = container.DataClass
task.DataClass.Msgs = make([]*types.BcsMessage,0)
task.DataClass.Msgs = make([]*types.BcsMessage, 0)
if err := createTaskConfigMaps(&task, container.ConfigMaps, store); err != nil {
return nil, err
}
Expand Down Expand Up @@ -383,10 +383,10 @@ func createTaskConfigMaps(task *types.Task, configMaps []commtypes.ConfigMap, st
blog.Warn("unkown configmap type:%s for task:%s", confItem.Type, task.ID)
continue
}
by,_ := json.Marshal(msg)
by, _ := json.Marshal(msg)
blog.Info("add task %s configmap message: %s", task.ID, string(by))
task.DataClass.Msgs = append(task.DataClass.Msgs, msg)
by,_ = json.Marshal(task.DataClass)
by, _ = json.Marshal(task.DataClass)
blog.Infof("task %s dataclass(%s)", task.ID, string(by))
}
}
Expand Down
30 changes: 15 additions & 15 deletions bcs-mesos/bcs-scheduler/src/manager/store/etcd/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"time"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
typesplugin "github.com/Tencent/bk-bcs/bcs-common/common/plugin"
"github.com/Tencent/bk-bcs/bcs-mesos/bcs-scheduler/src/manager/store"
"github.com/Tencent/bk-bcs/bcs-mesos/pkg/client/internalclientset"
"github.com/Tencent/bk-bcs/bcs-mesos/bcs-scheduler/src/pluginManager"
typesplugin "github.com/Tencent/bk-bcs/bcs-common/common/plugin"
"github.com/Tencent/bk-bcs/bcs-mesos/pkg/client/internalclientset"
bkbcsv2 "github.com/Tencent/bk-bcs/bcs-mesos/pkg/client/internalclientset/typed/bkbcs/v2"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -88,7 +88,7 @@ type managerStore struct {
cancel context.CancelFunc

//plugin manager, ip-resources
pm *pluginManager.PluginManager
pm *pluginManager.PluginManager
clusterId string
}

Expand Down Expand Up @@ -162,15 +162,15 @@ func (s *managerStore) StopStoreMetrics() {
s.cancel()

time.Sleep(time.Second)
// s.wg.Wait()
// s.wg.Wait()
}

//store metrics report prometheus
func (s *managerStore) StartStoreObjectMetrics() {
s.ctx, s.cancel = context.WithCancel(context.Background())
for {
time.Sleep(time.Minute)
if cacheMgr==nil || !cacheMgr.isOK {
if cacheMgr == nil || !cacheMgr.isOK {
continue
}
blog.Infof("start produce metrics")
Expand Down Expand Up @@ -251,8 +251,8 @@ func (s *managerStore) StartStoreObjectMetrics() {
var (
clusterCpu float64
clusterMem float64
remainCpu float64
remainMem float64
remainCpu float64
remainMem float64
)
for _, agent := range agents {
info := agent.GetAgentInfo()
Expand All @@ -262,7 +262,7 @@ func (s *managerStore) StartStoreObjectMetrics() {
}

var ipValue float64
if s.pm!=nil {
if s.pm != nil {
//request netservice to node container ip
para := &typesplugin.HostPluginParameter{
Ips: []string{info.IP},
Expand All @@ -285,9 +285,9 @@ func (s *managerStore) StartStoreObjectMetrics() {
}

//if ip-resources is zero, then ignore it
if s.pm==nil || ipValue>0{
remainCpu += info.CpuTotal-info.CpuUsed
remainMem += info.MemTotal-info.MemUsed
if s.pm == nil || ipValue > 0 {
remainCpu += info.CpuTotal - info.CpuUsed
remainMem += info.MemTotal - info.MemUsed
}
clusterCpu += info.CpuTotal
clusterMem += info.MemTotal
Expand Down Expand Up @@ -334,8 +334,8 @@ func NewEtcdStore(kubeconfig string, pm *pluginManager.PluginManager, clusterId
BkbcsClient: clientset.BkbcsV2(),
k8sClient: k8sClientset,
extensionClient: extensionClient,
pm: pm,
clusterId: clusterId,
pm: pm,
clusterId: clusterId,
}

//fetch application
Expand Down Expand Up @@ -444,6 +444,6 @@ func (store *managerStore) filterSpecialLabels(oriLabels map[string]string) map[
return labels
}

func (store *managerStore) ObjectNotLatestErr(err error)bool{
func (store *managerStore) ObjectNotLatestErr(err error) bool {
return strings.Contains(err.Error(), ObjectVersionNotLatestError)
}
}
6 changes: 3 additions & 3 deletions bcs-mesos/bcs-scheduler/src/manager/store/etcd/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ func (store *managerStore) SaveTask(task *types.Task) error {
return nil
}

func (store *managerStore) syncTaskInCache(taskId string){
task,err := store.FetchDBTask(taskId)
if err!=nil {
func (store *managerStore) syncTaskInCache(taskId string) {
task, err := store.FetchDBTask(taskId)
if err != nil {
blog.Errorf("fetch task(%s) in kube-apiserver failed: %s", taskId, err.Error())
return
}
Expand Down
6 changes: 3 additions & 3 deletions bcs-mesos/bcs-scheduler/src/manager/store/etcd/taskgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ func (store *managerStore) SaveTaskGroup(taskGroup *types.TaskGroup) error {
return nil
}

func (store *managerStore) syncTaskgroupInCache(taskgroupId string){
taskgroup,err := store.FetchDBTaskGroup(taskgroupId)
if err!=nil {
func (store *managerStore) syncTaskgroupInCache(taskgroupId string) {
taskgroup, err := store.FetchDBTaskGroup(taskgroupId)
if err != nil {
blog.Errorf("fetch taskgroup(%s) in kube-apiserver failed: %s", taskgroupId, err.Error())
return
}
Expand Down
20 changes: 10 additions & 10 deletions bcs-mesos/bcs-scheduler/src/manager/store/zk/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ type managerStore struct {
cancel context.CancelFunc

//plugin manager, ip-resources
pm *pluginManager.PluginManager
pm *pluginManager.PluginManager
clusterId string
}

// Create a store manager by a db driver
func NewManagerStore(dbDriver store.Dbdrvier, pm *pluginManager.PluginManager, clusterId string) store.Store {
s := &managerStore{
Db: dbDriver,
pm: pm,
Db: dbDriver,
pm: pm,
clusterId: clusterId,
}

Expand All @@ -60,7 +60,7 @@ func (s *managerStore) StartStoreObjectMetrics() {

for {
time.Sleep(time.Minute)
if cacheMgr==nil {
if cacheMgr == nil {
continue
}
blog.Infof("start produce metrics")
Expand Down Expand Up @@ -136,8 +136,8 @@ func (s *managerStore) StartStoreObjectMetrics() {
var (
clusterCpu float64
clusterMem float64
remainCpu float64
remainMem float64
remainCpu float64
remainMem float64
)
// handle agents metrics
agents, err := s.ListAllAgents()
Expand All @@ -152,7 +152,7 @@ func (s *managerStore) StartStoreObjectMetrics() {
}

var ipValue float64
if s.pm!=nil {
if s.pm != nil {
//request netservice to node container ip
para := &typesplugin.HostPluginParameter{
Ips: []string{info.IP},
Expand All @@ -175,9 +175,9 @@ func (s *managerStore) StartStoreObjectMetrics() {
}

//if ip-resources is zero, then ignore it
if s.pm==nil || ipValue>0{
clusterCpu += info.CpuTotal-info.CpuUsed
clusterMem += info.MemTotal-info.MemUsed
if s.pm == nil || ipValue > 0 {
clusterCpu += info.CpuTotal - info.CpuUsed
clusterMem += info.MemTotal - info.MemUsed
}
clusterCpu += info.CpuTotal
clusterMem += info.MemTotal
Expand Down
8 changes: 4 additions & 4 deletions bcs-mesos/pkg/apis/monitor/v1/servicemonitor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ func (s *ServiceMonitor) GetSelector() labels.Requirements {
return rms
}

func (s *ServiceMonitor) Match(labels map[string]string)bool{
for k,v :=range s.Spec.Selector.MatchLabels {
val,ok := labels[k]
if !ok || val!=v {
func (s *ServiceMonitor) Match(labels map[string]string) bool {
for k, v := range s.Spec.Selector.MatchLabels {
val, ok := labels[k]
if !ok || val != v {
return false
}
}
Expand Down
Loading

0 comments on commit ddce7e6

Please sign in to comment.