mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 17:57:33 +00:00
fix(queue): reset projection list before each Register
call (#10001)
# Which Problems Are Solved if Zitadel was started using `start-from-init` or `start-from-setup` there were rare cases where a panic occured when `Notifications.LegacyEnabled` was set to false. The cause was a list which was not reset before refilling. # How the Problems Are Solved The list is now reset before each time it gets filled. # Additional Changes Ensure all contexts are canceled for the init and setup functions for `start-from-init- or `start-from-setup` commands. # Additional Context none
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package start
|
package start
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
@@ -29,14 +31,19 @@ Requirements:
|
|||||||
masterKey, err := key.MasterKey(cmd)
|
masterKey, err := key.MasterKey(cmd)
|
||||||
logging.OnError(err).Panic("No master key provided")
|
logging.OnError(err).Panic("No master key provided")
|
||||||
|
|
||||||
initialise.InitAll(cmd.Context(), initialise.MustNewConfig(viper.GetViper()))
|
initCtx, cancel := context.WithCancel(cmd.Context())
|
||||||
|
initialise.InitAll(initCtx, initialise.MustNewConfig(viper.GetViper()))
|
||||||
|
cancel()
|
||||||
|
|
||||||
err = setup.BindInitProjections(cmd)
|
err = setup.BindInitProjections(cmd)
|
||||||
logging.OnError(err).Fatal("unable to bind \"init-projections\" flag")
|
logging.OnError(err).Fatal("unable to bind \"init-projections\" flag")
|
||||||
|
|
||||||
setupConfig := setup.MustNewConfig(viper.GetViper())
|
setupConfig := setup.MustNewConfig(viper.GetViper())
|
||||||
setupSteps := setup.MustNewSteps(viper.New())
|
setupSteps := setup.MustNewSteps(viper.New())
|
||||||
setup.Setup(cmd.Context(), setupConfig, setupSteps, masterKey)
|
|
||||||
|
setupCtx, cancel := context.WithCancel(cmd.Context())
|
||||||
|
setup.Setup(setupCtx, setupConfig, setupSteps, masterKey)
|
||||||
|
cancel()
|
||||||
|
|
||||||
startConfig := MustNewConfig(viper.GetViper())
|
startConfig := MustNewConfig(viper.GetViper())
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
package start
|
package start
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
@@ -34,7 +36,10 @@ Requirements:
|
|||||||
|
|
||||||
setupConfig := setup.MustNewConfig(viper.GetViper())
|
setupConfig := setup.MustNewConfig(viper.GetViper())
|
||||||
setupSteps := setup.MustNewSteps(viper.New())
|
setupSteps := setup.MustNewSteps(viper.New())
|
||||||
setup.Setup(cmd.Context(), setupConfig, setupSteps, masterKey)
|
|
||||||
|
setupCtx, cancel := context.WithCancel(cmd.Context())
|
||||||
|
setup.Setup(setupCtx, setupConfig, setupSteps, masterKey)
|
||||||
|
cancel()
|
||||||
|
|
||||||
startConfig := MustNewConfig(viper.GetViper())
|
startConfig := MustNewConfig(viper.GetViper())
|
||||||
|
|
||||||
|
@@ -43,6 +43,9 @@ func Register(
|
|||||||
queue.ShouldStart()
|
queue.ShouldStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure the slice does not contain old values
|
||||||
|
projections = nil
|
||||||
|
|
||||||
q := handlers.NewNotificationQueries(queries, es, externalDomain, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption)
|
q := handlers.NewNotificationQueries(queries, es, externalDomain, externalPort, externalSecure, fileSystemPath, userEncryption, smtpEncryption, smsEncryption)
|
||||||
c := newChannels(q)
|
c := newChannels(q)
|
||||||
projections = append(projections, handlers.NewUserNotifier(ctx, projection.ApplyCustomConfig(userHandlerCustomConfig), commands, q, c, otpEmailTmpl, notificationWorkerConfig, queue))
|
projections = append(projections, handlers.NewUserNotifier(ctx, projection.ApplyCustomConfig(userHandlerCustomConfig), commands, q, c, otpEmailTmpl, notificationWorkerConfig, queue))
|
||||||
|
Reference in New Issue
Block a user