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

chore(deployments/data-streams): adds don related label to node registration #16534

Merged
merged 1 commit into from
Feb 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions deployment/data-streams/changeset/jd_register_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,20 @@ func validateNodeSlice(nodes []NodeCfg, nodeType string, donIndex int) error {
return nil
}

func registerNodesForDON(e deployment.Environment, nodes []NodeCfg, baseLabels []*ptypes.Label, nodeType NodeType) {
func registerNodesForDON(e deployment.Environment, donName string, donID int, nodes []NodeCfg, baseLabels []*ptypes.Label, nodeType NodeType) {
ntStr := nodeType.String()
for _, node := range nodes {
labels := append([]*ptypes.Label(nil), baseLabels...)

labels = append(labels, &ptypes.Label{
Key: "nodeType",
Value: &ntStr,
})

labels = append(labels, &ptypes.Label{
Key: fmt.Sprintf("don-%d-%s", donID, donName),
Copy link
Contributor

Choose a reason for hiding this comment

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

This key feels off. Isn't that a value that we should assign to a key?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, alternatively, we could use a don key and assign fmt.Sprintf("don-%d-%s", donID, donName) as its value. However, this approach would limit us to a single value per key. For instance, if you wanted to label a node with two DONs, there wouldn’t be a way to attach multiple values to the same key.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see, so this is a "presence marker", i.e. a boolean flag. Sure, works for me.

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 suppose whether this is a limitation for data-streams depends on how the product is operated, but it might still be a good idea to future-proof the implementation regardless.

})

nodeID, err := e.Offchain.RegisterNode(e.GetContext(), &nodev1.RegisterNodeRequest{
Name: node.Name,
PublicKey: node.CSAKey,
Expand All @@ -100,8 +106,8 @@ func RegisterNodesWithJD(e deployment.Environment, cfg RegisterNodesInput) (depl
}

for _, don := range cfg.DONsList {
registerNodesForDON(e, don.Nodes, baseLabels, NodeTypeOracle)
registerNodesForDON(e, don.BootstrapNodes, baseLabels, NodeTypeBootstrap)
registerNodesForDON(e, don.Name, don.ID, don.Nodes, baseLabels, NodeTypeOracle)
registerNodesForDON(e, don.Name, don.ID, don.BootstrapNodes, baseLabels, NodeTypeBootstrap)
}

return deployment.ChangesetOutput{}, nil
Expand Down
Loading