both sidecar & controller update BucketClaim status #101
Description
While going through the codes of 'controller' & 'sidecar', I see that both sidecar & controller are updating status of the bucketclaim (within the scope of method BucketClaimListener#provisionBucketClaimOperation).
https://github.com/kubernetes-sigs/container-object-storage-interface-provisioner-sidecar/blob/80979e8992a6a2b2166f3ff1e7d39b4ab03f045c/pkg/bucket/bucket_controller.go#L163
https://github.com/kubernetes-sigs/container-object-storage-interface-controller/blob/38b4915c1bbc6b63144fa81351a72d228184a34c/pkg/bucketclaim/bucketclaim.go#L204
In this scenario, the bucketclaim object with the method(provisionBucketClaimOperation) of controller gets outdated, once sidecar updates the bucketClaim CR's status.
A suggestion from our side is to follow sidecar's approach with controller as well.
- Before updating bucket claim status in the given method (BucketClaimListener#provisionBucketClaimOperation).
https://github.com/kubernetes-sigs/container-object-storage-interface-controller/blob/38b4915c1bbc6b63144fa81351a72d228184a34c/pkg/bucketclaim/bucketclaim.go#L204 - Fetch updated bucketClaim & set the values for fields 'bucketClaim.Status.BucketName' & 'bucketClaim.Status.BucketReady' in the latest bucketClaim object & then use it for UpdateStatus.
https://github.com/kubernetes-sigs/container-object-storage-interface-provisioner-sidecar/blob/80979e8992a6a2b2166f3ff1e7d39b4ab03f045c/pkg/bucket/bucket_controller.go#L154
Note:
We didnt notice this issue, when bucket claims were created sequentially, with adequate time-gap. And happened to notice it when bucketclaims were created parallely (and sequentially without adequate time gap through scripts/yaml's).
Lets us know, if we could help further.
CC: @vegullah
Originally posted by @narayviv in kubernetes-retired/container-object-storage-interface-controller#139 (comment)