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

Show role when choosing database #54

Open
slootjes opened this issue Apr 9, 2024 · 8 comments
Open

Show role when choosing database #54

slootjes opened this issue Apr 9, 2024 · 8 comments

Comments

@slootjes
Copy link
Contributor

slootjes commented Apr 9, 2024

When using Port 7777 on an RDS cluster with multiple instances the output looks something like this:

Listing databases.
Which database would you like to connect to?

[1] some-service-databaseinstance1-azznqqajdhkm
[2] some-service-databaseinstance2-cqtwprntcl09

but based on this names I don't know which of the 2 is a reader or a writer. When making changes I obviously need a writer and while just doing some queries I prefer using a reader instance. Currently I always need to login to AWS to see which one I need. It would be very nice to see the role of the instance in this selection, perhaps like this:

Listing databases.
Which database would you like to connect to?

[1] some-service-databaseinstance1-azznoqajd0km (Writer instance)
[2] some-service-databaseinstance2-cqtwprbtdl09 (Reader instance)

While writing this, maybe also add the instance size to it as well:

Listing databases.
Which database would you like to connect to?

[1] some-service-databaseinstance1-azznoqajd0km (Writer instance / Serverless v2 (0.5 - 16 ACUs))
[2] some-service-databaseinstance2-cqtwprbtdl09 (Reader instance / tg4.medium)

What do you think?

@mnapoli
Copy link
Member

mnapoli commented Apr 9, 2024

Sounds like a great improvement idea, thanks for opening this. Naive question: is the reader/writer status exposed via the RDS API?

In any case I'm taking note of the idea (no promise on an implementation date ^^)

@slootjes
Copy link
Contributor Author

The information is returned in the describe db clusters API endpoint which is already used as far as I know by this app, this is the relevant output for my cluster:

<DBClusterMembers>
	<DBClusterMember>
		<DBInstanceIdentifier>some-service-databaseinstance1-azznoqajd0km</DBInstanceIdentifier>
		<DBClusterParameterGroupStatus>in-sync</DBClusterParameterGroupStatus>
		<PromotionTier>1</PromotionTier>
		<IsClusterWriter>true</IsClusterWriter>
	</DBClusterMember>
	<DBClusterMember>
		<DBInstanceIdentifier>some-service-databaseinstance2-cqtwprbtdl09</DBInstanceIdentifier>
		<DBClusterParameterGroupStatus>in-sync</DBClusterParameterGroupStatus>
		<PromotionTier>1</PromotionTier>
		<IsClusterWriter>false</IsClusterWriter>
	</DBClusterMember>
</DBClusterMembers>

The "IsClusterWriter" returns the relevant information if it's read/write or read only.

The instance type is available in the Describe Db Instances API call:

<DBInstanceClass>db.serverless</DBInstanceClass>

Maybe returning it as a table would be prettier even when adding more information.

@slootjes
Copy link
Contributor Author

slootjes commented Sep 4, 2024

Any update on this by any chance? The same thing applies for Elasticache:

Which Elasticache instance would you like to connect to?

[1] blr12bzer1fbecf1-001
[2] blr12bzer1fbecf1-002
[3] blrhen961d1ou3l-001
[4] blrhen961d1ou3l-002

Here it doesn't even show the name, only the identifier given by AWS. The same information would be useful here, especially the description and role (primary/replica).

@slootjes
Copy link
Contributor Author

slootjes commented Nov 6, 2024

Any news on this? Please let me know if there is a way for me to contribute, I don't think this should be difficult.

@mnapoli
Copy link
Member

mnapoli commented Nov 6, 2024

@slootjes no update at the moment.

Here is the relevant code if you want to have a go at it: https://gist.github.com/mnapoli/ea2300ed9496784ac91addefa183fd4f

The small challenge is that the prompt's selected result === what is displayed. So if we add more info to each line (e.g. the name, etc.), then when the user selects the line we get the whole string back.

@slootjes
Copy link
Contributor Author

slootjes commented Nov 6, 2024

Thanks for this :) The easy way out would be to have something like "{option} - {extra usefull stuff}" and then split/trim on the - and use the first part?

@mnapoli
Copy link
Member

mnapoli commented Nov 6, 2024

Oh yeah why not actually! Splitting on some character could work

@slootjes
Copy link
Contributor Author

slootjes commented Nov 6, 2024

I do see that the cluster ID being such a random name is because the ID is optional in CloudFormation and I didn't set one, this is not a bug in Port 7777. It would be very nice though to also get the description (which I did fill in) but I understand if this is a problem of my own :) The reader/writer (or primary/replace) would be most useful to know still.

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

No branches or pull requests

2 participants