Skip to content

Commit

Permalink
no scale for pd; only scale out for store
Browse files Browse the repository at this point in the history
  • Loading branch information
loadwiki committed Apr 4, 2019
1 parent 2dde38f commit 1b778da
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 35 deletions.
8 changes: 4 additions & 4 deletions charts/cell-cluster/templates/scripts/_start_proxy.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ until result=$(wget -qO- -T 3 http://${discovery_url}/proxy-config/${encoded_pod
echo "waiting for discovery service returns start args ..."
sleep $((RANDOM % 5))
done
echo ${result} > /var/lib/redis-proxy/proxy-config.json
echo ${result} > /var/lib/proxy/proxy-config.json

ARGS="\
-log-level=debug \
--cfg=/var/lib/redis-proxy/proxy-config.json \
--cfg=/var/lib/proxy/proxy-config.json \
"

echo "start cell-proxy ..."
cat /etc/proxy/proxy-config.json
exec /usr/local/bin/redis-proxy ${ARGS}
cat /var/lib/proxy/proxy-config.json
exec /usr/local/bin/proxy ${ARGS}
2 changes: 1 addition & 1 deletion charts/cell-cluster/templates/scripts/_start_store.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ until result=$(wget -qO- -T 3 http://${discovery_url}/store-config 2>/dev/null);
sleep $((RANDOM % 5))
done

ARGS="--data=/var/lib/cell/data \
ARGS="--data=/var/lib/store/data \
-log-level=debug \
--addr=${store_domain}:10800 \
--addr-cli=${store_domain}:6370 \
Expand Down
8 changes: 7 additions & 1 deletion pkg/manager/member/pd_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func (pdmm *pdMemberManager) syncPDStatefulSetForCellCluster(cc *v1alpha1.CellCl

if *newPDSet.Spec.Replicas != *oldPDSet.Spec.Replicas {
glog.Errorf("failed to sync CellCluster: [%s/%s]'s status, pd doesn't support scale now! ", ns, ccName)
return nil
}

// TODO FIXME equal is false every time
Expand Down Expand Up @@ -467,7 +468,7 @@ func (pdmm *pdMemberManager) getNewPDSetForCellCluster(cc *v1alpha1.CellCluster)
ImagePullPolicy: cc.Spec.PD.ImagePullPolicy,
Ports: []corev1.ContainerPort{
{
Name: "server",
Name: "peer",
ContainerPort: int32(2380),
Protocol: corev1.ProtocolTCP,
},
Expand All @@ -476,6 +477,11 @@ func (pdmm *pdMemberManager) getNewPDSetForCellCluster(cc *v1alpha1.CellCluster)
ContainerPort: int32(2379),
Protocol: corev1.ProtocolTCP,
},
{
Name: "rpc",
ContainerPort: int32(20800),
Protocol: corev1.ProtocolTCP,
},
},
VolumeMounts: volMounts,
Resources: util.ResourceRequirement(cc.Spec.PD.ContainerSpec),
Expand Down
19 changes: 2 additions & 17 deletions pkg/manager/member/proxy_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/listers/apps/v1beta1"
corelisters "k8s.io/client-go/listers/core/v1"
)
Expand Down Expand Up @@ -169,28 +168,14 @@ func (pxmm *proxyMemberManager) getNewProxySetForCellCluster(cc *v1alpha1.CellCl
ImagePullPolicy: cc.Spec.Proxy.ImagePullPolicy,
Ports: []corev1.ContainerPort{
{
Name: "server",
ContainerPort: int32(4000),
Protocol: corev1.ProtocolTCP,
},
{
Name: "status", // pprof, status, metrics
ContainerPort: int32(10080),
Name: "redis",
ContainerPort: int32(6379),
Protocol: corev1.ProtocolTCP,
},
},
VolumeMounts: volMounts,
Resources: util.ResourceRequirement(cc.Spec.Proxy.ContainerSpec),
Env: envs,
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/status",
Port: intstr.FromInt(10080),
},
},
InitialDelaySeconds: int32(10),
},
})

proxyLabel := label.New().Instance(instanceName).Proxy()
Expand Down
37 changes: 25 additions & 12 deletions pkg/manager/member/store_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,25 @@ func (stmm *storeMemberManager) syncStatefulSetForCellCluster(cc *v1alpha1.CellC
}

if *newSet.Spec.Replicas < *oldSet.Spec.Replicas {
if err := stmm.storeScaler.ScaleIn(cc, oldSet, newSet); err != nil {
return err
}
glog.Errorf("cell cluster does not support scale in!")
*newSet.Spec.Replicas = *oldSet.Spec.Replicas

/*
if err := stmm.storeScaler.ScaleIn(cc, oldSet, newSet); err != nil {
return err
}
*/
}

if stmm.autoFailover {
if cc.StoreAllPodsStarted() && !cc.StoreAllStoresReady() {
if err := stmm.storeFailover.Failover(cc); err != nil {
return err
glog.Errorf("cell cluster does not auto fail over!")
/*
if cc.StoreAllPodsStarted() && !cc.StoreAllStoresReady() {
if err := stmm.storeFailover.Failover(cc); err != nil {
return err
}
}
}
*/
}

if !statefulSetEqual(*newSet, *oldSet) {
Expand Down Expand Up @@ -333,8 +341,13 @@ func (stmm *storeMemberManager) getNewSetForCellCluster(cc *v1alpha1.CellCluster
ImagePullPolicy: cc.Spec.Store.ImagePullPolicy,
Ports: []corev1.ContainerPort{
{
Name: "server",
ContainerPort: int32(20160),
Name: "store-server",
ContainerPort: int32(10800),
Protocol: corev1.ProtocolTCP,
},
{
Name: "redis-cli",
ContainerPort: int32(6370),
Protocol: corev1.ProtocolTCP,
},
},
Expand Down Expand Up @@ -487,7 +500,7 @@ func (stmm *storeMemberManager) getKVStore(store *pdapi.StoreInfo) *v1alpha1.KVS
}
storeID := fmt.Sprintf("%d", store.Meta.ID)
ip := strings.Split(store.Meta.Address, ":")[0]
// podName := strings.Split(ip, ".")[0]
podName := strings.Split(ip, ".")[0]

heartBeatTime := time.Time{}
if store.Status.LastHeartbeatTS > 0 {
Expand All @@ -502,8 +515,8 @@ func (stmm *storeMemberManager) getKVStore(store *pdapi.StoreInfo) *v1alpha1.KVS
}

return &v1alpha1.KVStore{
ID: storeID,
// PodName: podName,
ID: storeID,
PodName: podName,
IP: ip,
LeaderCount: int32(store.Status.LeaderCount),
State: state,
Expand Down

0 comments on commit 1b778da

Please sign in to comment.