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 language-specific instructions to the "Connect to the Cluster" doc #6077

Merged
merged 11 commits into from
Jan 8, 2020

Conversation

Amruta-Ranade
Copy link
Contributor

@Amruta-Ranade Amruta-Ranade commented Nov 26, 2019

Addresses #5738

To-Do: Replicate changes to 20.1 docs

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@Amruta-Ranade
Copy link
Contributor Author

@jseldess @mjibson I need help with the formatting on this page:
http://cockroach-docs-review.s3-website-us-east-1.amazonaws.com/a430755e5838c1703c0bb26db7ba8d735aa70cc9/cockroachcloud/stable/cockroachcloud-connect-to-your-cluster.html#use-a-postgres-driver-or-orm

What I want to do is make the "Python" section be pre-clicked and expanded by default. But as of now, the user needs to click one of the languages to expand the sections. My research says that the reason is that the previous section ("Use the CockroachDB client") also has section selectors, and only one section selector can be "active" at a time on a page. Is this something you have seen before? Any ideas on how to fix this?

@jseldess
Copy link
Contributor

jseldess commented Dec 3, 2019 via email

@Amruta-Ranade
Copy link
Contributor Author

Hmm..the divs/sections trick didn't work. I like the idea of replacing the Mac/Linux toggles with bullet points. Going with it for now. Thanks, Jesse!

Copy link
Contributor

@jseldess jseldess left a comment

Choose a reason for hiding this comment

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

Nice progress, @Amruta-Ranade. I'm a bit concerned about providing just the connection string code fragment without explicitly mentioning prerequisites, like installing the driver or ORM. I'm still wondering whether it will be more helpful to CC devs to have a full "hello world" sample from which they can easily extract the details they need. Thoughts?

If you prefer to move forward with this approach for now, I'd like you to have a developer run through this for real, pretending to be a beginner, before I give my review.

Some other issues issues:

  • Reading through, it's strange to me that step 3 (generating the connection string) is not in the context of step 4 (connect to the cluster). You need to choose specific options in step 3 for step 4. Can you think about this more?
  • I think all of the bullets nested under number steps are not rendering correctly.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jseldess)

Copy link

@laurenbarker laurenbarker left a comment

Choose a reason for hiding this comment

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

