Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Commit

Permalink
add comment docs and make funcs private if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Jingtao Ren committed Jan 19, 2018
1 parent 2f8dc0d commit 34c3ac4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/apis/etcd/v1beta2/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ type PodPolicy struct {
// This field cannot be updated.
EtcdEnv []v1.EnvVar `json:"etcdEnv,omitempty"`

// PersistentVolumeClaimSpec ...
// PersistentVolumeClaimSpec is the spec to describe PVC for the etcd container
// This field is optional. If no PVC spec, etcd container will use emptyDir as volume
PersistentVolumeClaimSpec *v1.PersistentVolumeClaimSpec `json:"persistentVolumeClaimSpec,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (c *Cluster) setupServices() error {
return k8sutil.CreatePeerService(c.config.KubeCli, c.cluster.Name, c.cluster.Namespace, c.cluster.AsOwner())
}

func (c *Cluster) IsPodPVEnabled() bool {
func (c *Cluster) isPodPVEnabled() bool {
if podPolicy := c.cluster.Spec.Pod; podPolicy != nil {
return podPolicy.PersistentVolumeClaimSpec != nil
}
Expand All @@ -384,7 +384,7 @@ func (c *Cluster) IsPodPVEnabled() bool {

func (c *Cluster) createPod(members etcdutil.MemberSet, m *etcdutil.Member, state string) error {
pod := k8sutil.NewEtcdPod(m, members.PeerURLPairs(), c.cluster.Name, state, uuid.New(), c.cluster.Spec, c.cluster.AsOwner())
if c.IsPodPVEnabled() {
if c.isPodPVEnabled() {
pvc := k8sutil.NewEtcdPodPVC(m, *c.cluster.Spec.Pod.PersistentVolumeClaimSpec, c.cluster.Name, c.cluster.Namespace, c.cluster.AsOwner())
_, err := c.config.KubeCli.CoreV1().PersistentVolumeClaims(c.cluster.Namespace).Create(pvc)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (c *Cluster) removeMember(toRemove *etcdutil.Member) (err error) {
if err := c.removePod(toRemove.Name); err != nil {
return err
}
if c.IsPodPVEnabled() {
if c.isPodPVEnabled() {
err = c.removePVC(k8sutil.PVCNameFromMemberName(toRemove.Name))
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/k8sutil/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func GetPodNames(pods []*v1.Pod) []string {
return res
}

// PVCNameFromMemberName the way we get PVC name from the member name
func PVCNameFromMemberName(memberName string) string {
return memberName
}
Expand Down Expand Up @@ -249,6 +250,7 @@ func NewSeedMemberPod(clusterName string, ms etcdutil.MemberSet, m *etcdutil.Mem
return pod
}

// NewEtcdPodPVC create PVC object from etcd pod's PVC spec
func NewEtcdPodPVC(m *etcdutil.Member, pvcSpec v1.PersistentVolumeClaimSpec, clusterName, namespace string, owner metav1.OwnerReference) *v1.PersistentVolumeClaim {
pvc := &v1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 34c3ac4

Please sign in to comment.