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 dns update workflow #289

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

Genne23v
Copy link
Contributor

@Genne23v Genne23v commented Mar 1, 2023

Close #270

This PR adds DNS update workflow as below.

  1. Update the record by ID in DB with PENDING status
  2. Upsert the record in Route53
  3. Repeat polling Route53 until it gets the updated status (INSYNC or something else)
  4. Update the DB either with active or error

To test this, it needs manual steps as below.

Create a hostedZone using unit test dns.server.test.ts. If you run all test, it will remove hostedZone. Run partial test.
Get hostedZoneId from localhost:5053/moto-api and set AWS_ROUTE53_HOSTED_ZONE_ID
Set ROOT_DOMAIN to starchart.com
Go to http://localhost:8080/dev and add a request button with proper request body properties. DB Record ID must be included.

@Genne23v Genne23v self-assigned this Mar 1, 2023
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

A general comment, after quickly scanning the code in this PR. For DNS, doing Create, Update, and Delete is all very similar. Instead of creating separate queues/workers for each of these, can we create a single set of queues/workers that take the operation, etc. to run (e.g., create vs. update) and are able to run any of the jobs like this?

I think we should be able to use/leverage the existing queues/workers you already created.

@Genne23v
Copy link
Contributor Author

Genne23v commented Mar 1, 2023

I think we should be able to use/leverage the existing queues/workers you already created.

I did some testing to reuse existing worker, somehow it didn't work as expected. Actually only checkDnsStatus would be identical and the rest would be little different. I will spend more time to reduce the repeated worker/queue.

@humphd
Copy link
Contributor

humphd commented Mar 1, 2023

The way you'd do it is to have your worker be more elaborate, and include all the logic of each case. You'd send a arg with the job data that tells it what to do:

For example:

// Names are made up, don't read anything into them...
export async function genericWorker(job: DnsJob) {
  const { type, ...data } = job.data;

  switch(type) {
    case 'create':
      return doCreate(data); 
    case 'update':
      return doUpdate(data); 
    case 'delete':
      return doDelete(data); 
  }
}

@Genne23v Genne23v added this to the Milestone 0.5 milestone Mar 3, 2023
@Genne23v Genne23v added category: DNS A service about hosting domains category: queue A service that connects and manages certificate creation/expiration category: data Anything related to data management and structure labels Mar 3, 2023
@Genne23v Genne23v requested review from humphd and Myrfion March 3, 2023 20:06
@humphd humphd mentioned this pull request Mar 7, 2023
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Can you rebase this on main so it is easier to test? Also I created #298 to make it easier to deal with dns record creation for a user (i.e., we can just use the initial part of a name vs. the entire thing).

app/queues/dns/dns-record-worker.server.ts Outdated Show resolved Hide resolved
@humphd
Copy link
Contributor

humphd commented Mar 7, 2023

@Genne23v that wasn't a rebase, you added those commits in by mistake.

@Genne23v
Copy link
Contributor Author

Genne23v commented Mar 7, 2023

@Genne23v that wasn't a rebase, you added those commits in by mistake.

Sorry, my bad. I'm fixing it now.

@Genne23v Genne23v requested a review from humphd March 7, 2023 16:56
app/queues/dns/dns-flow.server.ts Outdated Show resolved Hide resolved
app/queues/dns/dns-flow.server.ts Show resolved Hide resolved
app/queues/dns/dns-record-worker.server.ts Outdated Show resolved Hide resolved
app/queues/dns/dns-record-worker.server.ts Outdated Show resolved Hide resolved
app/queues/dns/dns-record-worker.server.ts Outdated Show resolved Hide resolved
app/routes/dev.tsx Outdated Show resolved Hide resolved
app/routes/dev.tsx Outdated Show resolved Hide resolved
@Genne23v
Copy link
Contributor Author

Genne23v commented Mar 8, 2023

@humphd @Myrfion I just updated the PR. Sorry that I force pushed. Please note that I haven't refactored the code to separate DB update and Route53 update in this PR. I think the refactoring amount is very big for this one PR. I will quickly push another PR once this gets merged.

@Genne23v Genne23v requested review from humphd and Myrfion March 8, 2023 21:03
SerpentBytes
SerpentBytes previously approved these changes Mar 9, 2023
@humphd humphd requested a review from a user March 9, 2023 18:58
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Are you going to do the switch to create/update the record in the DB when you add it to the queue vs. when the worker starts? I think you should, so that the front-end can rely on the record existing early.

app/models/record.server.ts Outdated Show resolved Hide resolved
app/queues/dns/dns-flow.server.ts Outdated Show resolved Hide resolved
app/queues/dns/dns-record-worker.server.ts Outdated Show resolved Hide resolved
app/routes/__index/domains/new.tsx Show resolved Hide resolved
@Genne23v
Copy link
Contributor Author

@humphd I did a quick prototype to see how it should work and considered to add it to this PR, but the amount of refactoring is very big. So I changed my mind to do that separation in next release. If it needs to be in this iteration, I will update the PR.

@humphd
Copy link
Contributor

humphd commented Mar 10, 2023

@humphd I did a quick prototype to see how it should work and considered to add it to this PR, but the amount of refactoring is very big. So I changed my mind to do that separation in next release. If it needs to be in this iteration, I will update the PR.

That makes sense to me, but you didn't mention it in the PR. It's good to call out plans like that, and even better to file follow-up issues to clearly communicate intent.

app/utils.ts Show resolved Hide resolved
@Genne23v
Copy link
Contributor Author

Here's the issue number for follow-up. #315

@Genne23v Genne23v requested a review from humphd March 10, 2023 13:36
humphd
humphd previously approved these changes Mar 10, 2023
Copy link
Contributor

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Thanks for filing that issue.

app/utils.ts Show resolved Hide resolved
Myrfion
Myrfion previously approved these changes Mar 10, 2023
@SerpentBytes SerpentBytes self-requested a review March 10, 2023 14:36
Copy link
Contributor

@SerpentBytes SerpentBytes left a comment

Choose a reason for hiding this comment

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

I left some feedback. In issue #311, we request to replace the logic related to manipulating dates with built-in functions from dayjs, as it does it in fewer lines of code. While this PR is still open, could you use that library instead?

@Genne23v Genne23v merged commit b9107ee into DevelopingSpace:main Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: data Anything related to data management and structure category: DNS A service about hosting domains category: queue A service that connects and manages certificate creation/expiration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create DNS Flow skeleton like Certs Flow
4 participants