Skip to content

Commit

Permalink
fix: report errors to Equinix Metal event API
Browse files Browse the repository at this point in the history
This provides more detailed event for better error analysis.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Dec 2, 2022
1 parent 7ab140a commit dc5e0f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 9 additions & 2 deletions internal/app/machined/pkg/runtime/v1alpha1/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
type Event struct {
Type string
Message string
Error error
}

// nb: these events currently map to those expected by
Expand Down Expand Up @@ -133,10 +134,16 @@ func newPlatform(platform string) (p runtime.Platform, err error) {
func FireEvent(ctx context.Context, p runtime.Platform, e Event) {
switch platType := p.(type) {
case *equinixmetal.EquinixMetal:
eventErr := platType.FireEvent(ctx, equinixmetal.Event{
emEvent := equinixmetal.Event{
Type: e.Type,
Message: e.Message,
})
}

if e.Error != nil {
emEvent.Message = fmt.Sprintf("%s: %s", e.Message, e.Error)
}

eventErr := platType.FireEvent(ctx, emEvent)

if eventErr != nil {
log.Printf("failed sending event: %s", eventErr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ func LoadConfig(seq runtime.Sequence, data interface{}) (runtime.TaskExecutionFu
platform.Event{
Type: platform.EventTypeFailure,
Message: "Error fetching Talos machine config.",
Error: e,
},
)

Expand All @@ -535,6 +536,7 @@ func LoadConfig(seq runtime.Sequence, data interface{}) (runtime.TaskExecutionFu
platform.Event{
Type: platform.EventTypeFailure,
Message: "Error loading and validating Talos machine config.",
Error: e,
},
)

Expand Down Expand Up @@ -1927,6 +1929,7 @@ func Install(seq runtime.Sequence, data interface{}) (runtime.TaskExecutionFunc,
platform.Event{
Type: platform.EventTypeFailure,
Message: "Talos install failed.",
Error: err,
},
)

Expand Down Expand Up @@ -1967,7 +1970,8 @@ func Install(seq runtime.Sequence, data interface{}) (runtime.TaskExecutionFunc,
r.State().Platform(),
platform.Event{
Type: platform.EventTypeFailure,
Message: "Talos install failed.",
Message: "Talos staged upgrade failed.",
Error: err,
},
)

Expand Down

0 comments on commit dc5e0f4

Please sign in to comment.