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

Web: Improve RDS enrollment flow #44671

Merged
merged 1 commit into from
Aug 1, 2024
Merged

Web: Improve RDS enrollment flow #44671

merged 1 commit into from
Aug 1, 2024

Conversation

kimlisa
Copy link
Contributor

@kimlisa kimlisa commented Jul 26, 2024

part of #44366
part of #41004

recommend reviewing by commit

🛑 requires e2e once all the required backend changes are done:

Improvements:

  • rds flow does not default to auto discovery
  • for self-hosted, separated configuring discovery service into it's own step
  • added a vpc selector before showing a list of rds databases
  • when opting for auto enrolling, the rds table will now show both rds instances and clusters (since auto enrolling enrolls all rds types)
  • added subnet selector in the auto deploying service
  • auto enrolling will now also allow selecting both security groups and subnets
  • fixed a bug where when checking for databases already enrolled for single enrollment, not all existing databases came back from the query b/c we didn't account for duplicates (which can happen when user single enrolls a db, then auto enrolls), fixed by removing limit

Test plan:

  • self hosted rds flow single enrollment
  • self hosted rds flow auto enrollment (check proper event emit)
  • cloud rds flow single enrollment
  • cloud rds flow auto enrollment (check proper event emit)
  • ec2 ssm self-hosted flow (since the discovery config file got touched)

Story locations for all the changes made in this PR:

changelog: Improve web UI enroll RDS flow where VPC, subnets, and security groups are now selectable

@github-actions github-actions bot requested review from ravicious and rudream July 26, 2024 07:16
@public-teleport-github-review-bot

@kimlisa - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes.

This comment was marked as resolved.

Copy link
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

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

I reviewed the first three commits, I'll continue the review tomorrow.

Copy link
Member

@ravicious ravicious left a comment

Choose a reason for hiding this comment

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

Looks good, I left more minor comments, mostly around the use of useEffect.

There is a bunch of logic in there that seems to be related to the subject matter (deploying stuff on AWS) that I didn't verify very thoroughly.

<Flex>
<ButtonPrimary mr={3} width="50%" onClick={retry}>
<Flex gap={3} width="100%">
<ButtonPrimary style={{ flex: 1 }} onClick={retry}>
Copy link
Member

Choose a reason for hiding this comment

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

Ah damn, I didn't realize <Button> doesn't support flex as an arg. Long term it'd definitely be a good idea to add this.

Comment on lines 99 to 124
if (selectedSubnetIds.length === 0) {
setHasNoSubnets(true);
return;
} else {
setHasNoSubnets(false);
}
Copy link
Member

Choose a reason for hiding this comment

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

It feels like long term it'd be good to have a way to include this validation within validator.validate(). Otherwise we're going to end up with dozens of places doing such validations by hand while they could be using a dedicated mechanism for this instead.

Comment on lines +35 to +39
<Toggle
isToggled={wantAutoDiscover}
onToggle={toggleWantAutoDiscover}
disabled={disabled}
>
Copy link
Member

Choose a reason for hiding this comment

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

There's a lot of flashing when this toggle is clicked. For example, I shouldn't see "No results" for a split second when switching between toggle states. Presumably it's because of those extra effects used in AutoEnrollment and SingleEnrollment that I mentioned. Maybe addressing them will make the UI feel more stable as well.

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 made it less jumpy, but couldn't resolve why no results keep showing up before the actual data, it's strange, these are the render ticks. the table for some reason gets an empty item first, then the data comes on next render...

it's like setDataTable gets partially updated (because the fetchStatus: disabled is updated but not the items)...

image

@kimlisa kimlisa requested a review from ravicious July 31, 2024 07:52
/>
)}
{showVpcSelector && !hasVpcs && (
<P mt={-3}>
Copy link
Member

Choose a reason for hiding this comment

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

No worries, it's a minor thing in the grand scheme of things. It only becomes a problem when you want to reuse the component in different contexts where the hardcoded margins might not be necessary.

@kimlisa kimlisa force-pushed the lisa/improve-rds-flow branch from 6ea394c to 9649082 Compare July 31, 2024 20:30
@kimlisa
Copy link
Contributor Author

kimlisa commented Aug 1, 2024

ping @rudream

</P3>
)}
<P3>
{`${selectedSubnetIds.length} ${pluralize(selectedSubnetIds.length, 'subnet')} selected`}
Copy link
Member

Choose a reason for hiding this comment

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

FYI, I just submitted this small PR which fixes my mistake in pluralize. ;) #44949

Since the count is no longer hidden behind a zero check, AFAIK it should say "0 subnets selected" instead of "0 subnet selected".

