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

Add replication factor as env to jiva controller #388

Merged
merged 2 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
20 changes: 20 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,19 @@ 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, this ENV needs to be patched.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When kubectl scale up/down is done to the Replica deployment, this ENV i.e. 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 +939,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