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: refactor let api decide for restart #2835

Merged
merged 1 commit into from
Nov 6, 2024
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/go-xmlfmt/xmlfmt v1.1.2
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/golangci/golangci-lint v1.61.0
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v62 v62.0.0
github.com/google/go-querystring v1.1.0
github.com/google/uuid v1.6.0
Expand Down Expand Up @@ -170,6 +169,7 @@ require (
github.com/golangci/plugin-module-register v0.1.1 // indirect
github.com/golangci/revgrep v0.5.3 // indirect
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
Expand Down
11 changes: 0 additions & 11 deletions pkg/config/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package config
import (
"bytes"

"github.com/google/go-cmp/cmp"
v1API "github.com/supabase/cli/pkg/api"
"github.com/supabase/cli/pkg/cast"
"github.com/supabase/cli/pkg/diff"
Expand Down Expand Up @@ -81,16 +80,6 @@ type (
}
)

// Compare two db config, if changes requires restart return true, return false otherwise
func (a settings) requireDbRestart(b settings) bool {
return !cmp.Equal(a.MaxConnections, b.MaxConnections) ||
!cmp.Equal(a.MaxWorkerProcesses, b.MaxWorkerProcesses) ||
!cmp.Equal(a.MaxParallelWorkers, b.MaxParallelWorkers) ||
!cmp.Equal(a.MaxWalSenders, b.MaxWalSenders) ||
!cmp.Equal(a.MaxReplicationSlots, b.MaxReplicationSlots) ||
!cmp.Equal(a.SharedBuffers, b.SharedBuffers)
}

func (a *settings) ToUpdatePostgresConfigBody() v1API.UpdatePostgresConfigBody {
body := v1API.UpdatePostgresConfigBody{}

Expand Down
7 changes: 0 additions & 7 deletions pkg/config/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@ func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef s
return nil
}
fmt.Fprintln(os.Stderr, "Updating DB service with config:", string(dbDiff))

remoteConfig := s.fromRemoteConfig(*dbConfig.JSON200)
restartRequired := s.requireDbRestart(remoteConfig)
if restartRequired {
fmt.Fprintln(os.Stderr, "Database will be restarted to apply config updates...")
}
updateBody := s.ToUpdatePostgresConfigBody()
updateBody.RestartDatabase = &restartRequired
if resp, err := u.client.V1UpdatePostgresConfigWithResponse(ctx, projectRef, updateBody); err != nil {
return errors.Errorf("failed to update DB config: %w", err)
} else if resp.JSON200 == nil {
Expand Down