Merge pull request 'daemon: improve error messages' (#179) from Frankkkkk/runner:main into main

Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/179
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
pull/163/head
earl-warren 2024-04-10 21:42:49 +00:00
commit a697b9c1ed
1 changed files with 3 additions and 3 deletions

View File

@ -103,14 +103,14 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
resp, err := runner.Declare(ctx, ls.Names()) resp, err := runner.Declare(ctx, ls.Names())
if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented { if err != nil && connect.CodeOf(err) == connect.CodeUnimplemented {
// Gitea instance is older version. skip declare step. // Gitea instance is older version. skip declare step.
log.Warn("Because the Forgejo instance is an old version, skip declare labels and version.") log.Warn("Because the Forgejo instance is an old version, skipping declaring the labels and version.")
} else if err != nil { } else if err != nil {
log.WithError(err).Error("fail to invoke Declare") log.WithError(err).Error("fail to invoke Declare")
return err return err
} else { } else {
log.Infof("runner: %s, with version: %s, with labels: %v, declare successfully", log.Infof("runner: %s, with version: %s, with labels: %v, declared successfully",
resp.Msg.Runner.Name, resp.Msg.Runner.Version, resp.Msg.Runner.Labels) resp.Msg.Runner.Name, resp.Msg.Runner.Version, resp.Msg.Runner.Labels)
// if declare successfully, override the labels in the.runner file with valid labels in the config file (if specified) // if declared successfully, override the labels in the.runner file with valid labels in the config file (if specified)
reg.Labels = ls.ToStrings() reg.Labels = ls.ToStrings()
if err := config.SaveRegistration(cfg.Runner.File, reg); err != nil { if err := config.SaveRegistration(cfg.Runner.File, reg); err != nil {
return fmt.Errorf("failed to save runner config: %w", err) return fmt.Errorf("failed to save runner config: %w", err)