diff --git a/CHANGELOG.md b/CHANGELOG.md index a98e074f0..53754346a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +## HEAD (Unreleased) + +- Use the update token for renew_lease calls and update the API version to 5. + [#3348](https://github.com/pulumi/pulumi/pull/3348) + ## 1.4.1 (2019-11-01) - Adds a **preview** of .NET support for Pulumi. This code is an preview state and is subject diff --git a/pkg/apitype/updates.go b/pkg/apitype/updates.go index d680d5104..7ea87853f 100644 --- a/pkg/apitype/updates.go +++ b/pkg/apitype/updates.go @@ -173,6 +173,9 @@ type UpdateProgram struct { // RenewUpdateLeaseRequest defines the body of a request to the update lease renewal endpoint of the service API. type RenewUpdateLeaseRequest struct { // The current, valid lease token. + // DEPRECATED as of Pulumi API version 5+. Pulumi API will expect the update token + // in the Authorization header instead of this property. This property will be removed + // when the minimum supported API version on the service is raised to 5. Token string `json:"token"` // The duration for which to renew the lease in seconds (maximum 300). Duration int `json:"duration"` diff --git a/pkg/backend/httpstate/client/api.go b/pkg/backend/httpstate/client/api.go index 0e707c9a8..47c7532c5 100644 --- a/pkg/backend/httpstate/client/api.go +++ b/pkg/backend/httpstate/client/api.go @@ -165,7 +165,7 @@ func pulumiAPICall(ctx context.Context, d diag.Sink, cloudAPI, method, path stri userAgent := fmt.Sprintf("pulumi-cli/1 (%s; %s)", version.Version, runtime.GOOS) req.Header.Set("User-Agent", userAgent) // Specify the specific API version we accept. - req.Header.Set("Accept", "application/vnd.pulumi+4") + req.Header.Set("Accept", "application/vnd.pulumi+5") // Apply credentials if provided. if tok.String() != "" { diff --git a/pkg/backend/httpstate/client/client.go b/pkg/backend/httpstate/client/client.go index 2e86e9c2b..973f12634 100644 --- a/pkg/backend/httpstate/client/client.go +++ b/pkg/backend/httpstate/client/client.go @@ -596,7 +596,6 @@ func (pc *Client) RenewUpdateLease(ctx context.Context, update UpdateIdentifier, duration time.Duration) (string, error) { req := apitype.RenewUpdateLeaseRequest{ - Token: token, Duration: int(duration / time.Second), } var resp apitype.RenewUpdateLeaseResponse @@ -604,8 +603,8 @@ func (pc *Client) RenewUpdateLease(ctx context.Context, update UpdateIdentifier, // While renewing a lease uses POST, it is safe to send multiple requests (consider that we do this multiple times // during a long running update). Since we would fail our update operation if we can't renew our lease, we'll retry // these POST operations. - if err := pc.restCallWithOptions(ctx, "POST", getUpdatePath(update, "renew_lease"), nil, - req, &resp, httpCallOptions{RetryAllMethods: true}); err != nil { + if err := pc.updateRESTCall(ctx, "POST", getUpdatePath(update, "renew_lease"), nil, req, &resp, + updateAccessToken(token), httpCallOptions{RetryAllMethods: true}); err != nil { return "", err } return resp.Token, nil