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

Use VClusterOps API to get node details in podfacts #769

Merged
merged 6 commits into from
Apr 15, 2024

Conversation

cchen-vertica
Copy link
Collaborator

This adds a new fetcher in podfacts to fetch node details from the running database inside the pod. This new fetcher will call VClusterOps API which will send an HTTP request to the database. The new fetcher will be enabled when VclusterOps annotation is set, and Vertica server version is not older than v24.3.0. The new fetcher should be faster and more reliable than the old fetcher which will execute vsql within the pod.

@cchen-vertica cchen-vertica requested a review from spilchen as a code owner April 12, 2024 17:52
@cchen-vertica cchen-vertica marked this pull request as draft April 12, 2024 17:54
@cchen-vertica cchen-vertica marked this pull request as ready for review April 12, 2024 21:45
@cchen-vertica cchen-vertica requested a review from roypaulin April 12, 2024 21:45
func (p *PodFacts) makeNodeInfoFetcher(vdb *vapi.VerticaDB, pf *PodFact) catalog.Fetcher {
return catalog.MakeVSQL(vdb, p.PRunner, pf.name, pf.execContainerName)
const vclusterAPISupportedMinVersion = "v24.3.0"
vdbVer, ok := vdb.GetVerticaVersionStr()
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is already a function for getting the version from a vdb: MakeVersionInfo.

func (p *PodFacts) makeNodeInfoFetcher(vdb *vapi.VerticaDB, pf *PodFact) catalog.Fetcher {
return catalog.MakeVSQL(vdb, p.PRunner, pf.name, pf.execContainerName)
const vclusterAPISupportedMinVersion = "v24.3.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you call this const FetchNodeDetailsWithVclusterOpsMinVersion and add it to v1/version.go?

@@ -46,7 +46,7 @@ var _ = Describe("obj_reconcile", func() {

runReconciler := func(vdb *vapi.VerticaDB, expResult ctrl.Result, mode ObjReconcileModeType) {
// Create any dependent objects for the CRD.
pfacts := MakePodFacts(vdbRec, &cmds.FakePodRunner{}, logger)
pfacts := MakePodFacts(vdbRec, &cmds.FakePodRunner{}, logger, "")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
pfacts := MakePodFacts(vdbRec, &cmds.FakePodRunner{}, logger, "")
pfacts := MakePodFacts(vdbRec, &cmds.FakePodRunner{}, logger, vapi.MainCluster)

minor: use v1.MainCluster const in place of empty sandbox name

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this new empty string is for the dbadmin password. It might be clear if we still used a const for it. i.e. TestEmptyPassword

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I found we had a TestPassword exists in those tests. I will reuse that one.

@@ -852,23 +807,6 @@ func parseVerticaNodeName(stdout string) string {
return ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not directly related to your PR, but I saw it when reviewing your change, can you remove parseVerticaNodeName? I think we only use it for test. We don't have any non-test operator code that relies on it.

return catalog.MakeVSQL(vdb, p.PRunner, pf.name, pf.execContainerName)
const vclusterAPISupportedMinVersion = "v24.3.0"
vdbVer, ok := vdb.GetVerticaVersionStr()
if ok {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It might be good to log an entry if we cannot get the version. Just so we know why we reverted back to the old vsql behaviour.

nodeDetails.SubclusterOid = strconv.FormatUint(vnodeDetails.SubclusterID, 10)
nodeDetails.ReadOnly = vnodeDetails.IsReadOnly
nodeDetails.SandboxName = vnodeDetails.SandboxName
nodeDetails.ShardSubscriptions = int(vnodeDetails.NumberShardSubscriptions)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe there a bit of inconsistency with this one. The HTTPS endpoint will return the shard subscriptions, including the replica shard. Where as the old method that did vsql would could the number of subscriptions and explicitly avoided the replica shard in the WHERE clause. I wonder if we can just subtract the number by 1 if it's positive?

Copy link
Collaborator

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

Looks good. I just had one additional suggestion about a comment we should have.

@@ -47,6 +47,9 @@ func (nodeDetails *NodeDetails) parseVNodeDetails(vnodeDetails *vclusterops.Node
nodeDetails.ReadOnly = vnodeDetails.IsReadOnly
nodeDetails.SandboxName = vnodeDetails.SandboxName
nodeDetails.ShardSubscriptions = int(vnodeDetails.NumberShardSubscriptions)
if nodeDetails.ShardSubscriptions > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest we leave a comment so that we know why we are decrementing the subscription count.

Suggested change
if nodeDetails.ShardSubscriptions > 0 {
// The shard subscriptions we get from vcluster includes the replica shard.
// We decrement that by one to account for that. We want to know when there
// are 0 shard subscriptions in order to drive a shard rebalance.
if nodeDetails.ShardSubscriptions > 0 {

@cchen-vertica cchen-vertica merged commit 2934f95 into vnext Apr 15, 2024
31 checks passed
@cchen-vertica cchen-vertica deleted the cchen/use-vclusterapi-in-podfacts branch April 15, 2024 18:39
cchen-vertica added a commit that referenced this pull request Jul 17, 2024
This adds a new fetcher in podfacts to fetch node details from the
running database inside the pod. This new fetcher will call VClusterOps
API which will send an HTTP request to the database. The new fetcher
will be enabled when VclusterOps annotation is set, and Vertica server
version is not older than v24.3.0. The new fetcher should be faster and
more reliable than the old fetcher which will execute vsql within the
pod.
cchen-vertica added a commit that referenced this pull request Jul 17, 2024
This adds a new fetcher in podfacts to fetch node details from the
running database inside the pod. This new fetcher will call VClusterOps
API which will send an HTTP request to the database. The new fetcher
will be enabled when VclusterOps annotation is set, and Vertica server
version is not older than v24.3.0. The new fetcher should be faster and
more reliable than the old fetcher which will execute vsql within the
pod.
cchen-vertica added a commit that referenced this pull request Jul 24, 2024
This adds a new fetcher in podfacts to fetch node details from the
running database inside the pod. This new fetcher will call VClusterOps
API which will send an HTTP request to the database. The new fetcher
will be enabled when VclusterOps annotation is set, and Vertica server
version is not older than v24.3.0. The new fetcher should be faster and
more reliable than the old fetcher which will execute vsql within the
pod.
cchen-vertica added a commit that referenced this pull request Jul 24, 2024
This adds a new fetcher in podfacts to fetch node details from the
running database inside the pod. This new fetcher will call VClusterOps
API which will send an HTTP request to the database. The new fetcher
will be enabled when VclusterOps annotation is set, and Vertica server
version is not older than v24.3.0. The new fetcher should be faster and
more reliable than the old fetcher which will execute vsql within the
pod.
cchen-vertica added a commit that referenced this pull request Jul 24, 2024
This adds a new fetcher in podfacts to fetch node details from the
running database inside the pod. This new fetcher will call VClusterOps
API which will send an HTTP request to the database. The new fetcher
will be enabled when VclusterOps annotation is set, and Vertica server
version is not older than v24.3.0. The new fetcher should be faster and
more reliable than the old fetcher which will execute vsql within the
pod.
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.

3 participants