Skip to content

Commit

Permalink
Add replication factor as env to jiva controller (#388)
Browse files Browse the repository at this point in the history
Add replication factor as env to jiva controller

Signed-off-by: kmova <[email protected]>
  • Loading branch information
kmova authored and prateekpandey14 committed Jul 12, 2018
1 parent 8acd08b commit 58254da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions orchprovider/k8s/v1/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package v1

import (
"fmt"
"strconv"
"strings"

"github.com/golang/glog"
Expand Down Expand Up @@ -877,6 +878,20 @@ func (k *k8sOrchestrator) createControllerDeployment(volProProfile volProfile.Vo
ctrlLabelSpec[string(v1.ApplicationSelectorKey)] = appLV
}

//The replication count will be specified as REPLICATION_FACTOR
// ENV for jiva controller. The controller will use this value
// to determine if quorum is available for making volume as read-write.
// For example,
// - if replication factor is 1, volume will be marked as RW when one replica connects
// - if replication factor is 3, volume will be marked as RW when when atleast 2 replica connect
// Similar logic will be applied to turn the volume into RO, when qorum is lost.
//Note: When kubectl scale up/down is done for replica deployment,
// this ENV on controller deployment needs to be patched.
rCount, err := volProProfile.ReplicaCount()
if err != nil {
return nil, err
}

deploy := &k8sApisExtnsBeta1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: vsm + string(v1.ControllerSuffix),
Expand Down Expand Up @@ -925,6 +940,12 @@ func (k *k8sOrchestrator) createControllerDeployment(volProProfile volProfile.Vo
k8sApiV1.Container{
Name: vsm + string(v1.ControllerSuffix) + string(v1.ContainerSuffix),
Image: cImg,
Env: []k8sApiV1.EnvVar{
k8sApiV1.EnvVar{
Name: string(v1.ReplicationFactorEnvKey),
Value: strconv.Itoa(int(*rCount)),
},
},
Command: v1.JivaCtrlCmd,
Args: v1.MakeOrDefJivaControllerArgs(vsm, clusterIP),
Ports: []k8sApiV1.ContainerPort{
Expand Down
3 changes: 3 additions & 0 deletions types/v1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,9 @@ const (
// PortNameAPI is the name given to api ports
PortNameAPI JivaAnnotations = "api"

// ReplicationFactorEnvKey is the name used to pass replica count as env
ReplicationFactorEnvKey JivaAnnotations = "REPLICATION_FACTOR"

// JivaCtrlIPHolder is used as a placeholder for persistent volume controller's
// IP address
//
Expand Down

0 comments on commit 58254da

Please sign in to comment.