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

Ability to block until deploy and port-forward are finished #4022

Open
cpoole opened this issue Apr 24, 2020 · 9 comments
Open

Ability to block until deploy and port-forward are finished #4022

cpoole opened this issue Apr 24, 2020 · 9 comments
Labels
area/portforward area/testing Issues concerning the testing phase of Skaffold kind/feature-request priority/awaiting-more-evidence Lowest Priority. May be useful, but there is not yet enough supporting evidence.

Comments

@cpoole
Copy link

cpoole commented Apr 24, 2020

Expected behavior

For usage in CI pipelines (specifically integration testing) it would be nice if there was an easy way to do skaffold run --port-forward and not have it hang indefinitely. Instead it would simply block until all port forwards have been completed.

Currently I run skaffold run then manually create the port forwards, but now I've got these port forward definitions duplicated.

Is this a feature anyone else is interested in? Is there some easier or already existing way to accomplish this?

@tstromberg tstromberg added area/portforward kind/feature-request priority/awaiting-more-evidence Lowest Priority. May be useful, but there is not yet enough supporting evidence. labels Apr 24, 2020
@tstromberg
Copy link
Contributor

What do you mean by block until port forwards have been completed?

The tricky part, AFAIK, is that the port-forward process has to keep running. Are you suggesting that it daemonizes them?

@briandealwis briandealwis added the area/testing Issues concerning the testing phase of Skaffold label Apr 25, 2020
@briandealwis
Copy link
Member

You can use the events API to be notified of established port-forwards.

We'd like to hear more about how you're doing testing, however! This is an area we'd like to improve in Skaffold.

@cpoole
Copy link
Author

cpoole commented Apr 26, 2020

Yes, I think daemonizing them would be ideal. Let me explain my current workflow:

  • git trigger to jenkins + spin up new node
  • bootstrap new node by installing kind
  • skaffold run to install my app in kind
  • little dumb bash script to find all of the services spun up by skaffold and fork a kubectl port-forward for each of them (append PID's to a file).
  • run my integration tests against the stack in kind
  • kill all the pid's
  • kill kind

Pretty standard test cycle imo. What I'd like to see is some sort of option for skaffold to daemonize those port forwards and then know how to properly kill them with some other command skaffold delete --port-forwards or something like that.

Effectively mimic the behavior of running docker-compose up -d and then docker-compose down after tests.

@cpoole
Copy link
Author

cpoole commented Apr 26, 2020

Listening to the events is probably fine @briandealwis . I imagine id just fork a skaffold dev and block while listening. Is there an event for "all forwards done"?

Another way to solve this would be sort of skaffold test pipeline where we could pass in an arbitrary set of commands for skaffold to run after finishing a standard skaffold dev. But I've seen resistance (understandably) into making skaffold a generic workflow engine.

@tejal29
Copy link
Member

tejal29 commented Jun 15, 2020

Currently we don't have an event for Portforward completed.
We do have a an event for DevLoopEvent complete which can indicate when an entire devloop is complete which is sent after following phases are complete

  1. Build,
  2. Deploy,
  3. Status check - if --status-check is true
  4. port forwarding complete - if --port-forward is true.

Can you try that ?

@nkubala
Copy link
Contributor

nkubala commented Jul 15, 2020

@cpoole FWIW skaffold test is still in consideration as a potential phase, and I think you'd be able to accomplish what you need here with it.

cc #992

@gnarea
Copy link

gnarea commented Nov 18, 2020

I think the feature proposed here offers a better way to run a functional test suite in CI, and I don't see myself using skaffold test for the reasons here: #992 (comment)

As a workaround, I'm having to run skaffold run and then manually call kubectl port-forward for each port I need to access from the tests: https://github.com/relaycorp/relaynet-internet-gateway/blob/2eae4449267a5ecdab85c62ae2c0bfe27458cdd0/.github/workflows/ci-cd.yml#L42-L66

@tejal29 tejal29 added planning/Q4-21 Q4 2021 planning and removed planning/Q4-21 Q4 2021 planning labels Jun 4, 2021
@tejal29
Copy link
Member

tejal29 commented Jun 4, 2021

We have plans to improve skaffold test later in the year.
this could also been done via hooks #1441 that @gsquared94 is implementing.

@gsquared94 do you have an idea if post deploy hooks will run after port-forwarfing is stable ?

@ethanmdavidson
Copy link

The post-deploy hook appears to run before the port-forwarding is stable, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/portforward area/testing Issues concerning the testing phase of Skaffold kind/feature-request priority/awaiting-more-evidence Lowest Priority. May be useful, but there is not yet enough supporting evidence.
Projects
None yet
Development

No branches or pull requests

7 participants