Skip to content

Commit 1ac7070

Browse files
feat: Support non-error reconcile status (#9031)
* feat: Support non-error reconcile status * resolver warnings as reconcile warnings * use feature flags * self review * resolver warnings * self review * review comments * review comments * test fixes * review comments * Apply suggestions from code review Co-authored-by: Benjamin Egelund-Müller <b@egelund-muller.com> * nits --------- Co-authored-by: Benjamin Egelund-Müller <b@egelund-muller.com>
1 parent 54da9f9 commit 1ac7070

31 files changed

Lines changed: 1374 additions & 1027 deletions

File tree

cli/cmd/project/status.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package project
22

33
import (
44
"fmt"
5+
"strings"
56
"time"
67

78
"github.com/rilldata/rill/cli/pkg/cmdutil"
@@ -170,10 +171,11 @@ func StatusCmd(ch *cmdutil.Helper) *cobra.Command {
170171
}
171172

172173
type resourceTableRow struct {
173-
Type string `header:"type"`
174-
Name string `header:"name"`
175-
Status string `header:"status"`
176-
Error string `header:"error"`
174+
Type string `header:"type"`
175+
Name string `header:"name"`
176+
Status string `header:"status"`
177+
Error string `header:"error"`
178+
Warning string `header:"warning"`
177179
}
178180

179181
func newResourceTableRow(r *runtimev1.Resource) *resourceTableRow {
@@ -182,11 +184,17 @@ func newResourceTableRow(r *runtimev1.Resource) *resourceTableRow {
182184
truncErr = truncErr[:80] + "..."
183185
}
184186

187+
truncWarn := strings.Join(r.Meta.ReconcileWarnings, "; ")
188+
if len(truncWarn) > 80 {
189+
truncWarn = truncWarn[:80] + "..."
190+
}
191+
185192
return &resourceTableRow{
186-
Type: runtime.PrettifyResourceKind(r.Meta.Name.Kind),
187-
Name: r.Meta.Name.Name,
188-
Status: runtime.PrettifyReconcileStatus(r.Meta.ReconcileStatus),
189-
Error: truncErr,
193+
Type: runtime.PrettifyResourceKind(r.Meta.Name.Kind),
194+
Name: r.Meta.Name.Name,
195+
Status: runtime.PrettifyReconcileStatus(r.Meta.ReconcileStatus),
196+
Error: truncErr,
197+
Warning: truncWarn,
190198
}
191199
}
192200

cli/cmd/sudo/project/search.go

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,16 @@ func SearchCmd(ch *cmdutil.Helper) *cobra.Command {
103103
}
104104

105105
type projectStatusTableRow struct {
106-
Org string `header:"org"`
107-
Project string `header:"project"`
108-
DeploymentStatus string `header:"deployment"`
109-
IdleCount int `header:"idle"`
110-
PendingCount int `header:"pending"`
111-
RunningCount int `header:"running"`
112-
ReconcileErrorsCount int `header:"reconcile errors"`
113-
ParseErrorsCount int `header:"parse errors"`
114-
ParseWarningsCount int `header:"parse warnings"`
106+
Org string `header:"org"`
107+
Project string `header:"project"`
108+
DeploymentStatus string `header:"deployment"`
109+
IdleCount int `header:"idle"`
110+
PendingCount int `header:"pending"`
111+
RunningCount int `header:"running"`
112+
ReconcileErrorsCount int `header:"reconcile errors"`
113+
ReconcileWarningsCount int `header:"reconcile warnings"`
114+
ParseErrorsCount int `header:"parse errors"`
115+
ParseWarningsCount int `header:"parse warnings"`
115116
}
116117

117118
func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, project string) (*projectStatusTableRow, error) {
@@ -179,7 +180,7 @@ func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, projec
179180
var parser *runtimev1.Resource
180181
var parseErrorsCount, parseWarningsCount int
181182
var idleCount int
182-
var reconcileErrorsCount int
183+
var reconcileErrorsCount, reconcileWarningsCount int
183184
var pendingCount int
184185
var runningCount int
185186

@@ -196,6 +197,8 @@ func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, projec
196197
idleCount++
197198
if r.Meta.GetReconcileError() != "" {
198199
reconcileErrorsCount++
200+
} else if len(r.Meta.ReconcileWarnings) > 0 {
201+
reconcileWarningsCount++
199202
}
200203
case runtimev1.ReconcileStatus_RECONCILE_STATUS_PENDING:
201204
pendingCount++
@@ -226,15 +229,16 @@ func newProjectStatusTableRow(ctx context.Context, c *client.Client, org, projec
226229
}
227230

228231
return &projectStatusTableRow{
229-
Org: org,
230-
Project: project,
231-
DeploymentStatus: "OK",
232-
IdleCount: idleCount,
233-
PendingCount: pendingCount,
234-
RunningCount: runningCount,
235-
ReconcileErrorsCount: reconcileErrorsCount,
236-
ParseErrorsCount: parseErrorsCount,
237-
ParseWarningsCount: parseWarningsCount,
232+
Org: org,
233+
Project: project,
234+
DeploymentStatus: "OK",
235+
IdleCount: idleCount,
236+
PendingCount: pendingCount,
237+
RunningCount: runningCount,
238+
ReconcileErrorsCount: reconcileErrorsCount,
239+
ReconcileWarningsCount: reconcileWarningsCount,
240+
ParseErrorsCount: parseErrorsCount,
241+
ParseWarningsCount: parseWarningsCount,
238242
}, nil
239243
}
240244

cli/cmd/validate/validate.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ type ValidationResult struct {
2626
}
2727

2828
type ValidationSummary struct {
29-
TotalResources int `json:"total_resources"`
30-
ParseErrors int `json:"parse_errors"`
31-
ParseWarnings int `json:"parse_warnings"`
32-
ReconcileErrors int `json:"reconcile_errors"`
29+
TotalResources int `json:"total_resources"`
30+
ParseErrors int `json:"parse_errors"`
31+
ParseWarnings int `json:"parse_warnings"`
32+
ReconcileErrors int `json:"reconcile_errors"`
33+
ReconcileWarnings int `json:"reconcile_warnings"`
3334
}
3435

3536
// ParseError represents a parse error (serializable version of runtimev1.ParseError)
@@ -45,6 +46,7 @@ type ResourceStatus struct {
4546
Name string `json:"name" header:"name"`
4647
Status string `json:"status" header:"status"`
4748
Error string `json:"error" header:"error"`
49+
Warning string `json:"warning" header:"warning"`
4850
FilePath string `json:"file_path" header:"file_path"`
4951
Timeout bool `json:"timeout" header:"timeout"`
5052
}
@@ -220,6 +222,10 @@ func buildValidationResult(resources []*runtimev1.Resource) *ValidationResult {
220222
resourceStatus.Timeout = true
221223
}
222224
}
225+
if len(r.Meta.ReconcileWarnings) > 0 {
226+
result.Summary.ReconcileWarnings++
227+
resourceStatus.Warning = strings.Join(r.Meta.ReconcileWarnings, "; ")
228+
}
223229

224230
result.Resources = append(result.Resources, resourceStatus)
225231
}

0 commit comments

Comments
 (0)