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

Check the Pod when we delete the volume #87

Merged
merged 4 commits into from
Jul 13, 2018
Merged

Check the Pod when we delete the volume #87

merged 4 commits into from
Jul 13, 2018

Conversation

hwchiu
Copy link
Contributor

@hwchiu hwchiu commented Jul 12, 2018

  • Add a new function in the kuberntes package. DoesPodCompleted which return false if the phase of Pod is pending or running.
  • Check the Pod when we wan to remove the volume. if there're at least Pod not complete, we can't remove the volume.

@codecov-io
Copy link

codecov-io commented Jul 12, 2018

Codecov Report

Merging #87 into develop will increase coverage by 2.21%.
The diff coverage is 79.16%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #87      +/-   ##
===========================================
+ Coverage    69.68%   71.89%   +2.21%     
===========================================
  Files           32       33       +1     
  Lines         1260     1427     +167     
===========================================
+ Hits           878     1026     +148     
- Misses         324      333       +9     
- Partials        58       68      +10
Impacted Files Coverage Δ
src/volume/volume.go 92% <76.47%> (-8%) ⬇️
src/kubernetes/pods.go 86.36% <85.71%> (-0.31%) ⬇️
src/networkprovider/network.go 100% <0%> (ø) ⬆️
src/networkprovider/fake.go 100% <0%> (ø) ⬆️
src/networkprovider/ovs_system.go 76.92% <0%> (ø)
src/server/handler_network.go 86.89% <0%> (+3.11%) ⬆️
src/networkcontroller/network_controller.go 46.95% <0%> (+3.83%) ⬆️
src/networkprovider/ovs_netdev.go 79.77% <0%> (+4.77%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1eec4d1...1f42819. Read the comment docs.

@@ -33,3 +33,13 @@ func (kc *KubeCtl) DeletePod(name string) error {
options := metav1.DeleteOptions{}
return kc.Clientset.CoreV1().Pods(kc.Namespace).Delete(name, &options)
}

func (kc *KubeCtl) DoesPodCompleted(pod *corev1.Pod) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about IsPodCompleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

vscode都會建議 error message 不要大寫開頭,我們要統一嗎?
https://github.com/golang/go/wiki/CodeReviewComments#error-strings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, 好唷

@hwchiu hwchiu merged commit 6758cf2 into develop Jul 13, 2018
@hwchiu hwchiu deleted the hwchiu/VX-111 branch July 13, 2018 10:29
John-Lin pushed a commit that referenced this pull request Jul 25, 2018
Check the Pod when we delete the volume

Former-commit-id: 8bd9d4fc9803d6d80400a08651f4e3a2d5b5d198 [formerly 6758cf2]
Former-commit-id: df99e4fb65b85633f89bc150713c3fc6dd975c11
John-Lin pushed a commit that referenced this pull request Jul 25, 2018
Check the Pod when we delete the volume

Former-commit-id: 8bd9d4fc9803d6d80400a08651f4e3a2d5b5d198 [formerly 8bd9d4fc9803d6d80400a08651f4e3a2d5b5d198 [formerly 6758cf2]]
Former-commit-id: df99e4fb65b85633f89bc150713c3fc6dd975c11
Former-commit-id: b77a6ee
John-Lin pushed a commit that referenced this pull request Jul 25, 2018
Check the Pod when we delete the volume
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants