Commit graph

22 commits

Author SHA1 Message Date
Radek Simko
0fe906fa8c make copyrightfix 2026-02-17 13:56:34 +00:00
James Bardin
807e084130 final renaming for function results 2025-05-08 11:42:05 -04:00
James Bardin
a6ec17cb77 rename function results table
Remove "provider" from the function results fields since it's not going
to be exclusively used for providers any longer.
2025-05-07 16:03:43 -04:00
James Bardin
d016070564 move function results hashing to lang
We need to abstract the function results verification to use internally
too, so start by moving it out of the providers code.
2025-05-07 13:02:46 -04:00
James Bardin
2ffbd0eb4e remove old refactoring comments 2024-08-22 09:39:37 -04:00
James Bardin
bc750192e4 POC for always using decoded changes in core
We should not need to encode and decode change values within core, since
the encoded version is only technically needed for serialization. This
pattern stems from the conversion to current changes system, but back
then we did not have easy access to the correct schemas at the time to
encode and decode the entire set of changes.

Moving the core handling of changes to only use the decoded values will
drastically improve evaluation efficiency, removing a round trip
through encoded values for every resource reference.
2024-08-22 09:39:37 -04:00
Liam Cervante
f1ae07b1af
stacks: add support for provider functions in .tfstack.hcl files (#35610)
* stacks: fix bug preventing cross-provider move refactorings

* also make provider functions work

* stacks: add support for provider functions in .tfstack.hcl files
2024-08-22 09:28:39 +02:00
Liam Cervante
0c67edd598
stacks: ensure input values for components don't change between plan and apply (#35489)
* stacks: ensure input values for components don't change between plan and apply

* skip ephemeral values
2024-07-30 08:39:36 +02:00
Liam Cervante
87bbc47737
stacks: include plan mode in stacks plan format (#35405)
* stacks: include plan mode in stacks plan format

* fix tests

* fix missed files
2024-07-23 17:45:07 +02:00
Daniel Schmidt
59ead5356f
stacks: update RPC APIs with deferral information (#35125)
* stacks: add deferred resource instance planned change to protobuf

* stacks: add deferred resource instance to stack plan sequence

* stacks: add planned change for deferred actions

* stacks: refactor planned change resource instance planned

moving the components out of the main function definition so that we can reuse the implementation for deferred resource instances which wraps the message used for PlannedChangeResourceInstancePlanned

* stacks: track deferred changes in stackplan

* add simple tests

* fix tests

* address comments

---------

Co-authored-by: Liam Cervante <liam.cervante@hashicorp.com>
2024-06-04 15:14:00 +02:00
CJ Horton
5a750561e6 round-trip check results through stack plans
Components expect that check results will be round-tripped
through the plan in order to update unknown check results
during the apply. We hadn't wired this up for stack plans,
resulting in panics when the apply tries to update a check
status that doesn't exist.
2024-03-01 17:22:44 -08:00
Liam Cervante
07f6621091
stacks: include resources in state when calculating required providers (#34645)
* stacks: include resources in state when calculating required providers

* also support apply time

* add copywrite headers
2024-02-15 10:45:47 +01:00
Martin Atkins
884e1fb2a4 terraform: Plans can be "complete" and "applyable"
These ideas are both already implied by some logic elsewhere in the system,
but until now we didn't have the decision logic centralized in a single
place that could therefore evolve over time without necessarily always
updating every caller together.

We'll now have the modules runtime produce its own boolean ruling about
each characteristic, which callers can rely on for the mechanical
decision-making of whether to offer the user an "approve" prompt, and
whether to remind the user after apply that it was an incomplete plan
that will probably therefore need at least one more plan/apply round to
converge.

The "Applyable" flag directly replaces the previous method Plan.CanApply,
with equivalent logic. Making this a field instead of a method means that
we can freeze it as part of a saved plan, rather than recalculating it
when we reload the plan, and we can export the field value in our export
formats like JSON while ensuring it'll always be consistent with what
Terraform is using internally.

Callers can (and should) still use other context in the plan to return
more tailored messages for specific situations they already know about
that might be useful to users, but with these flags as a baseline callers
can now just fall back to a generic presentation when encountering a
situation they don't yet understand, rather than making the wrong decision
and causing something strange to happen. That is: a lack of awareness of
a new rule will now cause just a generic message in the UI, rather than
incorrect behavior.

This commit mostly just deals with populating the flags, and then all of
the direct consequences of that on our various tests. Further changes to
actually make use of these flags elsewhere in the system will follow in
later commits, both in this repository and in other repositories.
2024-02-09 09:24:27 -08:00
Martin Atkins
a4d61733f6 stackplan: Include extra info in raw component instance plan
We'll now track the planned action, the component addresses we depend on,
and the planned output values.
2024-01-08 10:52:01 -08:00
Martin Atkins
972f1c0678 stackplan: Track provider config for every resource instance change
Previously we were still partially relying on the record of this in the
embedded planproto object, but since we're now allowing "planned changes"
that don't actually include a change in that traditional sense we need to
track the provider configuration address separately as a top-level field.

As with some of the addresses before, this means we're now storing the
provider config address redundantly in two places when there _is_ a
planproto change. Hopefully we'll improve that someday, but we don't need
to sweat it too much right now because this only affects the internal
raw plan format that is not subject to any compatibility promises between
releases, so we can freely change it in any future version.
2023-11-15 12:38:56 -08:00
Martin Atkins
4e34e6ebfa stacks: Track prior state for all resource instance objects
Previously our raw plan data structure only included information about
resource instances that have planned actions, which meant we were missing
those which only get their state updated during refresh and don't actually
need any real work done.

Now we'll track everything, accepting that some "planned changes" for
resource instance objects will not actually include a planned change in
the typical sense, and instead only represent a state update.
2023-11-15 12:38:56 -08:00
Martin Atkins
8fd29e9439 stacks: Preserve prior state from plan to apply
We need to retain the prior state (in a form that Terraform Core's modules
runtime can accept) between the plan and apply phases because Terraform
uses it to verify that the provider's "final plan" is consistent with
the initial plan.

We previously tried to do this by reusing the "old" value from the planned
change, but that's not really possible in practice because of the
historical implementation detail that Terraform wants state information
in a JSON format and plan information in MessagePack.

This also contains the beginnings of handling the "discarding" of
unrecognized keys from the state data structures, although we'll probably
need to do more in that area later since this is just the bare minimum.
2023-11-15 12:38:56 -08:00
Martin Atkins
69aa51b9ff stackruntime: Fix some quirks of data sent from plan to apply
We previously took a few shortcuts just to more quickly produce a proof
of concept. This gets us considerably closer to a properly-working handoff
from plan to apply, at least for create, update, and replace actions.

Destroying stuff that's been removed from the configuration will take some
further work since currently everything we do is driven by objects in the
configuration. That will follow in later commits.
2023-11-15 12:38:55 -08:00
Martin Atkins
c67920ce4b stackplan: Add HashiCorp copyright comments 2023-11-15 12:38:55 -08:00
Martin Atkins
fafa36e73a stackeval: ApplyPlan function and initial supporting internals
This is a first pass at actually driving the apply phase through to
completion, using the ChangeExec function to schedule the real change
operations from the plan and then, just like for planning, a visit to
each participating object to ask it to check itself and report the results
of any changes it has made.

Many of our objects don't have any external side-effects of their own and
so just need to check their results are still valid after the apply phase
has replaced unknown values with known values. For those we can mostly
just share the same logic between plan and apply aside from asking for
ApplyPhase instead of PlanPhase.

ComponentInstance and OutputValue are the two objects whose treatment
differs the most between plan and apply, because both of those need to
emit externally-visible "applied change" objects to explain their
side-effects to the caller.

The apply-walk driver has a lot of behavior in common with the existing
plan-walk driver. For this commit we're just accepting that and having
two very similar pieces of code that differ only in some leaf details.
In a future commit we might try to generalize that so we can share more
logic between the two, but only if we can do that without making the code
significantly harder to read.
2023-11-15 12:38:54 -08:00
Martin Atkins
ba8af34679 stackplan: Stub of runtime models for representing plans
This package includes both some model types to represent plans (and parts
thereof) in memory, and logic for translating between the in-memory
representation and our protocol-buffers-based storage serialization.

Unlike the traditional saved plan file format, the stacks model for
planning is slightly asymmetrical: while constructing the plan the system
will emit chunks of the overall plan piecemeal as PlannedChange values,
streamed to the rpcapi client. When reloading that plan to apply it,
the client must provide all of the raw plan blobs in sequence which we
can then decode one by one to construct a single Plan object covering the
entire effect of the plan.

Another intentional asymmetry is that PlannedChange includes enough
information to produce both the raw internal plan representation and the
public-facing plan description, whereas Plan only includes the subset of
information actually required for Terraform Core to apply the plan, from
the raw internal representation exclusively.
2023-11-15 12:38:52 -08:00
Martin Atkins
d857c75e33 stackplan: Initial models for a "meta-plan" over an entire stack 2023-11-15 12:38:51 -08:00