Skip to content
Merged
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions api/apiv1/design/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,27 @@ var DatabaseUserSpec = g.Type("DatabaseUserSpec", func() {
g.Required("username")
})

var DatabaseConnection = g.Type("DatabaseConnection", func() {
g.Description("Controls how the service connects to the database. " +
"When omitted, all nodes are included with the local node first " +
"and target_session_attrs is derived from the service config.")
g.Attribute("target_nodes", g.ArrayOf(g.String), func() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I ran into an issue when testing database updates around this - I started with target_nodes as only n1 with target_session_attrs as prefer-standby and that worked well.

However, I tried to run an update on this to set it to n2 and primary, and I ran into two issues:

  • The MCP service didn't restart
  • Once I restarted it myself, it could not connect to the database. It seems like the service role didn't make it to n2, so it couldn't connect.

From there, I tried to remove the services block so I could redeploy it fully, and I ran into this validation:

{
  message: "services[0].config: init_token can only be set during initial provisioning"
  name: "invalid_input"
}

I had to tear it down and restart - it seems like we are not cleaning up the state fully.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Filed PLAT-522 to address the update issue. Will fix the role propagation issue in PLAT-461.

g.Description("Optional ordered list of database node names. When set, " +
"the service's database connection includes only the listed nodes " +
"in the specified order.")
g.Example([]string{"n1", "n2"})
g.Meta("struct:tag:json", "target_nodes,omitempty")
})
g.Attribute("target_session_attrs", g.String, func() {
g.Description("Optional libpq target_session_attrs value. When set, " +
"overrides the default derived from the service config. " +
"Valid values: primary, prefer-standby, standby, read-write, any.")
g.Enum("primary", "prefer-standby", "standby", "read-write", "any")
g.Example("primary")
g.Meta("struct:tag:json", "target_session_attrs,omitempty")
})
})

var ServiceSpec = g.Type("ServiceSpec", func() {
g.Attribute("service_id", Identifier, func() {
g.Description("The unique identifier for this service.")
Expand Down Expand Up @@ -197,6 +218,10 @@ var ServiceSpec = g.Type("ServiceSpec", func() {
g.Description("Orchestrator-specific options for this service.")
g.Meta("struct:tag:json", "orchestrator_opts,omitempty")
})
g.Attribute("database_connection", DatabaseConnection, func() {
g.Description("Optional database connection routing configuration.")
g.Meta("struct:tag:json", "database_connection,omitempty")
})

g.Required("service_id", "service_type", "version", "host_ids", "config")
})
Expand Down
15 changes: 15 additions & 0 deletions api/apiv1/gen/control_plane/service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

115 changes: 115 additions & 0 deletions api/apiv1/gen/http/control_plane/client/encode_decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions api/apiv1/gen/http/control_plane/client/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading