Skip to content

Commit

Permalink
Rename function and checn the error message
Browse files Browse the repository at this point in the history
Former-commit-id: 76405e78151f16b2c44fc12dc043f097f843b337 [formerly 76405e78151f16b2c44fc12dc043f097f843b337 [formerly 1f42819]]
Former-commit-id: 970a5ee3d2adf600c829d704cf9d43f49b21bf9a
Former-commit-id: 5230692
  • Loading branch information
hwchiu committed Jul 13, 2018
1 parent 744f565 commit e704346
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/kubernetes/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (kc *KubeCtl) DeletePod(name string) error {
return kc.Clientset.CoreV1().Pods(kc.Namespace).Delete(name, &options)
}

func (kc *KubeCtl) DoesPodCompleted(pod *corev1.Pod) bool {
func (kc *KubeCtl) IsPodCompleted(pod *corev1.Pod) bool {
switch pod.Status.Phase {
case corev1.PodRunning, corev1.PodPending:
return false
Expand Down
4 changes: 2 additions & 2 deletions src/kubernetes/pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ func (suite *KubeCtlPodTestSuite) TestDoesPodCompleted() {
suite.NoError(err)
}

run := suite.kubectl.DoesPodCompleted(&pods[0])
run := suite.kubectl.IsPodCompleted(&pods[0])
suite.False(run)

run = suite.kubectl.DoesPodCompleted(&pods[1])
run = suite.kubectl.IsPodCompleted(&pods[1])
suite.True(run)
}

Expand Down
6 changes: 3 additions & 3 deletions src/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func DeleteVolume(sp *serviceprovider.Container, volume *entity.Volume) error {
pods := []entity.Pod{}
err := session.FindAll(entity.PodCollectionName, bson.M{"volumes.name": volume.Name}, &pods)
if err != nil {
return fmt.Errorf("Load the database fail:%v", err)
return fmt.Errorf("load the database fail:%v", err)
}

usedPod := []string{}
Expand All @@ -75,13 +75,13 @@ func DeleteVolume(sp *serviceprovider.Container, volume *entity.Volume) error {
continue
}

if !sp.KubeCtl.DoesPodCompleted(currentPod) {
if !sp.KubeCtl.IsPodCompleted(currentPod) {
usedPod = append(usedPod, pod.Name)
}
}
if len(usedPod) != 0 {
podNames := strings.Join(usedPod, ",")
return fmt.Errorf("Delete the volume [%s] fail, since the followings pods still ust it: %s", volume.Name, podNames)
return fmt.Errorf("delete the volume [%s] fail, since the followings pods still ust it: %s", volume.Name, podNames)
}

return sp.KubeCtl.DeletePVC(volume.GetPVCName())
Expand Down

0 comments on commit e704346

Please sign in to comment.