Skip to content

Commit

Permalink
Fix: Helm Release fails with "the server could not find the requested…
Browse files Browse the repository at this point in the history
… resource" (#2677)

<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

### Proposed changes

<!--Give us a brief description of what you've done and what it solves.
-->

This PR fixes an intermittent problem that resembles:
```
 kubernetes:helm.sh/v3:Release (mongodb):
    error: 1 error occurred:
    	* Helm release "mongodb/mongodb-456643ba" failed to initialize completely. Use Helm CLI to investigate.: failed to become available within allocated timeout. Error: 
          Helm Release mongodb/mongodb-456643ba: release mongodb-456643ba failed, and has been rolled back due to atomic being set: 
          failed to create resource: the server could not find the requested resource
```

The problem was that a Go struct (containing a client-go rest config)
was being shared and mutated by numerous independent routines. The
solution was to copy the struct.

### Related issues (optional)

<!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes
#1234'.
Or link to full URLs to issues or pull requests in other GitHub
repositories. -->

Closes #2481
  • Loading branch information
EronWright authored Nov 28, 2023
1 parent d90d153 commit b045235
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

- Fix: compute version field in Check for content detection (https://github.com/pulumi/pulumi-kubernetes/pull/2672)

- Fix: Fix: Helm Release fails with "the server could not find the requested resource" (https://github.com/pulumi/pulumi-kubernetes/pull/2677)

## 4.5.4 (November 8, 2023)
- Fix: Helm Release: chart requires kubeVersion (https://github.com/pulumi/pulumi-kubernetes/pull/2653)

Expand Down
8 changes: 5 additions & 3 deletions provider/pkg/provider/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ type KubeConfig struct {

// ToDiscoveryClient implemented interface method
func (k *KubeConfig) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error) {
c := rest.CopyConfig(k.restConfig)

// The more groups you have, the more discovery requests you need to make.
// given 25 groups (our groups + a few custom resources) with one-ish version each, discovery needs to make 50 requests
// double it just so we don't end up here again for a while. This config is only used for discovery.
k.restConfig.Burst = 100
c.Burst = 100

return clients.NewMemCacheClient(discovery.NewDiscoveryClientForConfigOrDie(k.restConfig)), nil
return clients.NewMemCacheClient(discovery.NewDiscoveryClientForConfigOrDie(c)), nil
}

// ToRESTConfig implemented interface method
func (k *KubeConfig) ToRESTConfig() (*rest.Config, error) {
return k.restConfig, nil
return rest.CopyConfig(k.restConfig), nil
}

// ToRESTMapper implemented interface method
Expand Down

0 comments on commit b045235

Please sign in to comment.