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

Add determineNetworkAlias function to simplify aliases creation #1617

Closed
wants to merge 22 commits into from

Conversation

pablomendezroyo
Copy link
Contributor

Add determineNetworkAlias function to simplify aliases creation

@pablomendezroyo pablomendezroyo requested a review from a team as a code owner September 26, 2023 12:41
@pablomendezroyo pablomendezroyo marked this pull request as draft September 26, 2023 12:41
@github-actions
Copy link

github-actions bot commented Sep 26, 2023

@github-actions
Copy link

github-actions bot commented Sep 26, 2023

DAppNode bot has built and pinned the release to an IPFS node, for commit: f7cb715

This is a development version and should only be installed for testing purposes, install link

/ipfs/QmfTECAFMwgChwfQZf4UxG7BqzdKg7LNUCsov7byxFgu6Y

(by dappnodebot/build-action)

@github-actions github-actions bot temporarily deployed to commit September 26, 2023 18:42 Inactive
@github-actions github-actions bot temporarily deployed to commit September 27, 2023 09:24 Inactive
@github-actions github-actions bot temporarily deployed to commit September 27, 2023 15:01 Inactive
@github-actions github-actions bot temporarily deployed to commit September 27, 2023 18:10 Inactive
@github-actions github-actions bot temporarily deployed to commit September 27, 2023 22:42 Inactive
@github-actions github-actions bot temporarily deployed to commit September 27, 2023 23:11 Inactive
@github-actions github-actions bot temporarily deployed to commit September 27, 2023 23:46 Inactive
packages/dappmanager/src/domains.ts Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to commit September 28, 2023 10:47 Inactive
packages/dappmanager/src/domains.ts Show resolved Hide resolved
@@ -35,7 +35,14 @@ export async function bitcoin(
): Promise<ChainDataResult> {
const container = dnp.containers[0];
if (!container) throw Error("no container");
const containerDomain = getPrivateNetworkAlias(container);

const {dnpName,serviceName} = container;
Copy link
Contributor

Choose a reason for hiding this comment

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

In order to avoid having to duplicate this code in every driver, I would add a function called build/generateNetworkAliasByPkg({service: string, pkg: InstalledPackageData})

It would check if the package is monoservice or the specified service is main to set the value of isMainOrMonoservice

Then, it would call build/generateNetworkAlias to get an available alias

dnpName: dnpName,
serviceName: dnpName

const containerDomain = determineNetworkAlias({
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not look 100% reliable. What if you call this function with a dnp name that is a multiservice with no main service?

@@ -38,19 +40,21 @@ export async function getEthConsClientApiUrl(dnpName: string): Promise<string> {
dnp.chain.serviceName
) {
port = dnp.chain.portNumber;
domain = getPrivateNetworkAlias({
domain = determineNetworkAlias({
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also call here build/generateNetworkAliasByPkg({service: string, pkg: InstalledPackageData})

Copy link
Contributor

Choose a reason for hiding this comment

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

dnp.chain.serviceName does not seem 100% reliable either

packages/dappmanager/src/domains.ts Show resolved Hide resolved
migrateCoreNetworkAndAliasInCompose(container, aliases);

// Adds aliases to the container network
for (const alias of aliases) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could try to avoid the loop here.

  1. Get the current alias in config
  2. Compare those to the new ones and leave only those to add
  3. Add them at the same time of possible

const containerName = container.containerName;

// Wifi and VPN containers need a refresh connect due to their own network configuration
if (containerName === params.vpnContainerName || containerName === params.wifiContainerName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure only those? Are both wireguard and OpenVPN considered here?

return Boolean(
endpointConfig &&
endpointConfig.Aliases &&
Array.isArray(endpointConfig.Aliases) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be just a string and not an array? Likely not, but just in case

@@ -26,41 +26,48 @@ export async function getOptimismConfig(): Promise<OptimismConfigGet> {

return {
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be here, you need to rebase carefully

const containers = [containerMain, containerNotMain, monoContainer, containerMainPublic, containerNotMainPublic, monoContainerPublic];

const CONTAINER_COMPOSE = `
version: '3.4'
Copy link
Contributor

Choose a reason for hiding this comment

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

Here you set version 3.4, but above you migrate to 3.5 right? Why is this? I might be missing something

@github-actions github-actions bot temporarily deployed to commit September 29, 2023 09:43 Inactive
@github-actions github-actions bot temporarily deployed to commit September 29, 2023 09:46 Inactive
@github-actions github-actions bot temporarily deployed to commit September 29, 2023 10:08 Inactive
@github-actions github-actions bot temporarily deployed to commit September 29, 2023 10:09 Inactive
@github-actions github-actions bot temporarily deployed to commit September 29, 2023 11:22 Inactive
@Marketen Marketen force-pushed the pablo/the-endless-issue branch from 1d11b3c to 3bb4f81 Compare October 2, 2023 09:24
@github-actions github-actions bot temporarily deployed to commit October 2, 2023 09:28 Inactive
@github-actions github-actions bot temporarily deployed to commit October 2, 2023 09:29 Inactive
@github-actions github-actions bot temporarily deployed to commit October 2, 2023 09:56 Inactive
@github-actions github-actions bot temporarily deployed to commit October 2, 2023 11:24 Inactive
@dappnodedev
Copy link
Contributor

Overridden by #1632

@dappnodedev dappnodedev closed this Oct 3, 2023
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.

3 participants