Remove --http-port and --port from the cockroach operator#1058
Remove --http-port and --port from the cockroach operator#1058prafull01 wants to merge 2 commits intocockroachdb:masterfrom
Conversation
4733aa4 to
3b43236
Compare
3b43236 to
a3078de
Compare
| @@ -1084,12 +1084,12 @@ spec: | |||
| type: boolean | |||
| type: object | |||
| grpcPort: | |||
There was a problem hiding this comment.
Is this still just a port? Do we need to update the CRD here for something like grpcAddr and httpAddr
There was a problem hiding this comment.
If we change the fields from port to grpcAddr and http-port to httpAddr, we need to have some kind of migration to actually migrate the old CRs to these new values. This is why to keep it simple I have just changed the description and not fields.
| - 'exec /cockroach/cockroach.sh start --advertise-host=$(POD_NAME).test-cluster.test-ns | ||
| --certs-dir=/cockroach/cockroach-certs/ --http-port=8080 --sql-addr=:26257 | ||
| --certs-dir=/cockroach/cockroach-certs/ --http-addr=:8080 --sql-addr=:26257 | ||
| --listen-addr=:26258 --log="{sinks: {stderr: {channels: [OPS, HEALTH], redact: |
There was a problem hiding this comment.
Wait, did we already make the change to listen-addr in the operator? What value is it pulling from?
There was a problem hiding this comment.
Yes we already have change of listen-addr which is equal to :grpcPort, I did the same thing from http-port to http-addr=:httpPort
You can check existing values coming from here
| type: object | ||
| grpcPort: | ||
| description: '(Optional) The database port (`--port` CLI parameter | ||
| description: '(Optional) The database port (`--listen-addr` CLI parameter |
There was a problem hiding this comment.
Yes. I have only changed the description and not the field so it is backward compatible.
pkg/scale/drainer.go
Outdated
| // after it's confirmed that there are 0 replicas on the node. | ||
| func (d *CockroachNodeDrainer) markNodeAsDecommissioned(ctx context.Context, id uint, gRPCPort int32) error { | ||
| cmd := []string{"./cockroach", "node", "decommission", fmt.Sprintf("%d", id), fmt.Sprintf("--port=%d", gRPCPort)} | ||
| cmd := []string{"./cockroach", "node", "decommission", fmt.Sprintf("%d", id), fmt.Sprintf("--host=:%d", gRPCPort)} |
There was a problem hiding this comment.
What does --host=:<grpcPort> default to? Is it localhost?
There was a problem hiding this comment.
Description specifies:
--host <addr/host>[:<port>]
CockroachDB node to connect to. This can be specified either as an
address/hostname, or together with a port number as in -s myhost:26257. If
the port number is left unspecified, it defaults to 26257. An IPv6 address
can also be specified with the notation [...], for example [::1]:26257 or
[fe80::f6f2:::]:26257.
Environment variable: COCKROACH_HOST
(default :26257)
It is similar to listenAddr or httpAddr where we can only specify port with :port
8c47b28 to
f1bf6cf
Compare
udnay
left a comment
There was a problem hiding this comment.
Please make sure that the tests all pass on the branch, other than that LGTM
|
|
||
| if r.Spec.GRPCPort == nil { | ||
| r.Spec.GRPCPort = &DefaultGRPCPort | ||
| if r.Spec.GRPCPort == nil && r.Spec.ListenAddr == nil { |
There was a problem hiding this comment.
How does this work, I'm not super familiar with it. Do we need to persist the spec somewhere? I know we pull it often from the k8s api, do we need to update it if we change some of the values here?
There was a problem hiding this comment.
This Default() func always gets called in mutating configuration so whenever a create or update request comes on this func gets called and the changes we mutate on crdbCluster goes to apiserver and it gets persisted to etcd.
Now when in controller you get the crdbcluster object from apiserver it returns the object with all the mutation we did in Default() func.
There was a problem hiding this comment.
So if I do kubectl get crdbcluster foo -o yaml I'll see listenAddr set now?
There was a problem hiding this comment.
Yes. If you create a crdbcluster CR with these changes you will see the listenAddr, httpAddr and sqlAddr set.
If you have old CR, then you don't see it (so no automatic rolling restart). However as soon as you update that CR with new image, your rolling restart will happen and now you see addresses instead of ports.
| @@ -48,7 +49,6 @@ const ( | |||
|
|
|||
| func NewCluster(original *api.CrdbCluster) Cluster { | |||
There was a problem hiding this comment.
This is what I'm curious about, does the original crdb cluster get the defaults or will we always need to do the migration. I guess we'll always do the migration so that there is no conflict between the persisted object and whatever the customer is using to update it.
There was a problem hiding this comment.
This will always gets the object which is processed by default (see my prev comment). Whenever we get the object in controller we get the object which has already mutated using Default func. so we don't have to migrate it again. This is the reason I have removed the call to Default func again. This could cause migration on non migrated object.
If that call is present, after upgrade the migration doesn't happen on the actual CR, but in our logic that func does the migration which is two different states for the same object. We should always use the state which is persisted in etcd.
f1bf6cf to
40b1bc9
Compare
For tests to pass, I am starting a webhook server with controller manager so that this Default() func gets called and does the basic mutation on crdbcluster object. It will need some changes on test side so I will ask for a review again. |
40b1bc9 to
bdcd189
Compare
bdcd189 to
ada69ac
Compare
Fixes: #1056