Skip to content

Commit 4585d81

Browse files
committed
fix test
1 parent 8bcf217 commit 4585d81

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/services/provisioning/datasources/datasources.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ func (dc *DatasourceProvisioner) deleteDatasources(ctx context.Context, dsToDele
154154
for _, ds := range dsToDelete {
155155
cmd := &datasources.DeleteDataSourceCommand{OrgID: ds.OrgID, Name: ds.Name}
156156
getDsQuery := &datasources.GetDataSourceQuery{Name: ds.Name, OrgId: ds.OrgID}
157-
if err := dc.store.GetDataSource(ctx, getDsQuery); !errors.Is(err, datasources.ErrDataSourceNotFound) {
157+
if err := dc.store.GetDataSource(ctx, getDsQuery); err != nil && !errors.Is(err, datasources.ErrDataSourceNotFound) {
158158
return err
159159
}
160160

161161
if err := dc.store.DeleteDataSource(ctx, cmd); err != nil {
162162
return err
163163
}
164164

165-
if cmd.DeletedDatasourcesCount > 0 {
165+
if getDsQuery.Result != nil {
166166
if err := dc.correlationsStore.DeleteCorrelationsBySourceUID(ctx, correlations.DeleteCorrelationsBySourceUIDCommand{
167167
SourceUID: getDsQuery.Result.Uid,
168168
}); err != nil {
@@ -175,6 +175,10 @@ func (dc *DatasourceProvisioner) deleteDatasources(ctx context.Context, dsToDele
175175
return err
176176
}
177177

178+
dc.log.Info("deleted correlations based on configuration", "ds_name", ds.Name)
179+
}
180+
181+
if cmd.DeletedDatasourcesCount > 0 {
178182
dc.log.Info("deleted datasource based on configuration", "name", ds.Name)
179183
}
180184
}

0 commit comments

Comments
 (0)