crossplane / crossplane/upjet

Overriding an `initProvider` list in `forProvider` after the resource is created may cause an update loop

Open
#303 0 comments 0 reactions 0 assignees View on GitHub
bug reconciler v2
Dominant language
Go
Stars
481
Forks
131
Avg merge
2d 1h
Merged PRs (30d)
11

Description

### What happened?

This is a known issue of Upjet v1.0.0. An infinite update loop occurs when the following conditions hold at the same time:

1. The resource is created with an `initProvider` field of type `schema.TypeList`, [such as `private_ip_list`](https://github.com/hashicorp/terraform-provider-aws/blob/0dbed883d0d6c895eadf1404c36f8173dcdaf635/internal/service/ec2/vpc_network_interface.go#L174),
2. After the resource is created, the field is overridden in `forProvider`,
3. Overriding value has different length than overridden value.

The problem stems from the fact that length keys are deleted from diffs of `initProvider`-exclusive fields. Details are explained in [comments](https://github.com/crossplane/upjet/blob/bed1fa2fdde426e6beaf61aa51f490e0303b6f17/pkg/controller/external_nofork.go#L333-L342).

I have developed a [work-in-progress potential solution](https://github.com/mergenci/upjet/commit/0adc5e51f0757e8e43f7cc48e61a5d5107c02c21), which has neither been tested in depth nor reviewed.

### How can we reproduce it?

We will create a VPC Network Interface to reproduce the issue. Because the resource depends on a VPC Subnet, which in-turn depends on a VPC, we will first create those.

1. Create VPC and Subnet resources by applying the following configuration (Note: These resources can be monitored from [VPC Console](https://us-west-1.console.aws.amazon.com/vpcconsole/home?region=us-west-1#vpcs:) and [Subnet Console](https://us-west-1.console.aws.amazon.com/vpcconsole/home?region=us-west-1#subnets:)):
```
apiVersion: ec2.aws.upbound.io/v1beta1
kind: VPC
metadata:
name: test-upjet-issue-303-vpc
spec:
forProvider:
region: us-west-1
cidrBlock: 172.16.0.0/16
tags:
Name: test-upjet-issue-303-vpc

---

apiVersion: ec2.aws.upbound.io/v1beta1
kind: Subnet
metadata:
name: test-upjet-issue-303-subnet
spec:
forProvider:
region: us-west-1
availabilityZone: us-west-1b
cidrBlock: 172.16.10.0/24
vpcIdRef:
name: test-upjet-issue-303-vpc
```

2. Create Network Interface by applying the following configuration (Note: [Network Interface Console](https://us-west-1.console.aws.amazon.com/ec2/home?region=us-west-1#NIC:) is under [EC2 Console](https://us-west-1.console.aws.amazon.com/ec2/home?region=us-west-1#Home:)):
```
apiVersion: ec2.aws.upbound.io/v1beta1
kind: NetworkInterface
metadata:
name: test-upjet-issue-303-networkinterface
spec:
initProvider:
privateIpListEnabled: True
privateIpList:
- "172.16.10.100"
- "172.16.10.101"
- "172.16.10.102"
forProvider:
region: us-west-1
subnetIdRef:
name: test-upjet-issue-303-subnet
```

3. Modify the resource by applying the following configuration:
```
apiVersion: ec2.aws.upbound.io/v1beta1
kind: NetworkInterface
metadata:
name: test-upjet-issue-303-networkinterface
spec:
initProvider:
privateIpListEnabled: True
privateIpList:
- "172.16.10.100"
- "172.16.10.101"
- "172.16.10.102"
forProvider:
region: us-west-1
privateIpList:
- "172.16.10.103"
- "172.16.10.104"
subnetIdRef:
name: test-upjet-issue-303-subnet
```

4. Check out provider logs to see the update loop. You can apply the configuration in Step 2 above, to stop the update loop.

### Related Issues

#298 (duplicate of https://github.com/upbound/provider-aws/issues/946), #295, #299

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.