mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-17 17:55:39 +02:00
Enable slot and publication deletion when stream application is removed (#2684)
* refactor syncing publication section * update createOrUpdateStream function to allow resource deletion when removed from manifest * add minimal FES CRD to enable FES resources creation for E2E test * fix bug of removing manifest slots in syncStream * e2e test: fixing typo with major upgrade test * e2e test: should create and delete FES resource * e2e test: should not delete manual created resources * e2e test: enable cluster role for FES with patching instead of deploying in manifest
This commit is contained in:
@@ -49,9 +49,12 @@ const (
|
||||
getPublicationsSQL = `SELECT p.pubname, string_agg(pt.schemaname || '.' || pt.tablename, ', ' ORDER BY pt.schemaname, pt.tablename)
|
||||
FROM pg_publication p
|
||||
LEFT JOIN pg_publication_tables pt ON pt.pubname = p.pubname
|
||||
WHERE p.pubowner = 'postgres'::regrole
|
||||
AND p.pubname LIKE 'fes_%'
|
||||
GROUP BY p.pubname;`
|
||||
createPublicationSQL = `CREATE PUBLICATION "%s" FOR TABLE %s WITH (publish = 'insert, update');`
|
||||
alterPublicationSQL = `ALTER PUBLICATION "%s" SET TABLE %s;`
|
||||
dropPublicationSQL = `DROP PUBLICATION "%s";`
|
||||
|
||||
globalDefaultPrivilegesSQL = `SET ROLE TO "%s";
|
||||
ALTER DEFAULT PRIVILEGES GRANT USAGE ON SCHEMAS TO "%s","%s";
|
||||
@@ -628,6 +631,14 @@ func (c *Cluster) getPublications() (publications map[string]string, err error)
|
||||
return dbPublications, err
|
||||
}
|
||||
|
||||
func (c *Cluster) executeDropPublication(pubName string) error {
|
||||
c.logger.Infof("dropping publication %q", pubName)
|
||||
if _, err := c.pgDb.Exec(fmt.Sprintf(dropPublicationSQL, pubName)); err != nil {
|
||||
return fmt.Errorf("could not execute drop publication: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// executeCreatePublication creates new publication for given tables
|
||||
// The caller is responsible for opening and closing the database connection.
|
||||
func (c *Cluster) executeCreatePublication(pubName, tableList string) error {
|
||||
|
||||
Reference in New Issue
Block a user