Page MenuHomePhabricator

[CI] Use a random port for the website preview
ClosedPublic

Authored by Fabien on Apr 11 2023, 14:11.

Details

Reviewers
sdulfari
Group Reviewers
Restricted Project
Commits
rABC512d1605ccaa: [CI] Use a random port for the website preview
Summary

And write the generated preview URL to both stdout and a log file so it can be later retrieved by the build bot. The IP used is localhost if it's not running on a Teamcity build agent, and the public IP otherwise. To achieve that, the whatismyip package is used.
The port is randomly selected in a range free of known use.

Test Plan
./contrib/teamcity/build-configurations.py preview-e.cash

Check the preview URL is working as expected.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Apr 11 2023, 14:11

Use the same message for both stdout and the log

sdulfari added a subscriber: sdulfari.
sdulfari added inline comments.
contrib/teamcity/build-configurations.py
205 ↗(On Diff #39548)

Nit: This does not check if outer_port is available. To dodge this you could something like: outer_port = 41000 + hour_of_the_day * 100 + int(self.project_commit) % 100 but this does seem complicated. Only marked as a nit since this is expected to be distributed over multiple machines, so collisions are not very likely at our current rate of website changes.

This revision is now accepted and ready to land.Apr 11 2023, 17:32
contrib/teamcity/build-configurations.py
205 ↗(On Diff #39548)

That complicated computation doesn't prevent picking a port that's already in use either. My expectation is that the range is large enough wrt the number of calls and the number of agents that it doesn't really matter. If we start getting collisions we can always rework this.