Skip to content

Conversation

@denik
Copy link
Contributor

@denik denik commented Aug 11, 2025

Changes

The "${resources...id}" references are now substituted by direct deployment backend. They are used to build DAG both during planning and apply.

Tests

New test that check jobs update, pipeline recreation and reference going into integer field.

All existing tests that were disabled due to lack of ${resources} support are enabled.

@denik denik temporarily deployed to test-trigger-is August 11, 2025 15:04 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 11, 2025 15:12 — with GitHub Actions Inactive
@eng-dev-ecosystem-bot
Copy link
Collaborator

eng-dev-ecosystem-bot commented Aug 11, 2025

Run: 17037278580

Env ✅‌pass 🙈‌skip
✅‌ aws linux 310 479
✅‌ aws windows 311 478
✅‌ aws-ucws linux 423 378
✅‌ aws-ucws windows 424 377
✅‌ azure linux 310 478
✅‌ azure windows 311 477
✅‌ azure-ucws linux 425 375
✅‌ azure-ucws windows 426 374
✅‌ gcp linux 309 480
✅‌ gcp windows 310 479

@denik denik temporarily deployed to test-trigger-is August 11, 2025 16:00 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 11, 2025 16:07 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 11, 2025 16:19 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 11, 2025 16:30 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 12, 2025 10:44 — with GitHub Actions Inactive
@denik denik force-pushed the denik/plan-dag-wip branch from 1e71956 to 92897e8 Compare August 13, 2025 07:30
@denik denik temporarily deployed to test-trigger-is August 13, 2025 07:30 — with GitHub Actions Inactive
github-merge-queue bot pushed a commit that referenced this pull request Aug 13, 2025
## Changes
Improve error message when converting typed struct to dynamic.

## Why
Currently different functions share the message body, so you don't know
which field failed to convert.

Real example when working on #3390
test acceptance/bundle/deploy/jobs/double-underscore-keys triggers this
error condition:

Before this change "bundle deploy" fails with:

```
Warn: unable to convert typed configuration to dynamic configuration: unhandled type: string
Error: exit error: unhandled type: string
```

After:

```
Warn: unable to convert typed configuration to dynamic configuration: cannot convert int field to dynamic type "string": src=4611686018427387911 ref="4611686018427387911"
Error: exit error: cannot convert int field to dynamic type "string": src=4611686018427387911 ref="4611686018427387911"
```

## Tests
Manually, by applying this commit on
#3390
@denik denik force-pushed the denik/plan-dag-wip branch from 92897e8 to 671ac12 Compare August 13, 2025 11:10
@denik denik temporarily deployed to test-trigger-is August 13, 2025 11:10 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 11:14 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 11:16 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 11:19 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 11:40 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 12:19 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 12:24 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 12:28 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 13, 2025 12:39 — with GitHub Actions Inactive
@denik denik marked this pull request as ready for review August 13, 2025 12:40
@denik denik temporarily deployed to test-trigger-is August 13, 2025 12:43 — with GitHub Actions Inactive
@denik denik changed the title Resolve $resources.group.key.id and order deployment accordingly direct: Resolve $resources.group.key.id and order deployment accordingly Aug 13, 2025
return errors.New("internal error: no db entry")
}

bundle.ApplyFuncContext(ctx, b, func(ctx context.Context, b *bundle.Bundle) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need to be inside ApplyFuncContext call and not just Config.Mutate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApplyFuncContext ensures that dynamic configuration is copied back to typed one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. At this moment, we never read typed configuration, so we can postpone this conversion and save some time there. Removed ApplyFunContext - all tests still pass.

if err != nil {
return root, err
}
root, diags := convert.Normalize(b.Config, root)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to normalise here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this comment in the code:

+                       // Following resolve_variable_references.go, normalize after variable substitution.
+                       // This fixes the following case: ${resources.jobs.foo.id} is replaced by string "12345"
+                       // This string corresponds to job_id integer field. Normalization converts "12345" to 12345.
+                       // Without normalization there will be an error when converting dynamic value to typed.
                        root, diags := convert.Normalize(b.Config, root)

}

func (g *Graph[N]) AddDirectedEdge(from, to N, label string) error {
if from == to {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to avoid self loops?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to, but we already have diagnostics for loops. I've added new tests with both regular and self loops.

@denik denik force-pushed the denik/plan-dag-wip branch from fef7ba0 to 52f4575 Compare August 18, 2025 09:14
@denik denik temporarily deployed to test-trigger-is August 18, 2025 09:14 — with GitHub Actions Inactive
return
}
if actionType == deployplan.ActionTypeUnset {
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer an internal error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be. restored.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got that wrong. This comment explains what should happen 6c3356a


// Extract unresolved references from a given node only.
// We need to do it here because we're constantly resolving references, so that's where we have latest version.
myReferences, err := extractReferences(b.Config.Value(), node)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC this referred to a commented out log line.

}

func validateRef(root dyn.Value, ref string) (string, string, error) {
items := strings.Split(ref, ".")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It now uses a mix of split and dyn.NewPath below. Easier to only use dyn.Path.

@denik denik temporarily deployed to test-trigger-is August 18, 2025 09:43 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is August 18, 2025 09:55 — with GitHub Actions Inactive
@denik denik enabled auto-merge August 18, 2025 09:56
@denik denik added this pull request to the merge queue Aug 18, 2025
Merged via the queue into main with commit a76dc13 Aug 18, 2025
13 checks passed
@denik denik deleted the denik/plan-dag-wip branch August 18, 2025 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants