Skip to content

Commit

Permalink
fix(core): ensure needsReload flag works (#5211)
Browse files Browse the repository at this point in the history
* fix(core): ensure needsReload flag works

That's a function, not a boolean we were evaluating so it always
returned true. This fixes that.

* fix(server): fix load config error handling
  • Loading branch information
eysi09 committed Oct 9, 2023
1 parent c9417ed commit cdf65e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/server/instance-manager.ts
Expand Up @@ -236,7 +236,7 @@ export class GardenInstanceManager {

// Flag the instance for reloading when configs change
garden.events.once("configChanged", (_payload) => {
if (!garden.needsReload) {
if (!garden.needsReload()) {
garden.needsReload(true)
garden.log.info(
chalk.magenta.bold(
Expand Down
15 changes: 9 additions & 6 deletions core/src/server/server.ts
Expand Up @@ -884,22 +884,25 @@ export class GardenServer extends EventEmitter {
})

let graph: ConfigGraph | undefined
let errors: GardenError[] = []
let error: GardenError | undefined

try {
graph = await garden.getConfigGraph({ log, emit: true })
loadConfigLog.success("Config loaded")
} catch (error) {
errors.push(toGardenError(error))
} catch (err) {
error = toGardenError(err)
} finally {
loadConfigLog.success(`Loading config failed with error: ${errors[0].message}`)
if (error) {
loadConfigLog.error(`Loading config failed with error: ${error.message}`)
} else {
loadConfigLog.success("Config loaded")
}
await cloudEventStream.close() // Note: This also flushes events
send(
"commandResult",
sanitizeValue({
requestId,
result: graph,
errors,
errors: [error],
})
)
}
Expand Down

0 comments on commit cdf65e3

Please sign in to comment.