Skip to content

Conversation

@DaedalusG
Copy link
Contributor

@DaedalusG DaedalusG commented Apr 26, 2023

Fixes https://github.com/sourcegraph/sourcegraph/issues/51175.

Ultimately this change is minor, but may prevent confusion.

The port name and targetPort name are not actually used for anything besides human readability to my knowledge and there are no known issues with the current manifest. This does bring things in line with the convention in use in codeinsights-db service file though, and will eliminate possible confusion by readers

Codeinsights manifest

Checklist

Test plan

Ultimately this change is minor, but may prevent confusion.

The port name and targetPort name are not actually used for anything besides human readability to my knowledge and there are no known issues with the current manifest. This does bring things in line with the convention in use in codeinsights-db service file though, and will eliminate possible confusion by readers

[Codeinsights manifest](https://sourcegraph.com/github.com/sourcegraph/deploy-sourcegraph-helm@release/5.0/-/blob/charts/sourcegraph/templates/codeinsights-db/codeinsights-db.Service.yaml?L23:5)
Copy link

@efritz efritz left a comment

Choose a reason for hiding this comment

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

Is this used in the deployment (or any other file) by name?

- name: codeintel-db
port: 5432
targetPort: pgsql
targetPort: codeintel-db
Copy link
Member

Choose a reason for hiding this comment

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

the target port does not seem rigth to me:

shouldn't it be psql?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shouldn't targetPort always match the name -- just for readability? Why would this case be different than the codeinsights-db case of the service manifest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any design reason we named the db container in codeintel-db pgsql that we know of?

Copy link
Member

@michaellzc michaellzc Apr 26, 2023

Choose a reason for hiding this comment

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

in svc port entry

spec:
  selector:
    app.kubernetes.io/name: MyApp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376

it basically says, forward any incoming traffic to this svc at 80 to pod with matching selector labels at 9376

so targetPort should match the port name or number at the POD

Copy link
Member

Choose a reason for hiding this comment

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

if we really want to use codeintel-db everywhere, we will need to rename the port name in statefulset pod template s well

@michaellzc
Copy link
Member

@efritz would you clarify how this could be confusing to users during debugging?

afaik, user shound't care about the name of port we expose.

as an admin, i usually just run

k port-forward svc/codeintel-db 5432:5432

as long as the exposed port number is correct, it shound't be a problem?

@DaedalusG
Copy link
Contributor Author

@michaellzc this came up as a source of confusion during an upgrade call where migrator was unable to contact the codeintel-db -- it ultimately wasnt related to this naming, but we were asked to clarify the naming

@efritz
Copy link

efritz commented Apr 26, 2023

@michaellzc This tripped up Marc debugging an issue yesterday here. We weren't sure the Helm charts were configured to point the migrator at the correct databases, and since pgsql is a pod name AND the port name for the codeintel-db pod, it looked wrong at a glance.

@efritz
Copy link

efritz commented Apr 26, 2023

That said I don't know how to use Helm, and I think to a Helm ignorant person this change makes some sense just to disambiguate what strings are used where.

I'm up for other solutions/clarifications though.

@michaellzc
Copy link
Member

michaellzc commented Apr 26, 2023

I am still not sold.

I see Marc's comment was

Migrator commands reference frontend, while the pod name is pgsql

it looks to me the main confusion is coming from pgsql -> frontend, but obviously we can't just rename the pgsql statefulset.

Happy to just accept it as it is since there is no practical difference.

I think we have two options:

  1. rename all exposed port name of pgsql, codeintel-db, codeinsights-db to postgres or postgresql, just to emphasize this is just a postgres database
  2. rename the port name of each db deployment to the db name, i.e., pgsql -> pgsql, codeintel-db everywhere.

either option require renaming references to the port name in both statefulset pod template spec and service spec

@efritz
Copy link

efritz commented Apr 26, 2023

Option No. 1 seems simple and also the least risky. Should we do the same for non-Helm deployments where the port is also named (maybe just k8s)?

@michaellzc
Copy link
Member

Option No. 1 seems simple and also the least risky. Should we do the same for non-Helm deployments where the port is also named (maybe just k8s)?

Yeah, I think that will be great, to keep things consistent.

@marcleblanc2
Copy link
Contributor

marcleblanc2 commented Apr 26, 2023

Yeah, the customer admin was using Lens to manage their deployment which showed the network port name, and as that matched the frontend db's pod name, that distracted us and wasted a bunch of our time, and prolonged their unplanned Sourcegraph prod outage, thus decreased customer and user confidence in our product.

This is the kinda tech debt we need to clean up so our outage resolution times are faster by fewer distractions / opportunities to get tripped up; see also: inconsistent naming of database targets in the multi-version upgrade docs.

We can't require this level of depth of customer admin / support / IE expertise to save us this trouble, we need to prevent this trouble earlier in the chain, which then in turn reduces the escalation engineering cost and distraction of supporting the product, so it's a win-win-win all around.

@efritz
Copy link

efritz commented Apr 26, 2023

see also: inconsistent naming of database targets in the multi-version upgrade docs.

@marcleblanc2 covered in https://github.com/sourcegraph/sourcegraph/issues/51174, also see the board for progress over this quarter.

@marcleblanc2
Copy link
Contributor

You guys are awesome, I'm a big fan, I appreciate your work a ton, and customers are going to love not tripping over this stuff.

@DaedalusG
Copy link
Contributor Author

Okay all the ports are called postgres now @michaellzc wdyt?

@efritz efritz requested a review from michaellzc April 27, 2023 00:00
@DaedalusG DaedalusG merged commit 670b4b7 into release/5.0 Apr 27, 2023
@DaedalusG DaedalusG deleted the wg/fix-port-naming-codeintel-service branch April 27, 2023 17:23
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.

5 participants