From 94af308030aa4d4e6829a9d4c8ca12086a91e519 Mon Sep 17 00:00:00 2001 From: kochanovrv Date: Tue, 7 Jul 2026 11:24:09 +0300 Subject: [PATCH] MSP-8007 fix threads --- cmd/migrate/go.mod | 2 +- cmd/migrate/go.sum | 1 + service/rqlite/config_flags.go | 3 +++ service/rqlite/flags.go | 1 + service/rqlite/main.go | 22 ++++++++++------------ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cmd/migrate/go.mod b/cmd/migrate/go.mod index 9e73547..0378e1e 100644 --- a/cmd/migrate/go.mod +++ b/cmd/migrate/go.mod @@ -6,7 +6,7 @@ replace isp-config-service => ../.. require ( github.com/jmoiron/sqlx v1.4.0 - github.com/mattn/go-sqlite3 v1.14.42 + github.com/mattn/go-sqlite3 v1.14.47 github.com/pkg/errors v0.9.1 github.com/pressly/goose/v3 v3.27.2 github.com/txix-open/isp-kit v1.71.1 diff --git a/cmd/migrate/go.sum b/cmd/migrate/go.sum index 5d271e2..7551e91 100644 --- a/cmd/migrate/go.sum +++ b/cmd/migrate/go.sum @@ -100,6 +100,7 @@ github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuE github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mattn/go-sqlite3 v1.14.42 h1:MigqEP4ZmHw3aIdIT7T+9TLa90Z6smwcthx+Azv4Cgo= github.com/mattn/go-sqlite3 v1.14.42/go.mod h1:pjEuOr8IwzLJP2MfGeTb0A35jauH+C2kbHKBr7yXKVQ= +github.com/mattn/go-sqlite3 v1.14.47/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w= github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY= github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= diff --git a/service/rqlite/config_flags.go b/service/rqlite/config_flags.go index 76bd077..c928980 100644 --- a/service/rqlite/config_flags.go +++ b/service/rqlite/config_flags.go @@ -78,6 +78,9 @@ type Config struct { // If NoNodeVerify is true this field is ignored. NodeVerifyServerName string + // NodeVerifyCommonName is the CommonName to verify as on the certificates returned by a node. + NodeVerifyCommonName string + // NodeID is the Raft ID for the node. NodeID string diff --git a/service/rqlite/flags.go b/service/rqlite/flags.go index 1b01650..143570e 100644 --- a/service/rqlite/flags.go +++ b/service/rqlite/flags.go @@ -81,6 +81,7 @@ func ParseFlags(name, desc string, build *BuildInfo) (*Config, error) { fs.BoolVar(&config.NoNodeVerify, "node-no-verify", false, "Skip verification of any node-node certificate") fs.BoolVar(&config.NodeVerifyClient, "node-verify-client", false, "Enable mutual TLS for node-to-node communication") fs.StringVar(&config.NodeVerifyServerName, "node-verify-server-name", "", "Hostname to verify on certificate returned by a node") + fs.StringVar(&config.NodeVerifyCommonName, "node-verify-common-name", "", "CommonName to verify on certificate returned by a node") fs.StringVar(&config.AuthFile, "auth", "", "Path to authentication and authorization file. If not set, not enabled") fs.StringVar(&config.AutoBackupFile, "auto-backup", "", "Path to automatic backup configuration file. If not set, not enabled") fs.StringVar(&config.AutoRestoreFile, "auto-restore", "", "Path to automatic restore configuration file. If not set, not enabled") diff --git a/service/rqlite/main.go b/service/rqlite/main.go index 5b01db8..c4af1bb 100644 --- a/service/rqlite/main.go +++ b/service/rqlite/main.go @@ -26,7 +26,7 @@ import ( "github.com/rqlite/rqlite/v10/auto/backup" "github.com/rqlite/rqlite/v10/cluster" "github.com/rqlite/rqlite/v10/cmd" - command "github.com/rqlite/rqlite/v10/command/proto" + cmdpkg "github.com/rqlite/rqlite/v10/command" "github.com/rqlite/rqlite/v10/db" "github.com/rqlite/rqlite/v10/db/extensions" httpd "github.com/rqlite/rqlite/v10/http" @@ -83,7 +83,7 @@ func main(ctx context.Context, r *Rqlite) error { r.localHttpAddr = cfg.HTTPAddr // Configure logging and pump out initial message. - log.Printf("%s starting, version %s, SQLite %s, commit %s, branch %s, compiler (toolchain) %s, compiler (command) %s", + log.Printf("%s starting, version %s, SQLite %s, commit %s, compiler (toolchain) %s, compiler (command) %s", name, cmd.Version, db.DBVersion, cmd.Commit, runtime.Compiler, cmd.CompilerCommand) log.Printf("%s, target architecture is %s, operating system target is %s", runtime.Version(), runtime.GOARCH, runtime.GOOS) @@ -151,7 +151,10 @@ func main(ctx context.Context, r *Rqlite) error { if err != nil { log.Fatalf("failed to create cluster client: %s", err.Error()) } - httpServ, err := startHTTPService(cfg, str, clstrClient, credStr) + pxy := proxy.New(str, clstrClient) + pxy.SetAPIAddr(cfg.HTTPAdv) + + httpServ, err := startHTTPService(cfg, str, clstrClient, credStr, pxy) if err != nil { log.Fatalf("failed to start HTTP server: %s", err.Error()) } @@ -353,9 +356,9 @@ func createStore(cfg *Config, ln *tcp.Layer, extensions []string) (*store.Store, return str, nil } -func startHTTPService(cfg *Config, str *store.Store, cltr *cluster.Client, credStr *auth.CredentialsStore) (*httpd.Service, error) { +func startHTTPService(cfg *Config, str *store.Store, cltr *cluster.Client, credStr *auth.CredentialsStore, pxy *proxy.Proxy) (*httpd.Service, error) { // Create HTTP server and load authentication information. - s := httpd.New(cfg.HTTPAddr, str, cltr, proxy.New(str, cltr), credStr) + s := httpd.New(cfg.HTTPAddr, str, cltr, pxy, credStr) s.CACertFile = cfg.HTTPx509CACert s.CertFile = cfg.HTTPx509Cert @@ -394,7 +397,7 @@ func startNodeMux(cfg *Config, ln net.Listener) (*tcp.Mux, error) { } if cfg.NodeVerifyClient { b.WriteString(", mutual TLS enabled") - mux, err = tcp.NewMutualTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key, cfg.NodeX509CACert, "") + mux, err = tcp.NewMutualTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key, cfg.NodeX509CACert, cfg.NodeVerifyCommonName) } else { b.WriteString(", mutual TLS disabled") mux, err = tcp.NewTLSMux(ln, adv, cfg.NodeX509Cert, cfg.NodeX509Key) @@ -469,12 +472,7 @@ func createCluster(ctx context.Context, cfg *Config, hasPeers bool, client *clus leader, _ := str.LeaderAddr() return leader != "" } - clusterSuf := func() command.Suffrage { - if cfg.RaftNonVoter { - return command.Suffrage_NON_VOTER - } - return command.Suffrage_VOTER - }() + clusterSuf := cmdpkg.SuffrageNonVoterFromBool(cfg.RaftNonVoter) joiner := cluster.NewJoiner(client, cfg.JoinAttempts, cfg.JoinInterval) joiner.SetCredentials(cluster.CredentialsFor(credStr, cfg.JoinAs))