Defining a field in both forProvider
and initProvider
may cause an infinite update loop
#299
Labels
Milestone
forProvider
and initProvider
may cause an infinite update loop
#299
What happened?
I discovered this bug while working on supporting
initProvider
-related behavior in no-fork external client. An infinite update loop occurs when the following conditions hold at the same time:initProvider
andforProvider
,schema.TypeSet
, such asmanaged_policy_arns
,initProvider
has more elements than corresponding one inforProvider
.Provider reports “Cannot observe external resource” and an event is published with message: “cannot run refresh: refresh failed: Invalid index: Elements of a set are identified only by their value and don't have any separate index or key to select with, so it's only possible to perform operations across all elements of the set.”
The problem stems from the fact that Upjet puts
initProvider
-exclusive fields into Terraform'signore_changes
lifecycle meta argument. Even though not explicitly specified, Terraform documentation suggests thatignore_changes
doesn't support sets:Currently, we use index notation, like
set[0]
, for sets as well.I can't think of an easy resolution. We cannot ignore changes in the whole set, because doing so would prevent the values defined in
forProvider
to take effect. We can letforProvider
overwriteinitProvider
, in which case we should decide whether we do so for lists and maps as well.How can we reproduce it?
We will create an IAM Role to reproduce the issue. Because we will use
managed_policy_arns
that refers to IAM Policy resources, we will begin with creating IAM Policies.initProvider.managedPolicyArns
to have more elements thanforProvider.managedPolicyArns
, to be able to reproduce the bug.Related Issues
#298 (duplicate of crossplane-contrib/provider-upjet-aws#946), #295
The text was updated successfully, but these errors were encountered: