Skip to content

Commit

Permalink
chore(pro): improve error message when waiting for instance to become
Browse files Browse the repository at this point in the history
ready
  • Loading branch information
pascalbreuninger committed Jan 23, 2025
1 parent 0e6e4e9 commit d6fbe6a
Showing 1 changed file with 20 additions and 1 deletion.
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

0 comments on commit d6fbe6a

Please sign in to comment.