Skip to content

Use multiple registry fallbacks instead of one#1246

Merged
s-ludwig merged 4 commits intodlang:masterfrom
wilzbach:more-fallbacks
Nov 6, 2017
Merged

Use multiple registry fallbacks instead of one#1246
s-ludwig merged 4 commits intodlang:masterfrom
wilzbach:more-fallbacks

Conversation

@wilzbach
Copy link
Contributor

As we already see sometimes errors on Travis while downloading the installer script due to dlang.org and nightlies.dlang.org being down, it's imho a good idea to have multiple fallbacks by default for DUB.

https://code-mirror2.dlang.io is maintained by myself and the Heroku-App is based on dlang/dub-registry#231

@dlang-bot
Copy link
Collaborator

Thanks for your pull request, @wilzbach!

@wilzbach
Copy link
Contributor Author

Btw we didn't we simply add a list of RegistryPackageSuppliers as default?
A lot of the methods of Dub look like this:

foreach(ps; m_packageSuppliers){
	try {
		auto versions = ps.getVersions(p);

Doing the fallbacking as "Meta" supplier as done now and improved by this PR and within the class itself seems redundant.

Copy link
Member

@MartinNowak MartinNowak left a comment

Choose a reason for hiding this comment

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

As we already see sometimes errors on Travis while downloading the installer script due to dlang.org and nightlies.dlang.org being down, it's imho a good idea to have multiple fallbacks by default for DUB.

Any concrete example?
You can't fix all network issues, in particular when they are on bigger links.
The nightly nginx runs uninterrupted since 8 months, the nightly build server has an uptime of 1.5 years. It runs on OVH's networks which has nothing in common with dlang.org.

code.dlang.org is located in Germany (seems to peer via Level3 in Düsseldorf)
code-mirror.dlang.io runs on OVH/France
code-mirror2.dlang.io seems to run in some DC in texas (Incero), but uses the same DNS as code-mirror.dlang.io (another failure point, e.g. misconfiguration)
dub-registry.herokuapp.com runs on Heroku (AWS US-East)

So indeed adding 2 US based fallbacks seems sensible.

@MartinNowak
Copy link
Member

Btw we didn't we simply add a list of RegistryPackageSuppliers as default?

This was discussed in the original PR, #1190 (comment).

@s-ludwig
Copy link
Member

Is it possible to set up a CNAME record for codemirror3.dlang.io that points to the Heroku app, or do they do any internal dispatching based on the original name? It would be good to keep a central place where the mirrors can be replaced/removed, so that we don't have to rely on application updates until such modifications take effect.

@wilzbach
Copy link
Contributor Author

Is it possible to set up a CNAME record for codemirror3.dlang.io that points to the Heroku app, or do they do any internal dispatching based on the original name?

Custom CNames are free at Heroku, but SSL for them isn't. We could, however, setup a wildcard redirect. dlang.io can be managed via Namecheap - I will invite you later today.

@s-ludwig
Copy link
Member

A wildcard redirect would work. Regarding switching to HTTPS for code.dlang.org. As a simple first step we could have ["https://code.dlang.org/", "http://code.dlang.org/", ...] to provide the fallback in case any client has problems with HTTPS.

@wilzbach
Copy link
Contributor Author

but uses the same DNS as code-mirror.dlang.io (another failure point, e.g. misconfiguration)

@s-ludwig I added the Heroku App as code-mirror3.dlang.io, but I have to agree with @MartinNowak: by using the Heroku DNS, we have another fallback in case NameCheap has some issues (also wildcard redirect don't seem to be possible directly with NameCheap)

But I did add "http://code.dlang.org/" as a fallback if SSL isn't supported and fixed the Travis errors for 2.066 (as GDC is at 2.074.0 in master and 2.068.0 with their last release, we could drop the support for 2.066)

@s-ludwig
Copy link
Member

Alternatively, we could add some other mechanism for maintaining the mirror list in the future, such as requesting an up-to-date one from code.dlang.org, which would ideally be signed to avoid a worthwhile security target. BTW, package signing is also something we should also put on the (virtual) higher priority list as the eco system keeps growing.

@MartinNowak
Copy link
Member

Let's not sweat this too much, adding a few mirrors is nice as it might help with certain issues.
But this mirror thing isn't a replacement for a proper HA setup (or PaaS) in the long-term.

Copy link
Member

@MartinNowak MartinNowak left a comment

Choose a reason for hiding this comment

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

Just nits, lets move on with this.

{
return format("%s (fallback %s)", m_default.description, m_fallback.description);
import std.algorithm : map;
return format("%s (fallback %s)", m_default.description, m_fallbacks.map!(x => x.description));
Copy link
Member

Choose a reason for hiding this comment

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

Not a blocker, but this is fairly long and detailed.

==== registry at https://code.dlang.org/ (fallback ["registry at http://code.dlang.org/", "registry at https://code-mirror.dlang.io/", "registry at https://code-mirror2.dlang.io/", "registry at https://dub-registry.herokuapp.com/"]) ====

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know, but the PackageSupplier interface currently only supports a description attribute. We could add sth. like location in a follow-up?

try
return m_fallback.%1$s(args);
catch(Throwable)
assert(1);
Copy link
Member

Choose a reason for hiding this comment

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

Isn't {} what you should use for an empty statement?

Copy link
Member

Choose a reason for hiding this comment

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

More importantly, Throwable is a bad idea, must be Exception - logging the error with logDiagnostic or maybe just logDebug could also be important for remote debugging .

catch(Throwable)
assert(1);
}
return m_fallbacks.back.%1$s(args);
Copy link
Member

Choose a reason for hiding this comment

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

The recursive structure was setup to chain exceptions, so that users get a list of unreachable sites. Not too important though.

new FallbackPackageSupplier(
new RegistryPackageSupplier(URL(defaultRegistryURL)),
new RegistryPackageSupplier(URL(fallbackRegistryURL))
fallbackRegistryURLs.map!(x => cast(PackageSupplier) new RegistryPackageSupplier(URL(x))).array
Copy link
Member

Choose a reason for hiding this comment

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

Could have stayed with the recursive structure.

fallbackRegistryURLs.reduce!((agg, url) => new FallbackPackageSupplier(agg, new RegistryPackageSupplier(URL(x))))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I thought the "linear" way is more intuitive, but I don't really mind. If you feel strongly the recursive structure, feel free to change it back.

@wilzbach
Copy link
Contributor Author

wilzbach commented Oct 5, 2017

Just nits, lets move on with this.

Addressed the nits.

The recursive structure was setup to chain exceptions, so that users get a list of unreachable sites. Not too important though.

Don't they get this with logDebug as well?
Anyhow as mentioned before if you prefer the recursive way, feel free to change.
In any case it would be great to get this in before the next release.

@s-ludwig s-ludwig merged commit 1237487 into dlang:master Nov 6, 2017
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.

4 participants