Skip to content

Commit ebc5100

Browse files
authored
Update dependencies and fix unit-test compatibility
1 parent c663b18 commit ebc5100

13 files changed

Lines changed: 430 additions & 273 deletions

File tree

frontend/crd/controller/trident_mirror_relationship.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (c *TridentCrdController) handleTridentMirrorRelationship(keyItem *KeyItem)
245245
}
246246
} else {
247247
Logx(ctx).WithFields(logFields).WithField("reason", reason).Debug("Invalid TridentMirrorRelationship provided.")
248-
c.recorder.Eventf(mirrorRCopy, corev1.EventTypeWarning, netappv1.MirrorStateInvalid, reason)
248+
c.recorder.Eventf(mirrorRCopy, corev1.EventTypeWarning, netappv1.MirrorStateInvalid, "%s", reason)
249249

250250
if len(mirrorRCopy.Status.Conditions) > 0 {
251251
// For now, we only allow a single volumeMapping which should map to a single status condition
@@ -424,7 +424,7 @@ func (c *TridentCrdController) handleIndividualVolumeMapping(
424424
"Could not find volume at volume handle: %v", localPV.Spec.CSI.VolumeHandle,
425425
)
426426
Logx(ctx).WithFields(logFields).Debug(statusCondition.Message)
427-
c.recorder.Eventf(relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, statusCondition.Message)
427+
c.recorder.Eventf(relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, "%s", statusCondition.Message)
428428
return updateTMRConditionLocalFields(statusCondition, localPVCName, volumeMapping.RemoteVolumeHandle)
429429
}
430430

@@ -435,14 +435,14 @@ func (c *TridentCrdController) handleIndividualVolumeMapping(
435435
statusCondition.Message = "Error checking if localPVC's backend can support mirroring"
436436
Logx(ctx).WithFields(logFields).WithField("PVC", localPVCName).WithError(err).Error(statusCondition.Message)
437437
c.recorder.Eventf(
438-
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, statusCondition.Message)
438+
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, "%s", statusCondition.Message)
439439
return updateTMRConditionLocalFields(statusCondition, localPVCName, volumeMapping.RemoteVolumeHandle)
440440
} else if !mirrorCapable {
441441
statusCondition.MirrorState = netappv1.MirrorStateInvalid
442442
statusCondition.Message = "localPVC's backend does not support mirroring"
443443
Logx(ctx).WithFields(logFields).WithField("PVC", localPVCName).Warn(statusCondition.Message)
444444
c.recorder.Eventf(
445-
relationship, corev1.EventTypeWarning, netappv1.MirrorStateInvalid, statusCondition.Message)
445+
relationship, corev1.EventTypeWarning, netappv1.MirrorStateInvalid, "%s", statusCondition.Message)
446446
return updateTMRConditionLocalFields(statusCondition, localPVCName, volumeMapping.RemoteVolumeHandle)
447447
}
448448
}
@@ -496,7 +496,7 @@ func (c *TridentCrdController) handleIndividualVolumeMapping(
496496
statusCondition.Message = "Could not establish mirror"
497497
Logx(ctx).WithFields(logFields).WithError(err).Error(statusCondition.Message)
498498
c.recorder.Eventf(
499-
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, statusCondition.Message,
499+
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, "%s", statusCondition.Message,
500500
)
501501
} else if api.IsNotReadyError(err) {
502502
update, _ := updateTMRConditionLocalFields(statusCondition, localPVCName,
@@ -521,7 +521,7 @@ func (c *TridentCrdController) handleIndividualVolumeMapping(
521521
statusCondition.Message = "Could not reestablish mirror"
522522
Logx(ctx).WithFields(logFields).WithError(err).Error(statusCondition.Message)
523523
c.recorder.Eventf(
524-
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, statusCondition.Message,
524+
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, "%s", statusCondition.Message,
525525
)
526526
} else {
527527
// If we performed an action, get new mirror state
@@ -543,7 +543,7 @@ func (c *TridentCrdController) handleIndividualVolumeMapping(
543543
statusCondition.Message = "Could not promote mirror"
544544
Logx(ctx).WithFields(logFields).WithError(err).Error(statusCondition.Message)
545545
c.recorder.Eventf(
546-
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, statusCondition.Message,
546+
relationship, corev1.EventTypeWarning, netappv1.MirrorStateFailed, "%s", statusCondition.Message,
547547
)
548548
} else if api.IsNotReadyError(err) {
549549
update, _ := updateTMRConditionLocalFields(statusCondition, localPVCName,
@@ -566,7 +566,7 @@ func (c *TridentCrdController) handleIndividualVolumeMapping(
566566
statusCondition.MirrorState = netappv1.MirrorStateInvalid
567567
statusCondition.Message = err.Error()
568568
Logx(ctx).WithFields(logFields).WithField("PVC", localPVCName).Error(err)
569-
c.recorder.Eventf(relationship, corev1.EventTypeWarning, netappv1.MirrorStateInvalid, statusCondition.Message)
569+
c.recorder.Eventf(relationship, corev1.EventTypeWarning, netappv1.MirrorStateInvalid, "%s", statusCondition.Message)
570570
return updateTMRConditionLocalFields(statusCondition, localPVCName, volumeMapping.RemoteVolumeHandle)
571571
}
572572

frontend/crd/controller/trident_snapshot_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (c *TridentCrdController) handleTridentSnapshotInfo(keyItem *KeyItem) error
116116
"reason": reason,
117117
}
118118
Logx(ctx).WithFields(logFields).Warn("Invalid TridentSnapshotInfo provided.")
119-
c.recorder.Eventf(snapshotInfoCopy, corev1.EventTypeWarning, netappv1.SnapshotInfoInvalid, reason)
119+
c.recorder.Eventf(snapshotInfoCopy, corev1.EventTypeWarning, netappv1.SnapshotInfoInvalid, "%s", reason)
120120
status = &netappv1.TridentSnapshotInfoStatus{}
121121
}
122122

frontend/csi/controller_helpers/kubernetes/helper_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,8 +1678,10 @@ func (m *MockFullIndexer) Delete(obj interface{}) error { return nil }
16781678
func (m *MockFullIndexer) Get(obj interface{}) (item interface{}, exists bool, err error) {
16791679
return nil, false, nil
16801680
}
1681-
func (m *MockFullIndexer) ListKeys() []string { return []string{} }
1682-
func (m *MockFullIndexer) Replace([]interface{}, string) error { return nil }
1681+
func (m *MockFullIndexer) ListKeys() []string { return []string{} }
1682+
func (m *MockFullIndexer) LastStoreSyncResourceVersion() string { return "" }
1683+
func (m *MockFullIndexer) Bookmark(rv string) {}
1684+
func (m *MockFullIndexer) Replace([]interface{}, string) error { return nil }
16831685

16841686
// Required methods for cache.Indexer interface
16851687
func (m *MockFullIndexer) Index(indexName string, obj interface{}) ([]interface{}, error) {

frontend/csi/controller_helpers/kubernetes/plugin_test.go

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ func (f *FakeListWatcher) Watch(options metav1.ListOptions) (watch.Interface, er
6262

6363
type FakeController struct{}
6464

65-
func (f *FakeController) Run(stopCh <-chan struct{}) {}
66-
func (f *FakeController) HasSynced() bool { return true }
65+
func (f *FakeController) Run(stopCh <-chan struct{}) {}
66+
func (f *FakeController) HasSynced() bool { return true }
67+
func (f *FakeController) HasSyncedChecker() cache.DoneChecker {
68+
return newFakeDoneChecker("fake-controller", true)
69+
}
6770
func (f *FakeController) LastSyncResourceVersion() string { return "" }
6871
func (f *FakeController) GetIndexer() cache.Indexer { return &FakeIndexer{} }
6972
func (f *FakeController) AddIndexers(indexers cache.Indexers) error { return nil }
@@ -124,6 +127,8 @@ func (f *FakeIndexer) Update(obj interface{}) error { return nil
124127
func (f *FakeIndexer) Delete(obj interface{}) error { return nil }
125128
func (f *FakeIndexer) List() []interface{} { return nil }
126129
func (f *FakeIndexer) ListKeys() []string { return nil }
130+
func (f *FakeIndexer) LastStoreSyncResourceVersion() string { return "" }
131+
func (f *FakeIndexer) Bookmark(rv string) {}
127132
func (f *FakeIndexer) Get(obj interface{}) (item interface{}, exists bool, err error) {
128133
return nil, false, nil
129134
}
@@ -139,11 +144,13 @@ func (f *FakeIndexer) Resync() error { return nil }
139144

140145
type FakeStore struct{}
141146

142-
func (f *FakeStore) Add(obj interface{}) error { return nil }
143-
func (f *FakeStore) Update(obj interface{}) error { return nil }
144-
func (f *FakeStore) Delete(obj interface{}) error { return nil }
145-
func (f *FakeStore) List() []interface{} { return nil }
146-
func (f *FakeStore) ListKeys() []string { return nil }
147+
func (f *FakeStore) Add(obj interface{}) error { return nil }
148+
func (f *FakeStore) Update(obj interface{}) error { return nil }
149+
func (f *FakeStore) Delete(obj interface{}) error { return nil }
150+
func (f *FakeStore) List() []interface{} { return nil }
151+
func (f *FakeStore) ListKeys() []string { return nil }
152+
func (f *FakeStore) LastStoreSyncResourceVersion() string { return "" }
153+
func (f *FakeStore) Bookmark(rv string) {}
147154
func (f *FakeStore) Get(obj interface{}) (item interface{}, exists bool, err error) {
148155
return nil, false, nil
149156
}
@@ -2374,10 +2381,35 @@ type fakeController struct {
23742381
synced bool
23752382
}
23762383

2384+
type fakeDoneChecker struct {
2385+
name string
2386+
done <-chan struct{}
2387+
}
2388+
2389+
func (f fakeDoneChecker) Name() string {
2390+
return f.name
2391+
}
2392+
2393+
func (f fakeDoneChecker) Done() <-chan struct{} {
2394+
return f.done
2395+
}
2396+
23772397
func (f *fakeController) HasSynced() bool {
23782398
return f.synced
23792399
}
23802400

2401+
func (f *fakeController) HasSyncedChecker() cache.DoneChecker {
2402+
return newFakeDoneChecker("fake-controller", f.synced)
2403+
}
2404+
2405+
func newFakeDoneChecker(name string, synced bool) cache.DoneChecker {
2406+
doneCh := make(chan struct{})
2407+
if synced {
2408+
close(doneCh)
2409+
}
2410+
return fakeDoneChecker{name: name, done: doneCh}
2411+
}
2412+
23812413
// Implement other required methods as no-ops for testing
23822414
func (f *fakeController) AddEventHandler(handler cache.ResourceEventHandler) (cache.ResourceEventHandlerRegistration, error) {
23832415
return nil, nil

frontend/csi/node_server_test.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4894,19 +4894,30 @@ func TestNodePublishVolume_Multithreaded(t *testing.T) {
48944894
}()
48954895

48964896
csiNodeLockTimeout = testNodeLockTimeout
4897+
csiNodeRequestTimeout = testNodeMultithreadedBarrierTimeout
48974898

48984899
ctrl := gomock.NewController(t)
48994900
mockTrackingClient := mockNodeHelpers.NewMockNodeHelper(ctrl)
49004901
mockMount := mock_mount.NewMockMount(ctrl)
49014902

49024903
// Setting up mocks expectation for each request.
49034904
for i := 0; i < numOfRequests; i++ {
4904-
volumeTrackingInfo := &models.VolumeTrackingInfo{
4905-
VolumePublishInfo: NewVolumePublishInfoBuilder(TypeNFSVolumePublishInfo).Build(),
4906-
}
4907-
mockTrackingClient.EXPECT().ReadTrackingInfo(gomock.Any(), gomock.Any()).Return(volumeTrackingInfo, nil)
4905+
// Return fresh tracking structs so concurrent read-only mutations do not race on shared pointers.
4906+
mockTrackingClient.EXPECT().ReadTrackingInfo(gomock.Any(), gomock.Any()).DoAndReturn(
4907+
func(context.Context, string) (*models.VolumeTrackingInfo, error) {
4908+
return &models.VolumeTrackingInfo{
4909+
VolumePublishInfo: NewVolumePublishInfoBuilder(TypeNFSVolumePublishInfo).Build(),
4910+
}, nil
4911+
},
4912+
)
49084913
mockMount.EXPECT().IsLikelyNotMountPoint(gomock.Any(), gomock.Any()).Return(true, nil)
4909-
mockTrackingClient.EXPECT().ReadTrackingInfo(gomock.Any(), gomock.Any()).Return(volumeTrackingInfo, nil)
4914+
mockTrackingClient.EXPECT().ReadTrackingInfo(gomock.Any(), gomock.Any()).DoAndReturn(
4915+
func(context.Context, string) (*models.VolumeTrackingInfo, error) {
4916+
return &models.VolumeTrackingInfo{
4917+
VolumePublishInfo: NewVolumePublishInfoBuilder(TypeNFSVolumePublishInfo).Build(),
4918+
}, nil
4919+
},
4920+
)
49104921
mockMount.EXPECT().AttachNFSVolume(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
49114922
mockTrackingClient.EXPECT().AddPublishedPath(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
49124923
}
@@ -4926,11 +4937,11 @@ func TestNodePublishVolume_Multithreaded(t *testing.T) {
49264937
wg.Add(numOfRequests)
49274938

49284939
for i := 0; i < numOfRequests; i++ {
4929-
go func() {
4940+
go func(index int) {
49304941
defer wg.Done()
4931-
_, err := plugin.NodePublishVolume(context.Background(), requests[i])
4942+
_, err := plugin.NodePublishVolume(context.Background(), requests[index])
49324943
assert.NoError(t, err)
4933-
}()
4944+
}(i)
49344945
}
49354946

49364947
wg.Wait()
@@ -5805,7 +5816,7 @@ func TestNodePublishSMBVolume_Multithreaded(t *testing.T) {
58055816
csiNodeRequestTimeout = csiKubeletTimeoutTemp
58065817
}(csiNodeLockTimeout, csiNodeRequestTimeout)
58075818

5808-
csiNodeRequestTimeout = testNodeRequestTimeoutShort
5819+
csiNodeRequestTimeout = testNodeMultithreadedBarrierTimeout
58095820
ctx, cancel := context.WithTimeout(ctx, csiNodeRequestTimeout)
58105821
defer cancel()
58115822

0 commit comments

Comments
 (0)