Skip to content

Commit 2a88a8e

Browse files
Merge branch 'main' into dependabot/npm_and_yarn/typescript/vrotest/isaacs/brace-expansion-5.0.1
2 parents 6af1d44 + 7afffab commit 2a88a8e

File tree

3 files changed

+149
-3
lines changed

3 files changed

+149
-3
lines changed

common/artifact-manager/src/main/java/com/vmware/pscoe/iac/artifact/aria/operations/models/AlertDefinitionDTO.java

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,91 @@ public void setAdditionalProperties(String name, Object value) {
207207
}
208208

209209
@JsonInclude(JsonInclude.Include.NON_NULL)
210-
@JsonPropertyOrder({ "type", "relation", "aggregation", "symptomSetOperator", "symptomDefinitionIds", "symptomSets" })
210+
@JsonPropertyOrder({ "waitCycles", "cancelCycles", "severity", "condition" })
211+
public static class AlertCondition implements Serializable {
212+
private static final long serialVersionUID = 2188722915313653545L;
213+
214+
@JsonProperty("id")
215+
private String id;
216+
217+
@JsonProperty("waitCycles")
218+
private Integer waitCycles;
219+
220+
@JsonProperty("cancelCycles")
221+
private Integer cancelCycles;
222+
223+
@JsonProperty("severity")
224+
private String severity;
225+
226+
@JsonProperty("condition")
227+
private SymptomDefinitionDTO.SymptomDefinition.Condition condition;
228+
229+
@JsonIgnore
230+
private transient Map<String, Object> additionalProperties = new HashMap<>();
231+
232+
@JsonProperty("id")
233+
public String getId() {
234+
return id;
235+
}
236+
237+
@JsonProperty("id")
238+
public void setId(String id) {
239+
this.id = id;
240+
}
241+
242+
@JsonProperty("waitCycles")
243+
public Integer getWaitCycles() {
244+
return waitCycles;
245+
}
246+
247+
@JsonProperty("waitCycles")
248+
public void setWaitCycles(Integer waitCycles) {
249+
this.waitCycles = waitCycles;
250+
}
251+
252+
@JsonProperty("cancelCycles")
253+
public Integer getCancelCycles() {
254+
return cancelCycles;
255+
}
256+
257+
@JsonProperty("cancelCycles")
258+
public void setCancelCycles(Integer cancelCycles) {
259+
this.cancelCycles = cancelCycles;
260+
}
261+
262+
@JsonProperty("severity")
263+
public String getSeverity() {
264+
return severity;
265+
}
266+
267+
@JsonProperty("severity")
268+
public void setSeverity(String severity) {
269+
this.severity = severity;
270+
}
271+
272+
@JsonProperty("condition")
273+
public SymptomDefinitionDTO.SymptomDefinition.Condition getCondition() {
274+
return condition;
275+
}
276+
277+
@JsonProperty("condition")
278+
public void setCondition(SymptomDefinitionDTO.SymptomDefinition.Condition condition) {
279+
this.condition = condition;
280+
}
281+
282+
@JsonAnyGetter
283+
public Map<String, Object> getAdditionalProperties() {
284+
return this.additionalProperties;
285+
}
286+
287+
@JsonAnySetter
288+
public void setAdditionalProperties(String name, Object value) {
289+
this.additionalProperties.put(name, value);
290+
}
291+
}
292+
293+
@JsonInclude(JsonInclude.Include.NON_NULL)
294+
@JsonPropertyOrder({ "type", "relation", "aggregation", "symptomSetOperator", "symptomDefinitionIds", "symptomSets", "alertConditions" })
211295
public static class BaseSymptomSet implements Serializable {
212296
private static final long serialVersionUID = 7061962708255866132L;
213297

@@ -229,6 +313,9 @@ public static class BaseSymptomSet implements Serializable {
229313
@JsonProperty("symptomSets")
230314
private List<SymptomSet> symptomSets = new ArrayList<>();
231315

316+
@JsonProperty("alertConditions")
317+
private List<AlertCondition> alertConditions = new ArrayList<>();
318+
232319
@JsonIgnore
233320
private transient Map<String, Object> additionalProperties = new HashMap<>();
234321

@@ -292,6 +379,16 @@ public void setSymptomSets(List<SymptomSet> symptomSets) {
292379
this.symptomSets = symptomSets;
293380
}
294381

382+
@JsonProperty("alertConditions")
383+
public List<AlertCondition> getAlertConditions() {
384+
return alertConditions;
385+
}
386+
387+
@JsonProperty("alertConditions")
388+
public void setAlertConditions(List<AlertCondition> alertConditions) {
389+
this.alertConditions = alertConditions;
390+
}
391+
295392
@JsonAnySetter
296393
public void setAdditionalProperties(Map<String, Object> additionalProperties) {
297394
this.additionalProperties = additionalProperties;
@@ -309,7 +406,7 @@ public void setAdditionalProperties(String name, Object value) {
309406
}
310407

311408
@JsonInclude(JsonInclude.Include.NON_NULL)
312-
@JsonPropertyOrder({ "type", "relation", "aggregation", "symptomSetOperator", "symptomDefinitionIds" })
409+
@JsonPropertyOrder({ "type", "relation", "aggregation", "symptomSetOperator", "symptomDefinitionIds", "alertConditions" })
313410
public static class SymptomSet implements Serializable {
314411
private static final long serialVersionUID = 7061962708255866132L;
315412

@@ -328,6 +425,9 @@ public static class SymptomSet implements Serializable {
328425
@JsonProperty("symptomDefinitionIds")
329426
private List<String> symptomDefinitionIds = new ArrayList<>();
330427

428+
@JsonProperty("alertConditions")
429+
private List<AlertCondition> alertConditions = new ArrayList<>();
430+
331431
@JsonIgnore
332432
private transient Map<String, Object> additionalProperties = new HashMap<>();
333433

@@ -381,6 +481,16 @@ public void setSymptomDefinitionIds(List<String> symptomDefinitionIds) {
381481
this.symptomDefinitionIds = symptomDefinitionIds;
382482
}
383483

484+
@JsonProperty("alertConditions")
485+
public List<AlertCondition> getAlertConditions() {
486+
return alertConditions;
487+
}
488+
489+
@JsonProperty("alertConditions")
490+
public void setAlertConditions(List<AlertCondition> alertConditions) {
491+
this.alertConditions = alertConditions;
492+
}
493+
384494
@JsonAnyGetter
385495
public Map<String, Object> getAdditionalProperties() {
386496
return this.additionalProperties;

common/artifact-manager/src/main/java/com/vmware/pscoe/iac/artifact/aria/operations/rest/RestClientVrops.java

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2251,10 +2251,41 @@ private void updateDependentDefinitions(Object definition, VropsPackageMemberTyp
22512251
}
22522252
}
22532253

2254+
private void removeAlertConditionIds(Object definition, VropsPackageMemberType definitionType) {
2255+
if (!VropsPackageMemberType.ALERT_DEFINITION.equals(definitionType)) {
2256+
return;
2257+
}
2258+
if (definition == null) {
2259+
return;
2260+
}
2261+
if (!(definition instanceof AlertDefinitionDTO.AlertDefinition)) {
2262+
return;
2263+
}
2264+
//remove alert id
2265+
((AlertDefinitionDTO.AlertDefinition) definition).setId(null);
2266+
//remove alert condition ids
2267+
for (State state : ((AlertDefinitionDTO.AlertDefinition) definition).getStates()) {
2268+
if (state.getBaseSymptomSet() == null) {
2269+
continue;
2270+
}
2271+
if (state.getBaseSymptomSet().getAlertConditions() != null) {
2272+
state.getBaseSymptomSet().getAlertConditions().forEach(condition -> condition.setId(null));
2273+
}
2274+
if (state.getBaseSymptomSet().getSymptomSets() != null) {
2275+
for (SymptomSet symptomSet : state.getBaseSymptomSet().getSymptomSets()) {
2276+
if (symptomSet.getAlertConditions() != null) {
2277+
symptomSet.getAlertConditions().forEach(condition -> condition.setId(null));
2278+
}
2279+
}
2280+
}
2281+
}
2282+
}
2283+
22542284
private void removeIdFromDefinitionPayload(Object definition, VropsPackageMemberType definitionType) {
22552285
switch (definitionType) {
22562286
case ALERT_DEFINITION: {
2257-
((AlertDefinitionDTO.AlertDefinition) definition).setId(null);
2287+
// remove alert id and alert condition IDs
2288+
removeAlertConditionIds(definition, definitionType);
22582289
break;
22592290
}
22602291
case SYMPTOM_DEFINITION: {

docs/versions/latest/Release.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ Project generation from `vrops` archetype fails because Maven tries to replace a
6161
#### New Behavior
6262
Project generation from `vrops` archetype executes successfully. Maven configuration is updated to not use variable replacement on `src/main/resources` since content there needs to be directly copied.
6363

64+
### *Fix `vrops` issue 1009 failing to push alert Definitions with alertConditions set*
65+
#### Previous Behavior
66+
Pushing AlertDefinitions with alertConditions not null was failing as the id was not being clean up before pushing .
67+
#### New Behavior
68+
Before pushing alertDefinitions the alertConditions ID will be set to null.
6469
## Upgrade procedure
6570

6671
[//]: # (Explain in details if something needs to be done)

0 commit comments

Comments
 (0)