Fix #2733 "cscli hang forever when i try to delete a decision" (#2745)

This commit is contained in:
mmetc 2024-01-16 09:16:21 +01:00 committed by GitHub
parent c6e4762f28
commit 24b5e8f100
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -245,12 +245,14 @@ func NewServer(config *csconfig.LocalApiServerCfg) (*APIServer, error) {
if apiClient.apiClient.IsEnrolled() {
log.Infof("Machine is enrolled in the console, Loading PAPI Client")
papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel)
if err != nil {
return nil, err
}
if config.ConsoleConfig.IsPAPIEnabled() {
papiClient, err = NewPAPI(apiClient, dbClient, config.ConsoleConfig, *config.PapiLogLevel)
if err != nil {
return nil, err
}
controller.DecisionDeleteChan = papiClient.Channels.DeleteDecisionChannel
controller.DecisionDeleteChan = papiClient.Channels.DeleteDecisionChannel
}
} else {
log.Errorf("Machine is not enrolled in the console, can't synchronize with the console")
}
@ -317,7 +319,7 @@ func (s *APIServer) Run(apiReady chan bool) error {
//csConfig.API.Server.ConsoleConfig.ShareCustomScenarios
if s.apic.apiClient.IsEnrolled() {
if s.consoleConfig.ConsoleManagement != nil && *s.consoleConfig.ConsoleManagement {
if s.consoleConfig.IsPAPIEnabled() {
if s.papi.URL != "" {
log.Infof("Starting PAPI decision receiver")
s.papi.pullTomb.Go(func() error {

View file

@ -30,6 +30,13 @@ type ConsoleConfig struct {
ShareContext *bool `yaml:"share_context"`
}
func (c *ConsoleConfig) IsPAPIEnabled() bool {
if c == nil || c.ConsoleManagement == nil {
return false
}
return *c.ConsoleManagement
}
func (c *LocalApiServerCfg) LoadConsoleConfig() error {
c.ConsoleConfig = &ConsoleConfig{}
if _, err := os.Stat(c.ConsoleConfigPath); err != nil && os.IsNotExist(err) {