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

Draft: Adds services capabilities #638

Closed
wants to merge 7 commits into from
Closed

Conversation

Markcial
Copy link

@Markcial Markcial commented Apr 26, 2021

Fixes #173

Hi, this is a draft MR. Will need some more work

The network is created and removed by name, causing collisions, and it is created only once, I am not sure if that is the right setup, maybe it might be needed to be different on each job.

Containers and services should be included on that network, it's done here but maybe there is a better way. This MR also lacks proper testing, some advice on this would be good.

The configuration on the services are done in a hacky way, they should have properly merged environment settings, and some other configuration values.

I can help on any further changes or if you feel that someone else can't take better care of it feel free to modify it.

Thanks for this project

Copy link
Member

@catthehacker catthehacker left a comment

Choose a reason for hiding this comment

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

Anything else looks good to me!

Comment on lines 187 to 200
const defaultNetwork = "act_github_actions_network"

func (rc *RunContext) createNetwork() common.Executor {
return func(ctx context.Context) error {
return container.NewDockerNetworkCreateExecutor(defaultNetwork)(ctx)
}
}

func (rc *RunContext) removeNetwork() common.Executor {
return func(ctx context.Context) error {
return container.NewDockerNetworkRemoveExecutor(defaultNetwork)(ctx)
}
}

Copy link
Member

Choose a reason for hiding this comment

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

If another workflow references same services, there will be a clash.
Perhaps network should be named act-<workflow-name>-network

c.Pull(false),
c.Create(),
c.Start(false),
c.ConnectToNetwork(defaultNetwork),
Copy link
Member

Choose a reason for hiding this comment

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

Network name clash.

rc.JobContainer.Create(),
rc.JobContainer.Start(false),
rc.JobContainer.ConnectToNetwork(defaultNetwork),
Copy link
Member

Choose a reason for hiding this comment

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

Network name clash.

@cplee cplee added the needs-work Extra attention is needed label May 3, 2021
if err != nil {
return err
}
fmt.Printf("%#v", network.ID)
Copy link
Member

Choose a reason for hiding this comment

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

Please use log instead of fmt, we should limit fmt only to formatting strings

Copy link
Author

Choose a reason for hiding this comment

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

Oh sorry, it was a rogue line, my apologies

pkg/runner/run_context.go Outdated Show resolved Hide resolved
pkg/runner/runner_test.go Outdated Show resolved Hide resolved
Co-authored-by: Ryan (hackercat) <me@hackerc.at>
pkg/runner/runner_test.go Outdated Show resolved Hide resolved
@catthehacker
Copy link
Member

It seems that it created 5 different act-test-network networks

[basic/build]   🐳  docker pull node:12.20.1-buster-slim
time="2021-05-04T09:27:22Z" level=debug msg="Image exists? true"
[basic/build] Removed container: 6648844bde9265313d5fed13c0dbeaded7745c5deb5db238bb8ee514bf595278
[basic/build]   🐳  docker volume rm act-basic-build
[basic/build]   🐳  docker create image=node:12.20.1-buster-slim platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[basic/build] Created container name=act-basic-build id=d2af12ba6bb5dee3e5133bf1c8690d62ffc99b46397813da006a6b0d056e5570 from image node:12.20.1-buster-slim (platform: )
[basic/build] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_TEMP=/tmp]
[basic/build]   🐳  docker run image=node:12.20.1-buster-slim platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[basic/build] Starting container: d2af12ba6bb5dee3e5133bf1c8690d62ffc99b46397813da006a6b0d056e5570
[basic/build] Started container: d2af12ba6bb5dee3e5133bf1c8690d62ffc99b46397813da006a6b0d056e5570
[basic/build]   🐳  docker network connect act-build-network act-basic-build
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
--- FAIL: TestRunEventPullRequest (0.80s)
    runner_test.go:226: assertion failed: error is not nil: Error response from daemon: network act-build-network is ambiguous (5 matches found on name): pull-request

@Markcial
Copy link
Author

Markcial commented May 4, 2021

It seems that it created 5 different act-test-network networks

[basic/build]   🐳  docker pull node:12.20.1-buster-slim
time="2021-05-04T09:27:22Z" level=debug msg="Image exists? true"
[basic/build] Removed container: 6648844bde9265313d5fed13c0dbeaded7745c5deb5db238bb8ee514bf595278
[basic/build]   🐳  docker volume rm act-basic-build
[basic/build]   🐳  docker create image=node:12.20.1-buster-slim platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[basic/build] Created container name=act-basic-build id=d2af12ba6bb5dee3e5133bf1c8690d62ffc99b46397813da006a6b0d056e5570 from image node:12.20.1-buster-slim (platform: )
[basic/build] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_TEMP=/tmp]
[basic/build]   🐳  docker run image=node:12.20.1-buster-slim platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[basic/build] Starting container: d2af12ba6bb5dee3e5133bf1c8690d62ffc99b46397813da006a6b0d056e5570
[basic/build] Started container: d2af12ba6bb5dee3e5133bf1c8690d62ffc99b46397813da006a6b0d056e5570
[basic/build]   🐳  docker network connect act-build-network act-basic-build
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
time="2021-05-04T09:27:23Z" level=debug msg="Error response from daemon: network act-build-network is ambiguous (5 matches found on name)"
--- FAIL: TestRunEventPullRequest (0.80s)
    runner_test.go:226: assertion failed: error is not nil: Error response from daemon: network act-build-network is ambiguous (5 matches found on name): pull-request

Yes, this was one of my concerns, I was investigating on how to have the network ID, because do the operations just with the network name is a bit flaky.

I have a busy week, but if you can wait until next monday I can dig on this

@catthehacker
Copy link
Member

I kind of resolved it but then stuck with issue of too much IP ranges allocated

@mergify
Copy link
Contributor

mergify bot commented May 4, 2021

@Markcial this pull request is now in conflict 😩

@mergify mergify bot added the conflict PR has conflicts label May 4, 2021
@mergify
Copy link
Contributor

mergify bot commented May 4, 2021

@Markcial this pull request has failed checks 🛠

@catthehacker
Copy link
Member

thank you bot, I know that -.-

@Markcial
Copy link
Author

Markcial commented May 5, 2021

If you get something let me know, as I can't get to it before next monday.

I have an idea about using the network identifier to keep track on the networks and how to specifically remove them. But until I get some spare time I won't be able to try it.

Thanks for getting some time into it

@Markcial Markcial requested a review from a team as a code owner May 5, 2021 07:16
Co-authored-by: Ryan (hackercat) <me@hackerc.at>
@catthehacker
Copy link
Member

https://github.com/catthehacker/act-fork/tree/ticket-173
There is a lot in there unrelated changes as well (since I've a bad habit of going on refactoring spree when looking through code)

@Markcial
Copy link
Author

Markcial commented May 5, 2021

https://github.com/catthehacker/act-fork/tree/ticket-173
There is a lot in there unrelated changes as well (since I've a bad habit of going on refactoring spree when looking through code)

Well don't worry, at least it's something to check for ideas, thanks

@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2021

PR is stale and will be closed in 14 days unless there is new activity

@github-actions github-actions bot added the stale label Jun 5, 2021
@catthehacker catthehacker self-assigned this Jun 5, 2021
@github-actions github-actions bot closed this Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflict PR has conflicts needs-work Extra attention is needed size/L stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Services not working
3 participants