Skip to content

Commit a7698ed

Browse files
authored
Centralize dynamic config (temporalio#543)
1 parent ac0ac87 commit a7698ed

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ Publishing docker images of the features runner/suites is also supported. It may
171171
[manually](https://github.com/temporalio/features/actions/workflows/all-docker-images.yaml),
172172
but is also triggered by default on each push to main.
173173

174+
The dynamic configuration file located at `dockerfiles/dynamicconfig/docker.yaml` defines the dynamic configuration
175+
settings needed for features to run, and should be used as part of or all of the dynamic config settings for any
176+
external server not using the basic docker-compose setup.
177+
174178
## TODO
175179

176180
- Add support for replaying testing of all versions _inside_ each SDKs harness as part of the run

Diff for: cmd/run.go

+25-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"go.temporal.io/sdk/client"
2828
"go.temporal.io/sdk/log"
2929
"go.temporal.io/sdk/testsuite"
30+
"gopkg.in/yaml.v3"
3031
)
3132

3233
const (
@@ -200,17 +201,33 @@ func (r *Runner) Run(ctx context.Context, patterns []string) error {
200201

201202
// If the server is not set, start it ourselves
202203
if r.config.Server == "" {
204+
// Load up dynamic config values.
205+
// Probably the CLI could support passing a dynamic config file as well, but it also likes to set some default
206+
// values for certain things, so it's easier to just load the file here and pass those values explicitly.
207+
cfgPath := filepath.Join(r.rootDir, "dockerfiles", "dynamicconfig", "docker.yaml")
208+
yamlBytes, err := os.ReadFile(cfgPath)
209+
var yamlValues map[string][]struct {
210+
Constraints map[string]any
211+
Value any
212+
}
213+
if err = yaml.Unmarshal(yamlBytes, &yamlValues); err != nil {
214+
return fmt.Errorf("unable to decode dynamic config: %w", err)
215+
}
216+
dynamicConfigArgs := make([]string, 0, len(yamlValues))
217+
for key, values := range yamlValues {
218+
for _, value := range values {
219+
asJsonStr, err := json.Marshal(value)
220+
if err != nil {
221+
return fmt.Errorf("unable to marshal dynamic config value %s: %w", key, err)
222+
}
223+
dynamicConfigArgs = append(dynamicConfigArgs, "--dynamic-config-value", fmt.Sprintf("%s=%s", key, asJsonStr))
224+
}
225+
}
226+
203227
server, err := testsuite.StartDevServer(ctx, testsuite.DevServerOptions{
204-
// TODO(cretz): Configurable?
205228
LogLevel: "error",
206229
ClientOptions: &client.Options{Namespace: r.config.Namespace},
207-
ExtraArgs: []string{
208-
"--dynamic-config-value", "system.forceSearchAttributesCacheRefreshOnRead=true",
209-
"--dynamic-config-value", "system.enableActivityEagerExecution=true",
210-
"--dynamic-config-value", "system.enableEagerWorkflowStart=true",
211-
"--dynamic-config-value", "frontend.enableUpdateWorkflowExecution=true",
212-
"--dynamic-config-value", "frontend.enableUpdateWorkflowExecutionAsyncAccepted=true",
213-
},
230+
ExtraArgs: dynamicConfigArgs,
214231
})
215232
if err != nil {
216233
return fmt.Errorf("failed starting devserver: %w", err)

Diff for: dockerfiles/dynamicconfig/docker.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
frontend.forceSearchAttributesCacheRefreshOnRead:
2+
- value: true
3+
constraints: {}
4+
frontend.enableActivityEagerExecution:
5+
- value: true
6+
constraints: {}
7+
frontend.enableEagerWorkflowStart:
8+
- value: true
9+
constraints: {}
110
frontend.enableUpdateWorkflowExecution:
211
- value: true
312
constraints: {}

0 commit comments

Comments
 (0)