Everything worked as expected!
(also worth noting that this is the first time I've connected to one of my dbs)

For the "Use a Postgres driver or ORM" step I followed the "Node.js pg driver" instructions to test it out. The actual code I used:

// connect-test.js

const fs = require("fs");
const { Client } = require("pg");

// copied config from tutorial and added password
const config = {...};

const client = new Client(config);

client.connect();
console.log("connected");

client.query("SELECT NOW()", (err, res) => {
  console.log(err, res);

  client.end();
  console.log("disconnected");
});

@@ -94,7 +94,7 @@ On the machine from which you want to connect to your cluster:

The **Connect** tab is displayed.

<img src="{{ 'images/v19.1/cockroachcloud/connect-tab.png' | relative_url }}" alt="Connect to cluster" style="border:1px solid #eee;max-width:100%" />
<img src="{{ 'images/v19.2/cockroachcloud/connect-tab.png' | relative_url }}" alt="Connect to cluster" style="border:1px solid #eee;max-width:50%" />

6. Select a connection option:

Choose a reason for hiding this comment

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

The order of the tabs on the connection modal has recently been updated (CockroachDB Client is the default now).

// Connect to the "bank" database.
var config = {
user: '<username>',
host: '<region>.<cluster_name>',

Choose a reason for hiding this comment

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

I think my host was <cluster_name>.<region>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh..that's strange. Our parameter tab displays the <region_name>.<cluster_name> format.
Screen Shot 2019-12-03 at 5 09 04 PM

Can you confirm what should the correct format?

Choose a reason for hiding this comment

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

Oh interesting...mine is the opposite. Maybe just <host> then?

connect-params

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Woah..that's weird! Let's ask on Slack if this is an issue or if it's okay to have two formats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed: Both are correct, but differ based on version. <host> might be the safest way to go.

~~~ js
// Connect to CockroachDB through Sequelize.
var sequelize = new Sequelize('<database_name>', '<username>', '<password>', {
host: '<region>.<cluster_name>',

Choose a reason for hiding this comment

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

Same here --<cluster_name>.<region>

conn = psycopg2.connect(
user='<username>',
password='<password>',
host='<region>.<cluster_name>',

Choose a reason for hiding this comment

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

Same here --<cluster_name>.<region>

On the machine where you want to run your application:
# Create an engine to communicate with the database. The "cockroachdb://" prefix
# for the engine URL indicates that we are connecting to CockroachDB.
engine = create_engine('cockroachdb://<username>:<password>@<region>.<cluster_name>:26257/<database>?sslmode=verify-full&sslrootcert=<absolute path to CA certificate>')

Choose a reason for hiding this comment

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

Same here --<cluster_name>.<region>

~~~ go

// Connect to the database.
const addr = "postgresql://<username>:<password>@<region>.<cluster_name>:26257/<database>?sslmode=verify-full&sslrootcert=<absolute path to CA certificate>"

Choose a reason for hiding this comment

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

Same here --<cluster_name>.<region>

2. Run the code:
// Configure the database connection.
PGSimpleDataSource ds = new PGSimpleDataSource();
ds.setServerName("<region>.<cluster_name>");

Choose a reason for hiding this comment

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

Same here --<cluster_name>.<region>

//Database connection settings
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL95Dialect</property>
<property name="hibernate.connection.url"><![CDATA[jdbc:postgresql://<username>:<password>@<region>.<cluster_name>:26257/<database>?sslmode=verify-full&sslrootcert=<absolute path to CA certificate]]></property>

Choose a reason for hiding this comment

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

Same here --<cluster_name>.<region>

{{site.data.alerts.callout_info}}
The [CockroachDB Python package](https://github.com/cockroachdb/cockroachdb-python) installed earlier is triggered by the `cockroachdb://` prefix in the engine URL. Using `postgres://` to connect to your cluster will not work.
{{site.data.alerts.end}}
// Connect to the "bank" database.

Choose a reason for hiding this comment

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

What does "bank" database mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah..included it by mistake. Fixed.

The [CockroachDB Python package](https://github.com/cockroachdb/cockroachdb-python) installed earlier is triggered by the `cockroachdb://` prefix in the engine URL. Using `postgres://` to connect to your cluster will not work.
{{site.data.alerts.end}}
// Connect to the "bank" database.
var config = {

Choose a reason for hiding this comment

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

I had to add password to the config to get it to connect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Good catch. Fixed.

{% include copy-clipboard.html %}
~~~ shell
$ sudo cp -i cockroach-{{ page.release_info.version }}.linux-amd64/cockroach /usr/local/bin/
~~~
</section>

3. Use the `cockroach sql` command to open an interactive SQL shell, replacing placeholders in the [client connection string](#step-3-generate-the-connection-string) with the correct username, password, and path to the `ca.cert`:

Choose a reason for hiding this comment

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

Forgot one. Looks like the connection strings below missed the certs/ca.crt to <path to the CA certificate> update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

@Amruta-Ranade
Copy link
Contributor Author

Excellent feedback @laurenbarker! Thank you so much!

1 similar comment
Copy link
Contributor

@jseldess jseldess left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, @Amruta-Ranade. I didn't know you were ready for a re-review. In the future, please mention me in a comment once you're ready.

LGTM, with a few nits. I still find steps 3 and 4 a bit confusing, but let's go with this for now.

Also, you

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Amruta-Ranade and @laurenbarker)


v19.2/cockroachcloud-connect-to-your-cluster.md, line 37 at r8 (raw file):

5. From the **Network** dropdown, select:

         - **New Network** to authorize your application server’s network or application server’s network. Enter the public IPv4 address of the machine in the **Network** field.

These bullets aren't rendering properly. Please fix.

Screen Shot 2020-01-03 at 7.59.35 PM.png


v19.2/cockroachcloud-connect-to-your-cluster.md, line 47 at r8 (raw file):

      {{site.data.alerts.end}}

      If you need to add a range of IP addresses, use the CIDR (Classless Inter-Domain Routing) notation.

nit: If you need to add > To add. Also, no reason for this sentence to be its own paragraph. Please make it the first sentence of the following paragraph.


v19.2/cockroachcloud-connect-to-your-cluster.md, line 79 at r8 (raw file):

## Step 3. Select a connection method

On the machine from which you want to connect to your cluster:

This intro doesn't make sense for all cases. For example, you might grab the connection string on your laptop but then use it in app code running on a server. Do you think this intro is necessary?


v19.2/cockroachcloud-connect-to-your-cluster.md, line 151 at r8 (raw file):

    ~~~

3. Use the `cockroach sql` command to open an interactive SQL shell, replacing placeholders in the [client connection string](#step-3-generate-the-connection-string) with the correct username, password, and path to the `ca.cert`:

This anchor link is broken.

@Amruta-Ranade Amruta-Ranade self-assigned this Jan 7, 2020
@Amruta-Ranade Amruta-Ranade changed the title [WIP] Add language-specific instructions to the "Connect to the Cluster" doc Add language-specific instructions to the "Connect to the Cluster" doc Jan 8, 2020
Copy link
Contributor Author

@Amruta-Ranade Amruta-Ranade left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Amruta-Ranade, @jseldess, and @laurenbarker)


v19.2/cockroachcloud-connect-to-your-cluster.md, line 99 at r5 (raw file):

Previously, laurenbarker (Lauren Barker) wrote…

The order of the tabs on the connection modal has recently been updated (CockroachDB Client is the default now).

Done.


v19.2/cockroachcloud-connect-to-your-cluster.md, line 37 at r8 (raw file):

Previously, jseldess (Jesse Seldess) wrote…

These bullets aren't rendering properly. Please fix.

Screen Shot 2020-01-03 at 7.59.35 PM.png

Done.


v19.2/cockroachcloud-connect-to-your-cluster.md, line 79 at r8 (raw file):

Previously, jseldess (Jesse Seldess) wrote…

This intro doesn't make sense for all cases. For example, you might grab the connection string on your laptop but then use it in app code running on a server. Do you think this intro is necessary?

Done.


v19.2/cockroachcloud-connect-to-your-cluster.md, line 151 at r8 (raw file):

Previously, jseldess (Jesse Seldess) wrote…

This anchor link is broken.

Done.

@Amruta-Ranade Amruta-Ranade merged commit 216b37d into master Jan 8, 2020
@Amruta-Ranade Amruta-Ranade deleted the cc_connect_apps branch January 8, 2020 13:08
@Amruta-Ranade Amruta-Ranade moved this from In review to Done in Education sprint 16 (1/6 - 1/17) Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants