Skip to content

Commit

Permalink
Merge branch 'release-1.146.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
niksv committed Nov 9, 2023
2 parents d9c53a5 + ffa68de commit a6e4a5a
Show file tree
Hide file tree
Showing 56 changed files with 2,114 additions and 1,684 deletions.
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
# Changelog

## v1.146.0 (01/11/2023)
## v1.146.1 (08/11/2023)

### Bug Fixes:
- [#5465](https://github.com/telstra/open-kilda/pull/5465) Fix a bug when a misconfigured rule with incorrect cookie is not re-installed.
- [#5466](https://github.com/telstra/open-kilda/pull/5466) replaced opentsdb in kilda-gui with victoriaDB. [**gui**]

### Improvements:
- [#5462](https://github.com/telstra/open-kilda/pull/5462) #5390: [TEST] Use helper methods to create flow (Issues: [#5390](https://github.com/telstra/open-kilda/issues/5390) [#5390](https://github.com/telstra/open-kilda/issues/5390)) [**tests**]

For the complete list of changes, check out [the commit log](https://github.com/telstra/open-kilda/compare/v1.146.0...v1.146.1).

---

## v1.146.0 (07/11/2023)

### Bug Fixes:
- [#5464](https://github.com/telstra/open-kilda/pull/5464) GUI: Graph: Victoria: Incorrect metrics value (max value) #5458 (Issues: [#5458](https://github.com/telstra/open-kilda/issues/5458) [#5458](https://github.com/telstra/open-kilda/issues/5458))
- [#5457](https://github.com/telstra/open-kilda/pull/5457) Flows by port: add condition to check switch ID and separate scr and dst ports when processing segments. (Issue: [#5450](https://github.com/telstra/open-kilda/issues/5450))
- [#5419](https://github.com/telstra/open-kilda/pull/5419) HA-flow history: add dumps, fix task IDs for saving an action to history (Issue: [#5425](https://github.com/telstra/open-kilda/issues/5425))


### Other changes:
- [#5463](https://github.com/telstra/open-kilda/pull/5463) #5390: [TEST] Fix for flaky Server42 tests (Issues: [#5390](https://github.com/telstra/open-kilda/issues/5390) [#5390](https://github.com/telstra/open-kilda/issues/5390)) [**tests**]

Expand All @@ -17,7 +28,9 @@ For the complete list of changes, check out [the commit log](https://github.com/
### Affected Components:
gui, history

## v1.145.2 (30/10/2023)
---

## v1.145.2 (31/10/2023)

### Bug Fixes:
- [#5381](https://github.com/telstra/open-kilda/pull/5381) skip haYPoint=endpoint when update periodic pings
Expand Down
30 changes: 18 additions & 12 deletions src-gui/src/main/java/org/openkilda/constants/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public final String getMetricName(String prefix) {
return prefix + this.metricName;
}

public static String getFullMetricNameByMetricName(String metricName, String prefix) {
return Arrays.stream(values()).filter(value -> value.metricName.equals(metricName))
.map(val -> val.getMetricName(prefix)).findFirst().orElse(null);
}

/**
* Flow value.
*
Expand Down Expand Up @@ -176,14 +181,14 @@ public static String meterMetricName(String metricPart, String prefix) {
/**
* Flow raw value.
*
* @param tag the tag
* @param metricEnding the tag
* @return the list
*/
public static List<String> flowRawValue(String tag, String prefix) {
public static List<String> flowRawValue(String metricEnding, String prefix) {
List<String> list = new ArrayList<>();
tag = "Flow_raw_" + tag;
metricEnding = "Flow_raw_" + metricEnding;
for (Metrics metric : values()) {
if (metric.getTag().equalsIgnoreCase(tag)) {
if (metric.getTag().equalsIgnoreCase(metricEnding)) {
list.add(metric.getMetricName(prefix));
}
}
Expand All @@ -193,21 +198,22 @@ public static List<String> flowRawValue(String tag, String prefix) {
/**
* Switch value.
*
* @param tag the tag
* @param metricEnding the tag
* @return the list
*/
public static List<String> switchValue(String tag, String prefix) {
public static List<String> switchValue(String metricEnding, String prefix) {
List<String> list = new ArrayList<>();
String metricTag;

if (tag.equalsIgnoreCase("latency")) {
tag = "Isl_" + tag;
} else if (tag.equalsIgnoreCase("rtt")) {
tag = "Isl_" + tag;
if (metricEnding.equalsIgnoreCase("latency")) {
metricTag = "Isl_" + metricEnding;
} else if (metricEnding.equalsIgnoreCase("rtt")) {
metricTag = "Isl_" + metricEnding;
} else {
tag = "Switch_" + tag;
metricTag = "Switch_" + metricEnding;
}
for (Metrics metric : values()) {
if (metric.getTag().equalsIgnoreCase(tag)) {
if (metric.getTag().equalsIgnoreCase(metricTag)) {
list.add(metric.getMetricName(prefix));
}
}
Expand Down
75 changes: 40 additions & 35 deletions src-gui/src/main/java/org/openkilda/controller/StatsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import org.openkilda.constants.Metrics;
import org.openkilda.constants.OpenTsDb;
import org.openkilda.exception.InvalidRequestException;
import org.openkilda.model.FlowPathStats;
import org.openkilda.model.PortInfo;
import org.openkilda.model.VictoriaStatsReq;
import org.openkilda.model.victoria.Status;
import org.openkilda.model.victoria.VictoriaData;
import org.openkilda.model.victoria.VictoriaStatsRes;
Expand Down Expand Up @@ -55,9 +55,6 @@
public class StatsController {

private static final Logger LOGGER = Logger.getLogger(StatsController.class);

private static final String VICTORIA_METRICS_URL_EMPTY = "Victoria Metrics DB URL has not been configured"
+ " for Openkilda-gui.";
private static final String REQUIRED_START_DATE_ERROR = "startDate must not be null or empty.";
private static final String STATS_TYPE_ERROR = "statsType path variable should not be empty or wrong.";
private static final String REQUIRED_METRIC_ERROR = "metric must not be null or empty.";
Expand Down Expand Up @@ -160,11 +157,11 @@ public String getFlowStats(@PathVariable String flowid, @PathVariable String sta
/**
* Retrieves Victoria statistics data for a specific flow based on the provided parameters.
*
* @param flowId The ID of the flow for which statistics are retrieved.
* @param flowId The ID of the flow for which statistics are retrieved.
* @param startDate The start date of the data retrieval period.
* @param endDate The end date of the data retrieval period.
* @param step The time step for data aggregation.
* @param metric A list of metrics for which statistics are retrieved.
* @param endDate The end date of the data retrieval period.
* @param step The time step for data aggregation.
* @param metric A list of metrics for which statistics are retrieved.
* @param direction The direction of the flow data ('forward' or 'reverse'). Optional.
* @return A {@link ResponseEntity} containing a {@link VictoriaStatsRes} object with the retrieved statistics.
* @see VictoriaStatsRes
Expand All @@ -182,11 +179,6 @@ public ResponseEntity<VictoriaStatsRes> getFlowVictoriaStats(@PathVariable Strin
@RequestParam List<String> metric,
@RequestParam(required = false) String direction) {

if (StringUtils.isBlank(applicationProperties.getVictoriaBaseUrl())
|| applicationProperties.getVictoriaBaseUrl().contains("://:/prometheus")) {
return buildServiceUnavailableRes();
}

LOGGER.info("Get victoria stat for flow");
if (StringUtils.isBlank(startDate)) {
return buildVictoriaBadRequestErrorRes(REQUIRED_START_DATE_ERROR);
Expand Down Expand Up @@ -277,40 +269,57 @@ public String getFlowLossPacketStats(@PathVariable String flowid, @PathVariable
}

/**
* Gets the flow path stat.
* Gets the flow path stat from victoria db.
*
* @param flowPathStats the flow path stat (flowid , list of switchids, start date, end date)
* @param victoriaStatsReq the flow path stat (flowid , switchId, startDate, endDate, labels)
* @return the flow path stat
*/
@RequestMapping(value = "flowpath", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "common", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_FLOWS})
@ResponseBody
public String getFlowPathStat(@RequestBody FlowPathStats flowPathStats) {
public ResponseEntity<VictoriaStatsRes> commonVictoriaStats(@RequestBody VictoriaStatsReq victoriaStatsReq) {

LOGGER.info("Get flow path stat ");
return statsService.getFlowPathStats(flowPathStats);
LOGGER.info(String.format("Get flow path stat request: %s", victoriaStatsReq));
ResponseEntity<VictoriaStatsRes> res;
try {
List<VictoriaData> victoriaResult = statsService.getVictoriaStats(victoriaStatsReq);

Optional<VictoriaData> errorData = victoriaResult.stream().filter(this::hasError).findFirst();

if (errorData.isPresent()) {
VictoriaData err = errorData.get();
res = buildVictoriaBadRequestErrorRes(Integer.parseInt(err.getErrorType()), err.getError());
} else {
res = ResponseEntity.ok(VictoriaStatsRes.builder().status(SUCCESS)
.dataList(victoriaResult).build());
}
} catch (InvalidRequestException e) {
res = buildVictoriaBadRequestErrorRes(e.getMessage());
}
return res;
}

/**
* Gets the switch ports stats.
* Retrieves statistics for switch ports.
* This method handles HTTP POST requests to fetch statistics for switch ports. It requires a valid
* VictoriaStatsReq object in the request body to specify the statistics parameters.
*
* @param switchid the switchid
* @param startDate the start date
* @param endDate the end date
* @param downsample the downsample
* @return the switch ports stats
* @param statsReq The VictoriaStatsReq object containing the statistics parameters.
* @return A list of PortInfo objects representing the statistics for switch ports.
* @throws InvalidRequestException If the request parameters are invalid or malformed.
* @see VictoriaStatsReq
* @see PortInfo
* @see StatsService#getSwitchPortsStats(VictoriaStatsReq)
*/
@RequestMapping(value = "switchports/{switchid}/{startDate}/{endDate}/{downsample}", method = RequestMethod.GET,
@RequestMapping(value = "switchports", method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_SWITCHES})
@ResponseBody
public List<PortInfo> getSwitchPortsStats(@PathVariable String switchid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample) {

LOGGER.info("Get switch ports stat ");
return statsService.getSwitchPortsStats(startDate, endDate, downsample, switchid);
public List<PortInfo> switchPortsStats(@RequestBody VictoriaStatsReq statsReq) throws InvalidRequestException {
LOGGER.info("POST switch ports stat ");
return statsService.getSwitchPortsStats(statsReq);
}


Expand Down Expand Up @@ -342,10 +351,6 @@ private boolean hasError(VictoriaData victoriaData) {
return victoriaData != null && Status.ERROR.equals(victoriaData.getStatus());
}

private ResponseEntity<VictoriaStatsRes> buildServiceUnavailableRes() {
return buildVictoriaBadRequestErrorRes(503, StatsController.VICTORIA_METRICS_URL_EMPTY);
}

private ResponseEntity<VictoriaStatsRes> buildVictoriaBadRequestErrorRes(String message) {
return buildVictoriaBadRequestErrorRes(400, message);
}
Expand Down
116 changes: 0 additions & 116 deletions src-gui/src/main/java/org/openkilda/model/FlowPathStats.java

This file was deleted.

38 changes: 38 additions & 0 deletions src-gui/src/main/java/org/openkilda/model/VictoriaStatsReq.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* Copyright 2023 Telstra Open Source
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.openkilda.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.Data;

import java.util.List;
import java.util.Map;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(value = PropertyNamingStrategies.LowerCamelCaseStrategy.class)
@Data
public class VictoriaStatsReq {
private List<String> metrics;
private String statsType;
private String startDate;
private String endDate;
private String step;
private Map<String, String> labels;
}
Loading

0 comments on commit a6e4a5a

Please sign in to comment.