Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/bbr/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ func (ds *datastore) ConfigMapDelete(configmap *corev1.ConfigMap) {

func (ds *datastore) GetBaseModel(modelName string) string {
trimmedModelName := strings.TrimSpace(modelName)
ds.lock.RLock()
defer ds.lock.RUnlock()
// if the given model name is a LoRA adapter, we should return its base model
if baseModel, ok := ds.loraAdapterToBaseModel[trimmedModelName]; ok {
return baseModel
Expand Down
15 changes: 15 additions & 0 deletions pkg/bbr/datastore/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ func TestConfigMapDelete_MissingBaseModel(t *testing.T) {
}
}

func TestGetBaseModel_ConcurrentRace(t *testing.T) {
ds := NewDatastore()
cm := makeConfigMap(cmName, baseModel, "- a1\n")

go func() {
for i := 0; i < 10000; i++ {
_ = ds.ConfigMapUpdateOrAddIfNotExist(cm)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linter is unhappy when ignoring the error.
maybe add err := ..
and assert.NoError(..)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I should run make ci-lint, it should be working now, thanks @nirrozenbaum

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nirrozenbaum , my previous code is just ds.ConfigMapUpdateOrAddIfNotExist(cm) and this makes CI not happy, updating to _ = ds.ConfigMapUpdateOrAddIfNotExist(cm) is good enough to fix the lint error, hope this is ok.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. as long as the linter is happy, I'm happy 😄

}
}()

for i := 0; i < 10000; i++ {
ds.GetBaseModel("a1")
}
}

func TestConfigMapDelete_BaseModelCount(t *testing.T) {
ds := NewDatastore()
cm1 := makeConfigMap(cmName, baseModel, "- a1\n")
Expand Down
Loading