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

wait for dev pod to terminate #674

Merged
merged 6 commits into from
Feb 12, 2020
Merged

wait for dev pod to terminate #674

merged 6 commits into from
Feb 12, 2020

Conversation

rberrelleza
Copy link
Member

Fixes #664

Proposed changes

  • Wait for dev pod to be marked for termination before exiting okteto down

@codecov
Copy link

codecov bot commented Feb 11, 2020

Codecov Report

Merging #674 into master will increase coverage by 0.35%.
The diff coverage is 78.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #674      +/-   ##
==========================================
+ Coverage   38.23%   38.59%   +0.35%     
==========================================
  Files          42       43       +1     
  Lines        3588     3620      +32     
==========================================
+ Hits         1372     1397      +25     
- Misses       2136     2141       +5     
- Partials       80       82       +2
Impacted Files Coverage Δ
cmd/down.go 0% <0%> (ø) ⬆️
pkg/cmd/down/wait.go 76.92% <76.92%> (ø)
pkg/k8s/pods/pod.go 11.04% <90%> (+2.66%) ⬆️

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 0108d9f...d157d5b. Read the comment docs.

cmd/down.go Outdated
@@ -181,3 +194,14 @@ func stopSyncthing(dev *model.Dev) {
log.Infof("failed to delete existing syncthing folder")
}
}

func waitForDevPodTermination(c kubernetes.Interface, p *v1.Pod) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we wait for all pods with label interactive.dev.okteto.com: dev.Name or detached.dev.okteto.com: dev.Name?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, let me look into this. there are a couple other issues as well.

// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package down
Copy link
Member Author

Choose a reason for hiding this comment

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

I created this package to start moving logic outside of the main package, following kubectl's pattern. I think it's easier if we leave the user-interaction stuff in main (cmd parsing, param matching, input - output) and start moving the logic to packages like this.


wg := &sync.WaitGroup{}

waitForDevPodsTermination(c, d.Namespace, interactive, wg, t)
Copy link
Contributor

Choose a reason for hiding this comment

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

missing calling it as a goroutine?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes


waitForDevPodsTermination(c, d.Namespace, interactive, wg, t)
if len(d.Services) > 0 {
waitForDevPodsTermination(c, d.Namespace, detached, wg, t)
Copy link
Contributor

Choose a reason for hiding this comment

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

same

for i := 0; i < t; i++ {
ps, err := pods.ListBySelector(namespace, selector, c)
if err != nil {
log.Infof("failed to get dev pods with selector %s, exiting: %s", selector, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

if not found I wouldn't log anything. Try running "okteto down" two times in a row

Copy link
Member Author

Choose a reason for hiding this comment

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

pods.ListBySelector only returns an error if client-go returns an error. if there aren't any pods it's all fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

@rberrelleza rberrelleza merged commit 1b9d4d5 into master Feb 12, 2020
@rberrelleza rberrelleza deleted the wait-on-down branch February 12, 2020 08:22
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.

"okteto down" does not wait for dev pod termination
2 participants