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

get connections from k8 #40

Merged
merged 20 commits into from
Sep 5, 2023
Merged

get connections from k8 #40

merged 20 commits into from
Sep 5, 2023

Conversation

alishakawaguchi
Copy link
Contributor

@alishakawaguchi alishakawaguchi commented Aug 31, 2023

Removes postgres and uses kubernetes for connection source

backend/.env.dev Outdated
@@ -8,3 +8,4 @@ WAIT_TIME_SECONDS=20

AUTH0_BASEURL=https://auth.nucleuscloud.dev
AUTH0_AUDIENCE=https://api.nucleuscloud.com
K8_NAMESPACE=neosync
Copy link
Member

Choose a reason for hiding this comment

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

can this be something a little more descriptive that makes it clear exactly what it's purpose is?
Something like job config namespace or job namespace. something like that.

Copy link
Member

Choose a reason for hiding this comment

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

Separately, I think we can get rid of the .env.dev stuff since we are using the Helm chart to populate everything. Downside is this can't be run on baremetal without it. Which maybe youre currently relying on.

Comment on lines 13 to 14
input neosyncdevv1alpha1.SqlConnection,
secret corev1.Secret,
Copy link
Member

Choose a reason for hiding this comment

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

I think you want these passed in as pointers.
Especially since the secret is technically optional

// ) *mgmtv1alpha1.ConnectionConfig {
// return nil
// }
url := string(secret.Data["url"])
Copy link
Member

Choose a reason for hiding this comment

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

Few things here:

  1. What if the value is defined directly in the input (sqlconnection)? secret might not be needed.
  2. The key for the secret is defined in the SqlConnection and might not be url.

// return nil
// }
url := string(secret.Data["url"])
connCfg, err := conn_utils.ParsePostgresUrl(url)
Copy link
Member

Choose a reason for hiding this comment

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

this works as long as we only support postgres. You probably dont want to make this check unless the SqlConnection.Spec.Driver is postgres.

Comment on lines 52 to 55
k8Namespace := viper.GetString("K8_NAMESPACE")
if k8Namespace == "" {
return nil, fmt.Errorf("must provide K8_NAMESPACE in environment")
}
Copy link
Member

Choose a reason for hiding this comment

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

Idk if this really belongs here. The namespace is used for R/W the JobConfigs and such and is more bizz logic.

Also, maybe if it's not provided we just default to default? That is a common thing for kubernetes. That would also be a sane default value at the helm chart layer too.

@@ -2,16 +2,30 @@ package v1alpha1_connectionservice

Copy link
Member

Choose a reason for hiding this comment

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

Ok, it's going to be easier to talk holistically about this here as there are a few things that I think need to be revised.

  1. I don't think we can always assume that every SqlConnection that comes out of K8s will contain a Secret. There could be some that use the Value directly, and the API should seamlessly support that.
  2. I am seeing a few assumptions that the SqlConnection will always be Postgres, which is of course the case now, but will quickly not be. It's really classified as a postgres connection if the driver specified says as such.
  3. I'm having some thoughts about the UUID label. Now that I'm seeing the code, it's making me think that the presence of it makes this api more brittle. I am thinking this because I'm coming from the place where I have manually created a JobConfig directly from yaml, and now just want to go into the app to see it. However, it won't work because it'll be filtered out!
    3.1 I wonder if the right thing to do here is to actually have the operator attach the uuid to it as a label. That way we can be sure it is always there, regardless of how the JobConfig arrived. Thoughts? Should be relatively straightforward to do. Then the backend can just look for it on all of the CRDs that are owned by the operator.
    3.1.1 The other option I think we talked about was to just use the name directly right? Hmm.

Copy link
Member

Choose a reason for hiding this comment

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

I'm also wondering about the case where we want to return a list of Connections, but maybe one has an invalid secret. What should we do there? Fail hard? Or maybe filter that one out? Or possibly return it but have it be in an invalid state perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. will fix
  2. will fix
  3. I think the operator should attach the uuid as a label. I prefer uuid over name

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'm also wondering about the case where we want to return a list of Connections, but maybe one has an invalid secret. What should we do there? Fail hard? Or maybe filter that one out? Or possibly return it but have it be in an invalid state perhaps?

I think the best user experience is probably return but have it in invalid state. That way they can see the issue and fix. Otherwise who knows what the real issue is

@alishakawaguchi alishakawaguchi self-assigned this Sep 1, 2023
@alishakawaguchi alishakawaguchi merged commit a7a73bc into main Sep 5, 2023
@alishakawaguchi alishakawaguchi deleted the alisha/k8 branch September 5, 2023 19:07
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.

2 participants