Skip to content

Commit

Permalink
chore: set resync duration at caller
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Feb 2, 2022
1 parent 7d53974 commit f176c73
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/secrets-store-csi-driver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func main() {

// token request client
kubeClient := kubernetes.NewForConfigOrDie(cfg)
tokenClient := k8s.NewTokenClient(kubeClient, *driverName)
tokenClient := k8s.NewTokenClient(kubeClient, *driverName, 10*time.Minute)
if err != nil {
klog.ErrorS(err, "failed to create token client")
os.Exit(1)
Expand Down
6 changes: 3 additions & 3 deletions pkg/k8s/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ type TokenClient struct {
}

// NewTokenClient creates a new TokenClient
// The client will be used to request a token for the preconfigured audiences (--audiences) and expiration time.
func NewTokenClient(kubeClient kubernetes.Interface, driverName string) *TokenClient {
// The client will be used to request a token for token requests configured in the CSIDriver.
func NewTokenClient(kubeClient kubernetes.Interface, driverName string, resyncPeriod time.Duration) *TokenClient {
kubeInformerFactory := kubeinformers.NewFilteredSharedInformerFactory(
kubeClient,
time.Minute*10,
resyncPeriod,
corev1.NamespaceAll,
func(options *metav1.ListOptions) {
options.FieldSelector = fmt.Sprintf("metadata.name=%s", driverName)
Expand Down
2 changes: 1 addition & 1 deletion pkg/k8s/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestPodServiceAccountTokenAttrs(t *testing.T) {
return true, tr, nil
}))

tokenClient := NewTokenClient(client, testDriver)
tokenClient := NewTokenClient(client, testDriver, 1*time.Second)
_ = tokenClient.Run(wait.NeverStop)
waitForInformerCacheSync()

Expand Down
2 changes: 1 addition & 1 deletion pkg/rotation/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func newTestReconciler(client client.Reader, s *runtime.Scheme, kubeClient kuber
crdClient: crdClient,
cache: client,
secretStore: secretStore,
tokenClient: k8s.NewTokenClient(kubeClient, "test-driver"),
tokenClient: k8s.NewTokenClient(kubeClient, "test-driver", 1*time.Second),
}, nil
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/secrets-store/nodeserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"path/filepath"
"testing"
"time"

secretsstorev1 "sigs.k8s.io/secrets-store-csi-driver/apis/v1"
"sigs.k8s.io/secrets-store-csi-driver/pkg/k8s"
Expand All @@ -42,7 +43,7 @@ import (
func testNodeServer(t *testing.T, tmpDir string, mountPoints []mount.MountPoint, client client.Client, reporter StatsReporter) (*nodeServer, error) {
t.Helper()
providerClients := NewPluginClientBuilder(tmpDir)
return newNodeServer(tmpDir, "testnode", mount.NewFakeMounter(mountPoints), providerClients, client, client, reporter, k8s.NewTokenClient(fakeclient.NewSimpleClientset(), "test-driver"))
return newNodeServer(tmpDir, "testnode", mount.NewFakeMounter(mountPoints), providerClients, client, client, reporter, k8s.NewTokenClient(fakeclient.NewSimpleClientset(), "test-driver", 1*time.Second))
}

func TestNodePublishVolume(t *testing.T) {
Expand Down

0 comments on commit f176c73

Please sign in to comment.