Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: warning logs when image pulls back off #107

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions internal/cmd/local/local/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,35 +396,42 @@ func (c *Command) handleEvent(ctx context.Context, e *eventsv1.Event) {

switch {
case strings.EqualFold(e.Type, "normal"):
pterm.Debug.Println(e.Note)
if strings.EqualFold(e.Reason, "backoff") {
pterm.Warning.Println(e.Note)
} else {
pterm.Debug.Println(e.Note)
}

case strings.EqualFold(e.Type, "warning"):
var logs = ""
logs := ""
level := pterm.Debug

// only show the warning if the count is higher than 5
// TODO: replace DeprecatedCount
// Similar issue to DeprecatedLastTimestamp, the series attribute is always nil
if e.DeprecatedCount > 5 {
level = pterm.Warning
}

if strings.EqualFold(e.Reason, "backoff") {
var err error
logs, err = c.k8s.LogsGet(ctx, e.Regarding.Namespace, e.Regarding.Name)
if err != nil {
pterm.Debug.Printfln("Unable to retrieve logs for %s:%s\n %s", e.Regarding.Namespace, e.Regarding.Name, err)
logs = fmt.Sprintf("Unable to retrieve logs for %s:%s\n %s", e.Regarding.Namespace, e.Regarding.Name, err)
}
} else if strings.Contains(e.Note, "Failed to pull image") && strings.Contains(e.Note, "429 Too Many Requests") {
// The docker image is failing to pull because the user has hit a rate limit.
// This causes the install to go very slowly and possibly time out.
// Always warn in this case, so the user knows what's going on.
level = pterm.Warning
}

// TODO: replace DeprecatedCount
// Similar issue to DeprecatedLastTimestamp, the series attribute is always nil
if logs != "" {
msg := fmt.Sprintf("Encountered an issue deploying Airbyte:\n Pod: %s\n Reason: %s\n Message: %s\n Count: %d\n Logs: %s",
level.Printfln("Encountered an issue deploying Airbyte:\n Pod: %s\n Reason: %s\n Message: %s\n Count: %d\n Logs: %s",
e.Name, e.Reason, e.Note, e.DeprecatedCount, strings.TrimSpace(logs))
pterm.Debug.Println(msg)
// only show the warning if the count is higher than 5
if e.DeprecatedCount > 5 {
pterm.Warning.Printfln(msg)
}
} else {
msg := fmt.Sprintf("Encountered an issue deploying Airbyte:\n Pod: %s\n Reason: %s\n Message: %s\n Count: %d",
level.Printfln("Encountered an issue deploying Airbyte:\n Pod: %s\n Reason: %s\n Message: %s\n Count: %d",
e.Name, e.Reason, e.Note, e.DeprecatedCount)
pterm.Debug.Printfln(msg)
// only show the warning if the count is higher than 5
if e.DeprecatedCount > 5 {
pterm.Warning.Printfln(msg)
}
}

default:
Expand Down