Comment on lines 120 to 131
The security groups you pick must meet the following requirements:
<ul>
<li>
all security groups must allow outbound connectivity (eg:
0.0.0.0/0) to reach Teleport cluster
</li>
<li>
all security groups must allow inbound connectivity from the ECS
task security group or from the ECS task subnet(s) CIDR blocks
</li>
</ul>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The security groups you pick must meet the following requirements:
<ul>
<li>
all security groups must allow outbound connectivity (eg:
0.0.0.0/0) to reach Teleport cluster
</li>
<li>
all security groups must allow inbound connectivity from the ECS
task security group or from the ECS task subnet(s) CIDR blocks
</li>
</ul>
Select security group(s) based on the following requirements:
<ul>
<li>
The selected security group(s) must allow all outbound traffic
(eg: 0.0.0.0/0)
</li>
<li>
A security group attached to your database(s) must allow inbound
traffic from a security group you select or from all IPs in the
subnets you selected
</li>

Security groups are additive, so only one of the ECS task security groups needs to allow (0.0.0.0/0) outbound.
No inbound rules are needed for these either, but the databases' security groups need to allow inbound from the ECS task.

Comment on lines 137 to 139
running the database access agent. If you don't select any security
groups, the default one for the VPC will be used.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we make security group selection a requirement instead of optional?

I think it will be better to make the user think about and pick a security group than let them skip an optional step and then likely have to troubleshoot a failing deployment


<Text mb={2}>
Select subnets to assign to the Fargate service that will be running the
database access agent. All of the subnets you select must have an
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
database access agent. All of the subnets you select must have an
Teleport Database Service. All of the subnets you select must have an

disabled={disabled}
>
<Box ml={2} mr={1}>
Auto-enroll all databases for selected region
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Auto-enroll all databases for selected region
Auto-enroll all databases for the selected region

Copy link
Collaborator

@r0mant r0mant left a comment

Choose a reason for hiding this comment

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

🎉

@kimlisa kimlisa force-pushed the lisa/improve-rds-flow branch from 93641ef to 584821c Compare August 1, 2024 21:16
- user selects a vpc to see RDS's
- restrict deploying service to user selected vpc
- allow and require selecting subnets and security groups
- refactor EnrollRdsDatabase.tsx into SingleEnrollment and AutoEnrollment
- for self hosted, move configuring discovery config into own step
- fixes a query bug where not all db servers were returning because
  possible duplicates were not accounted for (fixed by removing limit,
  default limit is 1k which should be plenty)
@kimlisa kimlisa force-pushed the lisa/improve-rds-flow branch from 584821c to 6c96447 Compare August 1, 2024 21:32
@kimlisa kimlisa added this pull request to the merge queue Aug 1, 2024
Merged via the queue into master with commit c9489b5 Aug 1, 2024
38 checks passed
@kimlisa kimlisa deleted the lisa/improve-rds-flow branch August 1, 2024 21:53
@public-teleport-github-review-bot

@kimlisa See the table below for backport results.

Branch Result
branch/v16 Failed

@kimlisa kimlisa mentioned this pull request Aug 6, 2024
kimlisa added a commit that referenced this pull request Aug 22, 2024
- user selects a vpc to see RDS's
- restrict deploying service to user selected vpc
- allow and require selecting subnets and security groups
- refactor EnrollRdsDatabase.tsx into SingleEnrollment and AutoEnrollment
- for self hosted, move configuring discovery config into own step
- fixes a query bug where not all db servers were returning because
  possible duplicates were not accounted for (fixed by removing limit,
  default limit is 1k which should be plenty)
kimlisa added a commit that referenced this pull request Aug 22, 2024
- user selects a vpc to see RDS's
- restrict deploying service to user selected vpc
- allow and require selecting subnets and security groups
- refactor EnrollRdsDatabase.tsx into SingleEnrollment and AutoEnrollment
- for self hosted, move configuring discovery config into own step
- fixes a query bug where not all db servers were returning because
  possible duplicates were not accounted for (fixed by removing limit,
  default limit is 1k which should be plenty)
github-merge-queue bot pushed a commit that referenced this pull request Aug 22, 2024
* Web: Improve RDS enrollment flow (#44671)

- user selects a vpc to see RDS's
- restrict deploying service to user selected vpc
- allow and require selecting subnets and security groups
- refactor EnrollRdsDatabase.tsx into SingleEnrollment and AutoEnrollment
- for self hosted, move configuring discovery config into own step
- fixes a query bug where not all db servers were returning because
  possible duplicates were not accounted for (fixed by removing limit,
  default limit is 1k which should be plenty)

* Web: Improve RDS flow 2 (#45179)

* Don't default to auto discover
* Allow redpeploy when auto deploying and improve pending deploy hints
* Allow overwrite existing dbs and skip on heartbeat timeout during enrollment
* Remove allowing custom labels
* Emit rest of discovery config event

* Remove blocking if db_service exists for a vpc

Previously intended to determine if user already auto enrolled,
but now that single and auto enrollment sets the same kind of
labels for db_service, there is no distinction and can let
user be blocked incorrectly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants