mirror of
https://github.com/zitadel/zitadel
synced 2024-11-22 08:49:13 +00:00
17953e9040
Even though this is a feature it's released as fix so that we can back port to earlier revisions. As reported by multiple users startup of ZITADEL after leaded to downtime and worst case rollbacks to the previously deployed version. The problem starts rising when there are too many events to process after the start of ZITADEL. The root cause are changes on projections (database tables) which must be recomputed. This PR solves this problem by adding a new step to the setup phase which prefills the projections. The step can be enabled by adding the `--init-projections`-flag to `setup`, `start-from-init` and `start-from-setup`. Setting this flag results in potentially longer duration of the setup phase but reduces the risk of the problems mentioned in the paragraph above.
69 lines
1.6 KiB
Go
69 lines
1.6 KiB
Go
package setup
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/command"
|
|
"github.com/zitadel/zitadel/internal/config/systemdefaults"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
type externalConfigChange struct {
|
|
es *eventstore.Eventstore
|
|
ExternalDomain string `json:"externalDomain"`
|
|
ExternalSecure bool `json:"externalSecure"`
|
|
ExternalPort uint16 `json:"externalPort"`
|
|
|
|
currentExternalDomain string
|
|
currentExternalSecure bool
|
|
currentExternalPort uint16
|
|
defaults systemdefaults.SystemDefaults
|
|
}
|
|
|
|
func (mig *externalConfigChange) Check(lastRun map[string]interface{}) bool {
|
|
mig.currentExternalDomain, _ = lastRun["externalDomain"].(string)
|
|
externalPort, _ := lastRun["externalPort"].(float64)
|
|
mig.currentExternalPort = uint16(externalPort)
|
|
mig.currentExternalSecure, _ = lastRun["externalSecure"].(bool)
|
|
return mig.currentExternalSecure != mig.ExternalSecure ||
|
|
mig.currentExternalPort != mig.ExternalPort ||
|
|
mig.currentExternalDomain != mig.ExternalDomain
|
|
}
|
|
|
|
func (mig *externalConfigChange) Execute(ctx context.Context, _ eventstore.Event) error {
|
|
cmd, err := command.StartCommands(
|
|
mig.es,
|
|
mig.defaults,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
mig.ExternalDomain,
|
|
mig.ExternalSecure,
|
|
mig.ExternalPort,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
0,
|
|
0,
|
|
0,
|
|
nil,
|
|
)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return cmd.ChangeSystemConfig(ctx, mig.currentExternalDomain, mig.currentExternalPort, mig.currentExternalSecure)
|
|
}
|
|
|
|
func (mig *externalConfigChange) String() string {
|
|
return "config_change"
|
|
}
|