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

feat: introduce the logic to list/promote/stop squids #5

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

juanmahidalgo
Copy link
Collaborator

This PR create the endpoints to:

  • /list all the squid services that have been started and their statuses.

and also adds some functions for the feature to :

  • stop an indexer
  • promote an indexer

This two endpoints entrypoints will be added in a following up PR.

}

const token = authHeader.slice(7); // Extract token after 'Bearer '
const expectedToken = process.env.AUTH_TOKEN;

Choose a reason for hiding this comment

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

What do you think about grabbing this environment variable from the config component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

auth-middleware removed entirely

import { Network } from "@dcl/schemas";

const AWS_REGION = "us-east-1";
const CLUSTER_NAME = process.env.CLUSTER_NAME || "dev-main";

Choose a reason for hiding this comment

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

What do you think about grabbing this environment from the config component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good idea, done!

-- Fetch the old schema name from the squids table
SELECT schema INTO old_schema_name
FROM squids
WHERE name = 'marketplace';

Choose a reason for hiding this comment

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

Is this supposed to be fixed to marketplace?

}
}

async function stop(serviceName: string): Promise<void> {

Choose a reason for hiding this comment

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

If I'm not wrong, by exporting the stop function, the lifecycle mechanism of the components will run it upon termination. Would you mind checking if we need to change the name of the funcion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good call, renamed!

next: () => Promise<IHttpServerComponent.IResponse>
): Promise<IHttpServerComponent.IResponse> {
// Validate Authorization header
const authHeader = context.request.headers.get("Authorization");

Choose a reason for hiding this comment

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

If we're hardcoding the bearer token in one of our static UIs, we must take into consideration that those UIs are packaged and deployed to NPM before being uploaded to the CDN, carrying the token with them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

auth middleware removed entirely!

if: ${{ always() }}
- name: test
run: npm run test
- name: integration test

Choose a reason for hiding this comment

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

It would be great to do integration tests over the promotion process, but, as of today, I would remove the integration tests step that will make the job fail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed for the moment!

id: deploy
uses: decentraland/dcl-deploy-action@main
with:
dockerImage: "quay.io/decentraland/squid-management-server-:${{ inputs.tag }}"

Choose a reason for hiding this comment

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

removed dash: "quay.io/decentraland/squid-management-server:${{ inputs.tag }}"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good call, done!

.env.default Outdated

HTTP_SERVER_PORT=5001
HTTP_SERVER_HOST=0.0.0.0
AWS_CLUSTER_NAME=dev-main

Choose a reason for hiding this comment

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

why dev-main?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to just pick a name, as an example, I changed to blank but it's not that important IMO

config: IConfigComponent;
}): Promise<ISquidComponent> {
const cluster: string =
(await config.getString("CLUSTER_NAME")) || "dev-main";

Choose a reason for hiding this comment

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

why dev-main here? could we fail if CLUSTER_NAME is empty?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to requireString to ensure it has value or it explodes.


const serviceArns = servicesResponse.serviceArns || [];
const squidServices = serviceArns.filter((arn) =>
arn.includes("squid-server")

Choose a reason for hiding this comment

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

could it be "-squid-server-" ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to avoid which cases?

Choose a reason for hiding this comment

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

to make sure there is a project name before and a server A or B afterwards

Copy link

@charly-bg charly-bg Nov 13, 2024

Choose a reason for hiding this comment

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

also to avoid case: "squid-servers-a" with extra "s"

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