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

chore(pro): improve error message when waiting for instance to become ready #1588

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
21 changes: 20 additions & 1 deletion pkg/platform/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"crypto/tls"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -229,7 +230,25 @@ func WaitForInstance(ctx context.Context, client client.Client, instance *manage
return true, nil
})
if err != nil {
return nil, fmt.Errorf("wait for instance to get ready: %w", err)
// let's build a proper error message here
msg := "Timed out waiting for workspace to get ready \n\n "
// basic status
msg += fmt.Sprintf("ready: %t\n", isReady(updatedInstance))
msg += fmt.Sprintf("template synced: %t\n", isTemplateSynced(updatedInstance))
msg += fmt.Sprintf("runner ready: %t\n", isRunnerReady(updatedInstance, storagev1.BuiltinRunnerName))
msg += "\n"

// CRD conditions
msg += "Conditions:\n"
for _, cond := range updatedInstance.Status.Conditions {
msg += fmt.Sprintf("%s is %s (%s): %s\n", cond.Type, cond.Status, cond.Reason, cond.Message)
}
msg += "\n"

// error message, usually context timeout
msg += fmt.Sprintf("Error: %s", err.Error())

return nil, errors.New(msg)
}

return updatedInstance, nil
Expand Down
Loading