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

Fix aggregate simplified status panic issue #298

Merged
merged 1 commit into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
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
15 changes: 8 additions & 7 deletions internal/controllers/aggregation/composition.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ func (c *compositionController) aggregate(synth *apiv1.Synthesizer, comp *apiv1.
return copy
}

copy.Status = "Synthesizing"
if !comp.InputsExist(synth) {
copy.Status = "MissingInputs"
}
if comp.Status.InFlightSynthesis != nil || comp.Status.CurrentSynthesis == nil {
return copy
}

for _, result := range comp.Status.CurrentSynthesis.Results {
if result.Severity == krmv1.ResultSeverityError {
copy.Error = result.Message
Expand All @@ -90,13 +98,6 @@ func (c *compositionController) aggregate(synth *apiv1.Synthesizer, comp *apiv1.
}
}

copy.Status = "Synthesizing"
if !comp.InputsExist(synth) {
copy.Status = "MissingInputs"
}
if comp.Status.InFlightSynthesis != nil {
return copy
}
if syn := comp.Status.CurrentSynthesis; syn.Synthesized != nil {
copy.Status = "Reconciling"
}
Expand Down
25 changes: 25 additions & 0 deletions internal/controllers/aggregation/composition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ func TestCompositionSimplification(t *testing.T) {
Status: "PendingSynthesis",
},
},
{
Input: apiv1.CompositionStatus{InFlightSynthesis: &apiv1.Synthesis{UUID: "uuid"}},
Expected: apiv1.SimplifiedStatus{
Status: "Synthesizing",
},
},
{
Input: apiv1.CompositionStatus{CurrentSynthesis: &apiv1.Synthesis{UUID: "uuid"}},
Expected: apiv1.SimplifiedStatus{
Expand Down Expand Up @@ -109,6 +115,18 @@ func TestCompositionSimplification(t *testing.T) {
Status: "PendingSynthesis",
},
},
{
Bindings: []apiv1.Binding{{Key: "foo"}},
Input: apiv1.CompositionStatus{InFlightSynthesis: &apiv1.Synthesis{UUID: "uuid"}},
Synth: apiv1.Synthesizer{
Spec: apiv1.SynthesizerSpec{
Refs: []apiv1.Ref{{Key: "bar"}},
},
},
Expected: apiv1.SimplifiedStatus{
Status: "Synthesizing",
},
},
{
Bindings: []apiv1.Binding{{Key: "foo"}},
Input: apiv1.CompositionStatus{CurrentSynthesis: &apiv1.Synthesis{UUID: "uuid"}},
Expand All @@ -128,6 +146,13 @@ func TestCompositionSimplification(t *testing.T) {
Status: "PendingSynthesis",
},
},
{
Bindings: []apiv1.Binding{{Key: "foo"}},
Input: apiv1.CompositionStatus{InFlightSynthesis: &apiv1.Synthesis{UUID: "uuid"}},
Expected: apiv1.SimplifiedStatus{
Status: "Synthesizing",
},
},
{
Bindings: []apiv1.Binding{{Key: "foo"}},
Input: apiv1.CompositionStatus{CurrentSynthesis: &apiv1.Synthesis{UUID: "uuid"}},
Expand Down
Loading