Skip to content

Commit

Permalink
disk/status-waiter: add a hook to workaround credential refresh
Browse files Browse the repository at this point in the history
should be reverted once we have a ecsClient that can refresh its credentials
  • Loading branch information
huww98 committed Aug 29, 2024
1 parent ff7f810 commit ad5a9d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/aliyun/alibaba-cloud-sdk-go/services/ecs"
"github.com/container-storage-interface/spec/lib/go/csi"
snapClientset "github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/cloud"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/cloud/metadata"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/common"
"github.com/kubernetes-sigs/alibaba-cloud-csi-driver/pkg/features"
Expand Down Expand Up @@ -249,6 +250,9 @@ func newDiskStatusWaiter() DiskStatusWaiter {
return &SimpleDiskStatusWaiter{}
} else {
waiter := NewBatchedDiskStatusWaiter(GlobalConfigVar.EcsClient, clock.RealClock{})
waiter.PollHook = func() cloud.ECSInterface {
return updateEcsClient(GlobalConfigVar.EcsClient)
}
go waiter.Run(context.Background())
return waiter
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/disk/wait_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type waitRequest struct {

type BatchedDiskStatusWaiter struct {
ecsClient cloud.ECSInterface
// remove this once we have a ecsClient that can refresh its credentials
PollHook func() cloud.ECSInterface

requestChan chan *waitRequest
requests map[string][]*waitRequest
Expand Down Expand Up @@ -91,6 +93,9 @@ func (w *BatchedDiskStatusWaiter) Run(ctx context.Context) {
pollChan = w.clk.After(pollInterval - w.clk.Since(lastPollTime))
}
case t := <-pollChan:
if w.PollHook != nil {
w.ecsClient = w.PollHook()
}
var err error
w.idQueue, err = w.poll(w.idQueue)
lastPollTime = t
Expand Down

0 comments on commit ad5a9d5

Please sign in to comment.