MCPcopy Index your code
hub / github.com/rilldata/rill / reloadConfig

Method reloadConfig

runtime/config_reloader.go:48–186  ·  view source on GitHub ↗
(ctx context.Context, instanceID string)

Source from the content-addressed store, hash-verified

46}
47
48func (r *configReloader) reloadConfig(ctx context.Context, instanceID string) (varsCount int, modified bool, err error) {
49 err = r.mu.Lock(ctx)
50 if err != nil {
51 return 0, false, err
52 }
53 defer r.mu.Unlock()
54
55 inst, err := r.rt.Instance(ctx, instanceID)
56 if err != nil {
57 return 0, false, err
58 }
59
60 admin, release, err := r.rt.Admin(ctx, instanceID)
61 if err != nil {
62 return 0, false, err
63 }
64 defer release()
65
66 r.rt.Logger.Debug("Reloading config for instance", zap.String("instance_id", instanceID), observability.ZapCtx(ctx))
67
68 cfg, err := admin.GetConfig(ctx)
69 if err != nil {
70 return 0, false, err
71 }
72
73 // Clone for editing
74 tmp := *inst
75 inst = &tmp
76 restartController := false
77
78 // Update variables
79 vars := make(map[string]string)
80 // default first
81 for k, v := range cfg.Variables[""] {
82 vars[k] = v
83 }
84 // then overlay env specific
85 for k, v := range cfg.Variables[inst.Environment] {
86 vars[k] = v
87 }
88 varsChanged := !maps.Equal(inst.Variables, vars)
89 if varsChanged {
90 if !cfg.Editable { // for editable deployments we will write vars to `.env` which will also trigger controller restart
91 inst.Variables = vars
92 restartController = true
93 }
94 }
95 systemVarsChanged := !maps.Equal(inst.SystemVariables, cfg.SystemVariables)
96 if systemVarsChanged {
97 inst.SystemVariables = cfg.SystemVariables
98 restartController = true
99 }
100 inst.Annotations = cfg.Annotations
101
102 // Create a new connectors slice to avoid modifying cached objects
103 newConnectors := make([]*runtimev1.Connector, 0, len(inst.Connectors))
104 for _, connector := range inst.Connectors {
105 if connector.Type == "duckdb" {

Callers 3

ReloadConfigMethod · 0.80

Calls 15

ZapCtxFunction · 0.92
writeEnvFunction · 0.85
InstanceMethod · 0.80
RepoMethod · 0.80
ControllerMethod · 0.80
StringMethod · 0.65
GetConfigMethod · 0.65
PullMethod · 0.65
ReconcileMethod · 0.65
ErrorfMethod · 0.65
EditInstanceMethod · 0.65
LockMethod · 0.45

Tested by

no test coverage detected