Skip to content

Commit 6b26cac

Browse files
authored
implement resolved config versioning (#3349)
[static] Signed-off-by: Mateusz Błażejewski <mateusz.blazejewski@digitalasset.com>
1 parent a084098 commit 6b26cac

File tree

13 files changed

+1476
-11
lines changed

13 files changed

+1476
-11
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ repos:
5050
language: system
5151
entry: "scripts/fix-ts.py"
5252
types_or: [javascript, jsx, ts, tsx]
53-
exclude: "(/[.]prettierrc[.]cjs$|jest.config.ts$)"
54-
- id: pulumi_config
55-
name: check pulumi configs
53+
# TODO(#3334): The current implementation of fix-ts.py makes it impossible to format files
54+
# in the top level pulumi package.
55+
exclude: "(/[.]prettierrc[.]cjs$|/pulumi/[^/]+.ts$)"
56+
- id: pulumi_tests
57+
name: run pulumi tests and check expected files
5658
language: system
5759
entry: "make cluster/pulumi/test -j8"
58-
files: '^cluster/pulumi/.*[.]ts$'
60+
files: '^(cluster/pulumi/.*[.]ts|cluster/.*[.](yaml|yml))$'
5961
pass_filenames: false
6062
- id: gha_lint
6163
name: static check github actions

TESTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,15 @@ they cover. Please see the [jest "getting started"](https://jestjs.io/docs/getti
471471
for tips on how to write tests. The type definitions for jest come from the `@jest/globals`
472472
package usage of which is described [here](https://jestjs.io/docs/getting-started#type-definitions).
473473

474+
### Versioning resolved configuration
475+
To make sure that changes to cluster configuration are made consciously in light of various
476+
modularization and reuse mechanisms in the config loader a complete and fully resolved version of
477+
the cluster configuration file is versioned. Such a file is generated as `config.resolved.yaml`
478+
for each clusters' main `config.yaml` using `make cluster/deployment/update-resolved-config -j`.
479+
The `cluster/pulumi/update-expected` make target also includes resolved configuration update.
480+
Appropriate checks are conducted in pre-commit hooks and later in CI to make sure that these
481+
resolved configuration files are kept in sync with the original unresolved ones.
482+
474483
### Pulumi state checks
475484
To make sure that the impact of changes in the Pulumi resource definitions is well understood we
476485
rely on checked in `expected` files that need to be updated whenever the expected deployment state changes.

cluster/deployment/local.mk

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
deployment_dir := $(call current_dir)
5+
6+
cluster_dirs := $(foreach config,$(wildcard $(deployment_dir)/*/config.yaml),$(shell dirname $(config)))
7+
resolved_config_targets := $(foreach cluster_dir,$(cluster_dirs),$(cluster_dir)/config.resolved.yaml)
8+
9+
# We use .PHONY because it is hard to pinpoint exact deps for config resolution as it might depend
10+
# on many config files and the config loader implementation. At some point, when we get rid of
11+
# more specific config loading rules, it might make sense to try list the dependencies here.
12+
define update_resolved_config
13+
.PHONY: $(1)/config.resolved.yaml
14+
$(1)/config.resolved.yaml:
15+
source $(1)/.envrc.vars && \
16+
cd "${SPLICE_ROOT}/cluster/pulumi" && \
17+
npm run resolve-config
18+
endef
19+
$(foreach cluster_dir,$(cluster_dirs),$(eval $(call update_resolved_config,$(cluster_dir))))
20+
21+
.PHONY: $(deployment_dir)/update-resolved-config
22+
$(deployment_dir)/update-resolved-config: $(resolved_config_targets)
23+
24+
.PHONY: $(deployment_dir)/check-resolved-config
25+
$(deployment_dir)/check-resolved-config: $(resolved_config_targets)
26+
git diff --exit-code --quiet $(resolved_config_targets)

0 commit comments

Comments
 (0)