crossplane / crossplane/crossplane

TestPackageRevisionLifeCycle is flaky due to asynchronous revision update

Open Beginner friendly
#7,683 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
12.1k
Forks
1.3k
Avg merge
1d 6h
Merged PRs (30d)
46

Description

### What happened?

`TestPackageRevisionLifeCycle` is occasionally flaky.

The test updates a `Function` resource and waits for:

```go
metadata.generation == 2
```

It then immediately verifies that `status.currentRevision` has changed.

However, `metadata.generation` is updated by the API server as soon as the spec
changes, while `status.currentRevision` is updated asynchronously by the package
reconciler. There is a reconciliation window where the generation has already
been incremented but the current revision still points to the previous
`FunctionRevision`.

This occasionally causes failures such as:

```
expected current revision to change, still "function-image-config-runtime-..."
```

The issue appears to be limited to the test synchronization rather than the
runtime behavior itself.

### How can we reproduce it?

Run the package lifecycle E2E test repeatedly, for example:

```bash
./nix.sh run .#e2e -- \
-test.run '^TestPackageRevisionLifeCycle$'
```

The failure is intermittent and may require several runs before reproducing.

### Suggested fix

Instead of checking `status.currentRevision` immediately after
`metadata.generation` changes, the test should wait until the current revision
actually changes (or until the new `FunctionRevision` becomes the current and
healthy revision).

This would synchronize the test on the state it is actually validating, rather
than on an intermediate reconciliation step.

### What environment did it happen in?

Crossplane version: current `main` (observed after commit `93cc669a6`)

Kubernetes: Kind (E2E test environment)

Contributor guide

Open the contributing guide

Research direction

Run the package lifecycle E2E test with `./nix.sh run .#e2e -- -test.run '^TestPackageRevisionLifeCycle$'` and locate `TestPackageRevisionLifeCycle`. Read the existing wait for `metadata.generation == 2`; synchronize next on the changed or healthy `status.currentRevision`, then repeat the test to confirm the intermittent failure is gone.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.