Skip to content

Commit 4fa57d8

Browse files
khushi1310PriteshKiriSarthakJain26
authored
fix: Allow chaos probes with same name across different projects (#5241)
* Refactor MongoDB index creation for ChaosProbeCollection Signed-off-by: khushi1310 <[email protected]> * fix-Cannot reuse probe name after deletion Signed-off-by: khushi1310 <[email protected]> * Update Go base image version to 1.24.6 Signed-off-by: khushi1310 <[email protected]> * Update Go version to 1.24 Signed-off-by: khushi1310 <[email protected]> * reverting go version Signed-off-by: khushi1310 <[email protected]> * reverting go version Signed-off-by: khushi1310 <[email protected]> --------- Signed-off-by: khushi1310 <[email protected]> Co-authored-by: Pritesh Kiri <[email protected]> Co-authored-by: Sarthak Jain <[email protected]>
1 parent b181ed6 commit 4fa57d8

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

chaoscenter/graphql/server/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ USER 65534
3434

3535
CMD ["./server"]
3636

37-
EXPOSE 8080
37+
EXPOSE 8080

chaoscenter/graphql/server/pkg/database/mongodb/init.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,14 @@ func (m *MongoClient) initAllCollection() {
298298

299299
m.ChaosProbeCollection = m.Database.Collection(Collections[ChaosProbeCollection])
300300
_, err = m.ChaosProbeCollection.Indexes().CreateMany(backgroundContext, []mongo.IndexModel{
301-
{
302-
Keys: bson.M{
303-
"name": 1,
304-
},
305-
Options: options.Index().SetUnique(true),
306-
},
307301
{
308302
Keys: bson.D{
309-
{"project_id", 1},
303+
{Key: "name", Value: 1},
304+
{Key: "project_id", Value: 1},
310305
},
306+
Options: options.Index().SetUnique(true).SetPartialFilterExpression(bson.D{{
307+
Key: "is_removed", Value: false,
308+
}}),
311309
},
312310
})
313311
if err != nil {

chaoscenter/graphql/server/pkg/probe/handler/handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ func (p *probeService) ValidateUniqueProbe(ctx context.Context, probeName, proje
709709
query := bson.D{
710710
{"name", probeName},
711711
{"project_id", bson.D{{"$eq", projectID}}},
712+
{"is_removed", false},
712713
}
713714

714715
isUnique, err := p.probeOperator.IsProbeUnique(ctx, query)

0 commit comments

Comments
 (0)