Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

refactor(rexctl): move old installer settings on first upgrade

Hampuseabd18ae1513
diff --git a/fluxer_rexctl/cmd/upgrade.go b/fluxer_rexctl/cmd/upgrade.go
index 66f79aa65..2ba9ed04b 100644
--- a/fluxer_rexctl/cmd/upgrade.go
+++ b/fluxer_rexctl/cmd/upgrade.go
@@ -623,15 +623,6 @@ func nextState(inst *instance.Instance, set *stack.Set, images stack.ImageSet, t
if cur.Release == stack.LegacyRelease {
pins = slices.Sorted(maps.Keys(instance.ConvertLegacy(&next, set, next.Images.Refs).Pins))
}
- for _, m := range stack.Pending(next.Migrations) {
- if err := m.Apply(next.Settings); err != nil {
- return nil, nil, fmt.Errorf("%s: %w", m.ID, err)
- }
- }
- next.Migrations = next.Migrations[:0]
- for _, m := range stack.Migrations {
- next.Migrations = append(next.Migrations, m.ID)
- }
if _, err := secrets.Mint(next.Secrets, true); err != nil {
return nil, nil, err
}
diff --git a/fluxer_rexctl/internal/instance/convert.go b/fluxer_rexctl/internal/instance/convert.go
index ec1124052..80e3a995e 100644
--- a/fluxer_rexctl/internal/instance/convert.go
+++ b/fluxer_rexctl/internal/instance/convert.go
@@ -44,10 +44,7 @@ func ConvertLegacy(s *State, next *stack.Set, nextImages map[string]string) *Leg
delete(s.Settings, tunnelBindVar)
s.Settings[settings.EdgeBind] = v
}
- if len(next.Profiles) > 0 {
- memoryProfile(next, s.Settings)
- c.Profile = s.Settings[settings.MemoryProfile]
- }
+ stack.ConvertLegacySettings(s.Settings)
return c
}
diff --git a/fluxer_rexctl/internal/instance/state.go b/fluxer_rexctl/internal/instance/state.go
index 78e45cc88..e0de18f61 100644
--- a/fluxer_rexctl/internal/instance/state.go
+++ b/fluxer_rexctl/internal/instance/state.go
@@ -132,6 +132,7 @@ func ParseState(data []byte, dir string) (*State, error) {
var stateFields = map[string]bool{
"schema": true, "project": true, "engine": true, "release": true, "previous_release": true, "failed_release": true,
"upgrade": true, "pending": true, "images": true, "settings": true, "secrets": true, "admin_import": true,
+ "setup_done": true, "installing": true, "stopped": true, "rendered": true, "mounted": true, "ejected": true,
"installed_at": true, "updated_at": true,
}
diff --git a/fluxer_rexctl/internal/stack/legacy.go b/fluxer_rexctl/internal/stack/legacy.go
new file mode 100644
index 000000000..69fa50700
--- /dev/null
+++ b/fluxer_rexctl/internal/stack/legacy.go
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+package stack
+
+import (
+ "strconv"
+ "strings"
+)
+
+func ConvertLegacySettings(settings map[string]string) {
+ migrateLiveKitPath(settings)
+ migrateEdgeSiteAddress(settings)
+ migrateSvcConcurrency(settings)
+ migrateSvcCombined(settings)
+}
+
+func migrateLiveKitPath(settings map[string]string) {
+ const key = "FLUXER_LIVEKIT_URL"
+ v, ok := settings[key]
+ if !ok {
+ return
+ }
+ trimmed := strings.TrimRight(v, "/")
+ if base, found := strings.CutSuffix(trimmed, "/gateway/livekit"); found {
+ settings[key] = base + "/livekit"
+ }
+}
+
+func migrateEdgeSiteAddress(settings map[string]string) {
+ const oldKey, newKey = "FLUXER_CADDY_SITE_ADDRESS", "FLUXER_EDGE_SITE_ADDRESS"
+ old, ok := settings[oldKey]
+ if !ok {
+ return
+ }
+ if current := settings[newKey]; current == "" && old != "" {
+ settings[newKey] = old
+ }
+ delete(settings, oldKey)
+}
+
+func migrateSvcConcurrency(settings map[string]string) {
+ const key = "FLUXER_SVC_MAX_CONCURRENT_REQUESTS"
+ const floor = 320
+ v, ok := settings[key]
+ if !ok {
+ return
+ }
+ n, err := strconv.Atoi(strings.TrimSpace(v))
+ if err != nil || n < floor {
+ delete(settings, key)
+ }
+}
+
+func migrateSvcCombined(settings map[string]string) {
+ const floorMiB = 256
+ for _, name := range []string{"SNOWFLAKES", "USERS", "GIFS", "MESSAGES", "UNFURL"} {
+ limitKey, shardLimitKey := "FLUXER_"+name+"_MEMORY_LIMIT", "FLUXER_"+name+"_SHARD_MEMORY_LIMIT"
+ limit, hasLimit := settings[limitKey]
+ shardLimit, hasShardLimit := settings[shardLimitKey]
+ switch {
+ case hasShardLimit && (!hasLimit || parseMiB(shardLimit) > parseMiB(limit)):
+ settings[limitKey] = shardLimit
+ case !hasShardLimit && hasLimit && parseMiB(limit) < floorMiB:
+ delete(settings, limitKey)
+ }
+ delete(settings, shardLimitKey)
+
+ poolKey, shardPoolKey := "FLUXER_"+name+"_POSTGRES_MAX_CONNECTIONS", "FLUXER_"+name+"_SHARD_POSTGRES_MAX_CONNECTIONS"
+ if pool, ok := settings[shardPoolKey]; ok {
+ if _, set := settings[poolKey]; !set {
+ settings[poolKey] = pool
+ }
+ delete(settings, shardPoolKey)
+ }
+ }
+}