Open vbontempi opened 9 months ago
When initializing the Cloudant client for the newly provisioned service the resource does: https://github.com/IBM-Cloud/terraform-provider-ibm/blob/819a586e652748b9682e060412d89845d89c5f45/ibm/service/cloudant/resource_ibm_cloudant.go#L384
to later obtain a bearer token https://github.com/IBM-Cloud/terraform-provider-ibm/blob/819a586e652748b9682e060412d89845d89c5f45/ibm/service/cloudant/resource_ibm_cloudant.go#L390
the meta
used to get the session
is passed into resourceIBMCloudantCreate
when the resource create starts.
On Feb 23rd instances were created as normal, but for a short window there were long delays in them being recognized as provisioned. In this case there was longer than the token lifetime inbetween the start of resourceIBMCloudantCreate
and the call to get the BluemixSession()
. Whilst this is extremely unusual it would be good to handle it better if it does happen and refresh the token if necessary.
I'm not sure on the expected pattern in the provider for this, it seems wasteful to call RefreshToken(session)
every time when the token will nearly always be valid. Equally the Cloudant resource does not seem like the right place to be decoding a session bearer token and checking if it is expired.
Some possible options:
RefreshToken
is modifed to do an expiry check and we add a call to it when setting up the Cloudant clientRefreshIfExpired
and we call that when setting up the Cloudant clientBluemixSession()
is modified to do a refresh if necessaryRefreshToken
every time when setting up the Cloudant client even though it is wasteful most of the timeIt would be good to hear the maintainers' thoughts on this.
Creation of Cloudant instance using ibm_cloudant is failing when the instance deployment takes more than one hour to complete the deployment.
After one hour the cached token expires and it isn't refreshed Logs below of local execution with terraform debug log enabled: as found from the logs the token expiration is correctly handled with catalog APIs, but the same is not done with cloudant instance APIs when triggering the PUT request to set CORS config
Community Note
Terraform CLI and Terraform IBM Provider Version
terraform version 1.7.4.
terraform ibm provider
Affected Resource(s)
Debug Output
pasted above
Steps to Reproduce
template to debug the issue
terraform apply