Skip to content

Commit fd5d3d8

Browse files
authored
Merge pull request #284 from aali309/GITOPS-11094
fix: getAppSetStatus incorrectly treats ApplicationSetUpToDate=True as Error
2 parents 2da6a8f + ebab759 commit fd5d3d8

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

‎src/gitops/utils/gitops.test.ts‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,27 @@ describe('getOperationType', () => {
118118
});
119119
});
120120

121+
const healthyApplicationSetConditions = [
122+
{
123+
type: 'ErrorOccurred',
124+
status: 'False',
125+
reason: 'ApplicationSetUpToDate',
126+
message: 'All applications have been generated successfully',
127+
},
128+
{
129+
type: 'ParametersGenerated',
130+
status: 'True',
131+
reason: 'ParametersGenerated',
132+
message: 'Successfully generated parameters for all Applications',
133+
},
134+
{
135+
type: 'ResourcesUpToDate',
136+
status: 'True',
137+
reason: 'ApplicationSetUpToDate',
138+
message: 'All applications have been generated successfully',
139+
},
140+
];
141+
121142
describe('getAppSetStatus', () => {
122143
it('determines ApplicationSet status', () => {
123144
expect(
@@ -140,4 +161,34 @@ describe('getAppSetStatus', () => {
140161

141162
expect(getAppSetStatus({} as any)).toMatchInlineSnapshot(`"Unknown"`);
142163
});
164+
165+
it('returns Healthy for realistic upstream conditions (ResourcesUpToDate=True)', () => {
166+
expect(
167+
getAppSetStatus({
168+
status: { conditions: healthyApplicationSetConditions },
169+
} as any),
170+
).toBe('Healthy');
171+
});
172+
173+
it('returns Error when ResourcesUpToDate is False', () => {
174+
expect(
175+
getAppSetStatus({
176+
status: {
177+
conditions: [
178+
{ type: 'ErrorOccurred', status: 'False' },
179+
{ type: 'ParametersGenerated', status: 'True' },
180+
{ type: 'ResourcesUpToDate', status: 'False', reason: 'ErrorOccurred' },
181+
],
182+
},
183+
} as any),
184+
).toBe('Error');
185+
});
186+
187+
it('does not treat ApplicationSetUpToDate reason as a condition type', () => {
188+
expect(
189+
getAppSetStatus({
190+
status: { conditions: [{ type: 'ApplicationSetUpToDate', status: 'True' }] },
191+
} as any),
192+
).toBe('Healthy');
193+
});
143194
});

‎src/gitops/utils/gitops.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ export function getAppSetStatus(appset: ApplicationSetKind): ApplicationSetStatu
192192
) {
193193
status = ApplicationSetStatus.ERROR;
194194
} else if (
195-
condition.type == 'ApplicationSetUpToDate' &&
196-
condition.status == K8sResourceConditionStatus.True
195+
condition.type == 'ResourcesUpToDate' &&
196+
condition.status != K8sResourceConditionStatus.True
197197
) {
198198
status = ApplicationSetStatus.ERROR;
199199
}

0 commit comments

Comments
 (0)