knative / knative/serving

ECR credentials provider in k8schain makes revision reconciler tests slow

Open
#10,878 4 comments 0 reactions 0 assignees View on GitHub
area/API kind/feature triage/accepted
Dominant language
Go
Stars
6.1k
Forks
1.2k
Avg merge
2d 7h
Merged PRs (30d)
2

Description

/area API

## Describe the feature

When iterating on tests in `reconciler/revision` I noticed they take 10+ seconds to run. The main culprit seems to be [`TestResolve()`](https://github.com/knative/serving/blob/32eabd48fc03d1f16ae2508d7b50cc9e9ebb8280/pkg/reconciler/revision/resolve_test.go#L145) which (via `Resolve()`) creates a k8schain to test resolving digests. Unfortunately this code iterates all the credential providers to auto-detect what to use and the ECR provider, at least on my computer, takes ages to fail :(.

Passing [`--tags disable_aws` to disable that provider](https://github.com/google/go-containerregistry/blob/main/pkg/authn/k8schain/k8schain_aws.go#L1) drops the test from seconds to milliseconds, but I doubt many people will guess to do this (and they shouldn't have to). There may be some other magic way to disable ECR from k8schain, but because it gets loaded implicitly via `init` if the file isn't excluded via build tags I couldn't find anything obvious.

An easy workaround for now may be to just move `resolve*.go` to its own subpackage, which is probably a worthwhile refactor anyway so I'll probably look at doing that if no-one hates the idea for any reason. Or maybe we should just disable the test in `--short` mode 🤷.

Contributor guide

Open the contributing guide

Research direction

Start with TestResolve() in reconciler/revision/resolve_test.go and follow its call to Resolve(), then inspect how k8schain discovers credential providers. Compare the current runtime with the --tags disable_aws workaround and review the resolve*.go organization. Done means revision tests retain digest-resolution coverage without taking 10+ seconds.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
performance, testing-qa
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.