pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

Request for application registration duplicate check function

Open jo-jo-1217 opened this issue 3 years ago • 5 comments

I would like to have a duplicate check function when registering applications with the pipectl add command.

I have many services and projects, and I am having trouble registering applications with the pipectl add command, because the same applications can be registered.

jo-jo-1217 avatar Jul 08 '22 07:07 jo-jo-1217

Successfully (sadly), I reproduced the situation as below:

1. Run a piped

2. Execute the following pipectl command once

pipectl application add \
    --address=xxx \
    --api-key-file=xxx \
    --app-name=duplicate-1 \
    --app-kind=ECS \
    --piped-id=xxx \
    --platform-provider=ecs-dev \
    --repo-id=xxx \
    --app-dir=xxx

-> Successfully added application id = d38a75b1-761a-4b42-b62c-16bd8ab0f3a2

3. Again, execute the same command as 2.

-> Successfully added application id = 8fb1d9e0-c81d-487c-b567-6362d5336c86 Another app with another ID is created.

apps UI:

Image deployments for each app were triggered: Image

t-kikuc avatar Apr 23 '25 02:04 t-kikuc

I would like work on this

Tushar240503 avatar May 16 '25 05:05 Tushar240503

Hi @Tushar240503 I mentioned how to process this issue via this PR comment 👍 You're on the right track 🙌 https://github.com/pipe-cd/pipecd/pull/5840#discussion_r2115050840

khanhtc1202 avatar May 30 '25 02:05 khanhtc1202

@Tushar240503 This is a short explanation for the flow mentioned in the above comment

Case: Want to use SyncState.Status field of Application model in queries, in case of MySQL datastore

(1) Create Virtual Column SyncState_Status and store it in Application table index: https://github.com/pipe-cd/pipecd/blob/c1ca195128301d0b12ad69971c28b8c702e7aacb/pkg/datastore/mysql/ensurer/indexes.sql#L17 (2) In refined filter function, change the SyncState.Status given in PipeCD datastore, to field convention that works in MySQL: https://github.com/pipe-cd/pipecd/blob/c1ca195128301d0b12ad69971c28b8c702e7aacb/pkg/datastore/mysql/query.go#L204-L216 (3) In caller place, just use it as is (mention it as field name SyncState.Status: https://github.com/pipe-cd/pipecd/blob/c1ca195128301d0b12ad69971c28b8c702e7aacb/pkg/app/server/grpcapi/web_api.go#L658-L664

Then all done

Case: Same field but for GCP Firestore database: You need to create indexes on Firestore like this, to make the Firestore process your query https://github.com/pipe-cd/pipecd/blob/c1ca195128301d0b12ad69971c28b8c702e7aacb/pkg/app/ops/firestoreindexensurer/indexes.json#L82-L89

Point: We have to refine the name of the field SyncState.Status to SyncState_Status because

  • Firestore supports SyncState.Status without an alias name, so the only way to make it is to keep the path the same with .
  • MySQL, on the other hand, doesn't allow . as part of the field name
  • To keep the interface the same for both datastores, we chose . in queries, and added logic to convert the field name before giving it to the MySQL engine

Hope this help 👌

khanhtc1202 avatar May 30 '25 03:05 khanhtc1202

@khanhtc1202 thank you for the inputs

Tushar240503 avatar May 30 '25 18:05 Tushar240503