Skip to content

feat(pg-queue): Migrated secret webhook and replication to postgres #3839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

akhilmhdh
Copy link
Member

Description 📣

This is part of persistent queue initiative in which the queue that are critical are moved away from redis to postgres. This PR moves secret replication and webhook to postgres queue.

This PR also corrects the ts infer of secret queue service to make ts infer faster.

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

@maidul98
Copy link
Collaborator

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Migrates critical queue operations from Redis to PostgreSQL for secret webhooks and replication, improving persistence and reliability of the secret management system.

  • Implements PostgreSQL advisory locks and transaction support in secret-rotation-v2-service.ts to handle concurrent operations safely
  • Introduces new TSecretQueueFactory type in secret-types.ts to improve TypeScript inference and maintain type safety across queue operations
  • Adds initialization steps in routes/index.ts to properly sequence secret replication and queue services during server startup
  • Enhances secret approval workflow in secret-approval-request-service.ts with support for encrypted secret values using KMS
  • Maintains backwards compatibility through dual queue support while transitioning from Redis to PostgreSQL

13 files reviewed, 2 comments
Edit PR Review Bot Settings | Greptile

Comment on lines +552 to +559
syncIntegrations: (dto: {
secretPath: string;
projectId: string;
environment: string;
isManual?: boolean;
actorId?: string;
deDupeQueue?: Record<string, boolean>;
}) => Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Consider extracting syncIntegrations DTO into a separate named type for reusability

Comment on lines +861 to 863
queueService.start(QueueName.SecretReplication, async (job) => {
await $secretReplicationQueueTask(job.id as string, job.data);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: Potential race condition: Both Redis and Postgres queues are active simultaneously. Need coordination mechanism or migration strategy to prevent duplicate processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants