Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP]feat:add support for additional config #82

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1/curvecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ type EtcdSpec struct {
ClientPort int `json:"clientPort,omitempty"`

// +optional
Config map[string]string `json:"config,omitempty"`
Config map[string]int `json:"config,omitempty"`
}

// MdsSpec is the spec of mds
Expand Down
7 changes: 7 additions & 0 deletions config/samples/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ spec:
peerPort: 23800
# clientPort for listening server port.
clientPort: 23790
config:
snapshot-count: "10000"
heartbeat-interval: "80"
election-timeout: "1000"
quota-backend-bytes: "0"
max-snapshots: "5"
max-wals: "5"
mds:
port: 6700
dummyPort: 7700
Expand Down
27 changes: 27 additions & 0 deletions pkg/daemon/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ type NodeInfo struct {
ReplicasSequence int
PeerPort int // etcd
ClientPort int // etcd
SnapshotCount int // etcd
HeartbeatInterval int // etcd
ElectionTimeout int // etcd
QuotaBackendBytes int // etcd
MaxSnapshots int // etcd
MaxWals int // etcd
MdsPort int // mds
DummyPort int // mds
SnapshotClonePort int // snapshotclone
Expand All @@ -27,6 +33,9 @@ func ConfigureNodeInfo(c *Cluster) ([]NodeInfo, error) {

var (
peerPort, clientPort int
snapshotCount, heartbeatInterval int
electionTimeout, quotaBackendBytes int
maxSnapshots, maxWals int
mdsPort, dummyPort int
snapshotClonePort, snapshotCloneDummyPort, snapshotCloneProxyPort int
metaserverPort, metaserverExternalPort int
Expand All @@ -43,6 +52,12 @@ func ConfigureNodeInfo(c *Cluster) ([]NodeInfo, error) {
replicasSequence++
peerPort++
clientPort++
snapshotCount++
heartbeatInterval++
electionTimeout++
quotaBackendBytes++
maxSnapshots++
maxWals++
mdsPort++
dummyPort++
snapshotClonePort++
Expand All @@ -54,6 +69,12 @@ func ConfigureNodeInfo(c *Cluster) ([]NodeInfo, error) {
replicasSequence = 0
peerPort = c.Etcd.PeerPort
clientPort = c.Etcd.ClientPort
snapshotCount = c.Etcd.Config["snapshot-count"]
heartbeatInterval = c.Etcd.Config["heartbeat-interval"]
electionTimeout = c.Etcd.Config["election-timeout"]
quotaBackendBytes = c.Etcd.Config["quota-backend-bytes"]
maxSnapshots = c.Etcd.Config["max-snapshots"]
maxWals = c.Etcd.Config["max-wals"]
mdsPort = c.Mds.Port
dummyPort = c.Mds.DummyPort
snapshotClonePort = c.SnapShotClone.Port
Expand All @@ -70,6 +91,12 @@ func ConfigureNodeInfo(c *Cluster) ([]NodeInfo, error) {
ReplicasSequence: replicasSequence,
PeerPort: peerPort,
ClientPort: clientPort,
SnapshotCount: snapshotCount,
HeartbeatInterval: heartbeatInterval,
ElectionTimeout: electionTimeout,
QuotaBackendBytes: quotaBackendBytes,
MaxSnapshots: maxSnapshots,
MaxWals: maxWals,
MdsPort: mdsPort,
DummyPort: dummyPort,
SnapshotClonePort: snapshotClonePort,
Expand Down
22 changes: 14 additions & 8 deletions pkg/etcd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ var _ config.ConfigInterface = &etcdConfig{}

// etcdConfig for a single etcd
type etcdConfig struct {
Prefix string
ServiceRole string
ServiceHostSequence string
ServiceReplicaSequence string
ServiceAddr string
ServicePort string
ServiceClientPort string
ClusterEtcdHttpAddr string
Prefix string
ServiceRole string
ServiceHostSequence string
ServiceReplicaSequence string
ServiceAddr string
ServicePort string
ServiceClientPort string
ServiceSnapshotCount string
ServiceHeartbeatInterval string
ServiceElectionTimeout string
ServiceQuotaBackendBytes string
ServiceMaxSnapshots string
ServiceMaxWals string
ClusterEtcdHttpAddr string

ResourceName string
CurrentConfigMapName string
Expand Down
22 changes: 14 additions & 8 deletions pkg/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,20 @@ func (c *Cluster) Start(nodesInfo []daemon.NodeInfo) ([]*topology.DeployConfig,
resourceName := fmt.Sprintf("%s-%s", AppName, daemonIDString)
currentConfigMapName := fmt.Sprintf("%s-%s", ConfigMapNamePrefix, daemonIDString)
etcdConfig := &etcdConfig{
Prefix: prefix,
ServiceRole: config.ROLE_ETCD,
ServiceHostSequence: strconv.Itoa(node.HostID),
ServiceReplicaSequence: strconv.Itoa(node.ReplicasSequence),
ServiceAddr: node.NodeIP,
ServicePort: strconv.Itoa(node.PeerPort),
ServiceClientPort: strconv.Itoa(node.ClientPort),
ClusterEtcdHttpAddr: initialCluster,
Prefix: prefix,
ServiceRole: config.ROLE_ETCD,
ServiceHostSequence: strconv.Itoa(node.HostID),
ServiceReplicaSequence: strconv.Itoa(node.ReplicasSequence),
ServiceAddr: node.NodeIP,
ServicePort: strconv.Itoa(node.PeerPort),
ServiceClientPort: strconv.Itoa(node.ClientPort),
ServiceSnapshotCount: strconv.Itoa(node.SnapshotCount),
ServiceHeartbeatInterval: strconv.Itoa(node.HeartbeatInterval),
ServiceElectionTimeout: strconv.Itoa(node.ElectionTimeout),
ServiceQuotaBackendBytes: strconv.Itoa(node.QuotaBackendBytes),
ServiceMaxSnapshots: strconv.Itoa(node.MaxSnapshots),
ServiceMaxWals: strconv.Itoa(node.MaxWals),
ClusterEtcdHttpAddr: initialCluster,

DaemonID: daemonIDString,
CurrentConfigMapName: currentConfigMapName,
Expand Down
10 changes: 9 additions & 1 deletion pkg/etcd/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,15 @@ func (c *Cluster) makeEtcdDaemonContainer(nodeName string, ip string, etcdConfig
Protocol: v1.ProtocolTCP,
},
},
Env: []v1.EnvVar{{Name: "TZ", Value: "Asia/Hangzhou"}},
Env: []v1.EnvVar{
{Name: "TZ", Value: "Asia/Hangzhou"},
{Name: "ETCD_SNAPSHOT_COUNT", Value: etcdConfig.ServiceSnapshotCount},
{Name: "ETCD_HEARTBEAT_INTERVAL", Value: etcdConfig.ServiceHeartbeatInterval},
{Name: "ETCD_ELECTION_TIMEOUT", Value: etcdConfig.ServiceElectionTimeout},
{Name: "ETCD_QUOTA_BACKEND_BYTES", Value: etcdConfig.ServiceQuotaBackendBytes},
{Name: "ETCD_MAX_SNAPSHOTS", Value: etcdConfig.ServiceMaxSnapshots},
{Name: "ETCD_MAX_WALS", Value: etcdConfig.ServiceMaxWals},
},
}
return container
}