Skip to content

Commit

Permalink
Merge branch 'release-1.148.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
niksv committed Dec 5, 2023
2 parents 67a3ed8 + 0b9e44e commit 3a8d487
Show file tree
Hide file tree
Showing 130 changed files with 1,676 additions and 1,754 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## v1.148.0 (04/12/2023)

### Bug Fixes:
- [#5476](https://github.com/telstra/open-kilda/pull/5476) Fix a bug with writing history before the history event is created. (Issue: [#4738](https://github.com/telstra/open-kilda/issues/4738))

### Improvements:
- [#5472](https://github.com/telstra/open-kilda/pull/5472) Remove opentsdb from Kilda-gui [**gui**]
- [#5479](https://github.com/telstra/open-kilda/pull/5479) kilda-gui deps update [**gui**]
- [#5483](https://github.com/telstra/open-kilda/pull/5483) [TEST]: Server42: Flow: Rtt stats: Adding origin [**tests**]
- [#5484](https://github.com/telstra/open-kilda/pull/5484) #5390: [TEST] Avoid possibility of Y-Flow's subflows vlan conflict (Issues: [#5390](https://github.com/telstra/open-kilda/issues/5390) [#5390](https://github.com/telstra/open-kilda/issues/5390)) [**tests**]
- [#5487](https://github.com/telstra/open-kilda/pull/5487) [TEST]: Rigel: Stats: Victoria [**tests**]
- [#5488](https://github.com/telstra/open-kilda/pull/5488) #5390: [TEST] Fix flaky HA-Flow ping test (Issues: [#5390](https://github.com/telstra/open-kilda/issues/5390) [#5390](https://github.com/telstra/open-kilda/issues/5390)) [**tests**]
- [#5461](https://github.com/telstra/open-kilda/pull/5461) Change health check test for the MySQL container. Update docs. (Issue: [#5459](https://github.com/telstra/open-kilda/issues/5459)) [**configuration**]

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

### Affected Components:
history

---

## v1.147.1 (27/11/2023)

### Bug Fixes:
Expand Down
6 changes: 5 additions & 1 deletion confd/templates/docker-compose/docker-compose.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ services:
ports:
- 8101:3306
healthcheck:
test: "mysqladmin -u kilda -pkilda ping"
test: "mysql -u kilda -pkilda --protocol=tcp -e 'use kilda; select count(user());'"
interval: 3s
timeout: 3s
retries: 5
start_period: 20s
networks:
default:
aliases:
Expand Down
2 changes: 1 addition & 1 deletion confd/templates/functional-tests/kilda.properties.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ hibernate.url = {{ getv "/kilda_hibernate_url" }}
elasticsearch.endpoint={{ getv "/kilda_logging_elasticsearch_proto" }}://{{ getv "/kilda_logging_elasticsearch_hosts" }}
zookeeper.connect_string = {{ getv "/kilda_zookeeper_hosts"}}/{{ getv "/kilda_zookeeper_state_root" }}
legacy.tsdb.endpoint=http://{{ getv "/kilda_opentsdb_hosts" }}:{{ getv "/kilda_opentsdb_port" }}
tsdb.endpoint=http://{{ getv "/kilda_victoriametrics_host" }}:{{ getv "/kilda_victoriametrics_read_port" }}{{ getv "/kilda_tests_victoriametrics_query_path" }}
tsdb.endpoint={{ getv "/kilda_victoria_read_url_schema" }}://{{ getv "/kilda_victoriametrics_host" }}:{{ getv "/kilda_victoriametrics_read_port" }}{{ getv "/kilda_tests_victoriametrics_query_path" }}
kafka.bootstrap.server={{ getv "/kilda_kafka_hosts" }}
kafka.bootstrap.server.internal={{ getv "/kilda_kafka_hosts" }}
grpc.endpoint={{ getv "/kilda_grpc_endpoint" }}:{{ getv "/kilda_grpc_rest_port" }}
Expand Down
5 changes: 2 additions & 3 deletions confd/templates/gui/application.properties.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ spring.mvc.throw-exception-if-no-handler-found=true
#Northbound Base URL
nb.base.url={{ getv "/kilda_northbound_endpoint" }}:{{ getv "/kilda_northbound_rest_port" }}/api

#OPEN TSDB Base URL and metric prefix
opentsdb.base.url=http://{{ getv "/kilda_opentsdb_hosts" }}:{{ getv "/kilda_opentsdb_port" }}
opentsdb.metric.prefix = {{ getv "/kilda_opentsdb_metric_prefix" }}
#Metric prefix
metric.prefix = {{ getv "/kilda_opentsdb_metric_prefix" }}

#VICTORIA METRICS Base URL and metric prefix
victoria.base.url={{ getv "/kilda_victoria_read_url_schema" }}://{{ getv "/kilda_victoriametrics_host" }}:{{ getv "/kilda_victoriametrics_read_port" }}{{ getv "/kilda_victoriametrics_read_path" }}/prometheus
Expand Down
2 changes: 1 addition & 1 deletion docker/db-mysql-migration/migrations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ changeSet:
To start DB update manually you need to compose a migration image and execute a migration script. Optionally, you
can execute liquibase with arbitrary parameters.

To create an image, navigate to (TODO)
To create an image, navigate to the root of the OpenKilda project and execute:
```shell script
docker-compose build db_mysql_migration
```
Expand Down
4 changes: 2 additions & 2 deletions src-gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ build/libs/${APP}.war: .deps/node .deps/resources
./gradlew build

.deps/node: | .deps
docker run --rm -e LOCAL_UID=`id -u $(USER)` -e LOCAL_GID=`id -g $(USER)` -v $(CURDIR)/src:/app/src -v $(CURDIR)/ui:/app/ui node:14.17-alpine \
sh -c 'cd /app/ui && npm install && /app/ui/node_modules/.bin/ng build --prod && chown -R $$LOCAL_UID:$$LOCAL_GID /app'
docker run --rm -e LOCAL_UID=`id -u $(USER)` -e LOCAL_GID=`id -g $(USER)` -v $(CURDIR)/src:/app/src -v $(CURDIR)/ui:/app/ui node:18.18.2-alpine \
sh -c 'cd /app/ui && npm install && /app/ui/node_modules/.bin/ng build --configuration production && chown -R $$LOCAL_UID:$$LOCAL_GID /app'

.deps/resources: .deps
mkdir -p src/main/webapp/lib/css/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ public class ApplicationProperties {
@Value("${nb.base.url}")
private String nbBaseUrl;

@Value("${opentsdb.base.url}")
private String openTsdbBaseUrl;

@Value("${victoria.base.url}")
private String victoriaBaseUrl;

@Value("${opentsdb.metric.prefix}")
@Value("${metric.prefix}")
private String metricPrefix;

@Value("${kilda.username}")
Expand Down
15 changes: 0 additions & 15 deletions src-gui/src/main/java/org/openkilda/constants/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;

@Getter
Expand Down Expand Up @@ -261,17 +259,4 @@ public static List<String> list(String prefix) {
return Arrays.stream(values()).map(metric -> metric.getMetricName(prefix)).collect(Collectors.toList());
}

/**
* Tags.
*
* @return the sets the
*/
public static Set<String> tags() {
Set<String> tags = new TreeSet<>();
for (Metrics metric : values()) {
String[] v = metric.getTag().split("_");
tags.add(v[1]);
}
return tags;
}
}
185 changes: 17 additions & 168 deletions src-gui/src/main/java/org/openkilda/controller/StatsController.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2018 Telstra Open Source
/* 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.
Expand Down Expand Up @@ -82,78 +82,6 @@ public StatsController(StatsService statsService, ApplicationProperties applicat
return Metrics.list(applicationProperties.getMetricPrefix());
}


/**
* Gets the isl stats.
*
* @param startDate the start date
* @param endDate the end date
* @param downsample the downsample
* @return the flow stats
*/
@RequestMapping(value =
"isl/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_ISL})
@ResponseBody
public String getIslStats(@PathVariable String srcSwitch, @PathVariable String srcPort,
@PathVariable String dstSwitch, @PathVariable String dstPort,
@PathVariable String startDate, @PathVariable String endDate,
@PathVariable String downsample, @PathVariable String metric) {

LOGGER.info("Get stat for Isl");
return statsService.getSwitchIslStats(startDate, endDate, downsample, srcSwitch, srcPort, dstSwitch, dstPort,
metric);

}

/**
* Gets the port stats.
*
* @param switchid the switchid
* @param port the port
* @param startDate the start date
* @param endDate the end date
* @param downsample the downsample
* @return the port stats
*/
@RequestMapping(value = "switchid/{switchid}/port/{port}/{startDate}/{endDate}/{downsample}/{metric}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_SWITCHES})
@ResponseBody
public String getPortStats(@PathVariable String switchid, @PathVariable String port,
@PathVariable String startDate, @PathVariable String endDate,
@PathVariable String downsample, @PathVariable String metric) {

LOGGER.info("Get stat for port");
return statsService.getSwitchPortStats(startDate, endDate, downsample, switchid, port, metric);

}

/**
* Gets the flow stats.
*
* @param flowid the flowid
* @param startDate the start date
* @param endDate the end date
* @param downsample the downsample
* @return the flow stats
*/
@RequestMapping(value = "flowid/{flowid:.+}/{startDate}/{endDate}/{downsample}/{metric}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_FLOWS})
@ResponseBody
public String getFlowStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample,
@PathVariable String metric) {

LOGGER.info("Get stat for flow");
return statsService.getFlowStats(startDate, endDate, downsample, flowid, metric);
}

/**
* Retrieves Victoria statistics data for a specific flow based on the provided parameters.
*
Expand All @@ -166,7 +94,7 @@ public String getFlowStats(@PathVariable String flowid, @PathVariable String sta
* @return A {@link ResponseEntity} containing a {@link VictoriaStatsRes} object with the retrieved statistics.
* @see VictoriaStatsRes
*/
@RequestMapping(value = "victoria/{statsType}",
@RequestMapping(value = "flowgraph/{statsType}",
method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_FLOWS})
Expand All @@ -178,7 +106,7 @@ public ResponseEntity<VictoriaStatsRes> getFlowVictoriaStats(@PathVariable Strin
@RequestParam String step,
@RequestParam List<String> metric,
@RequestParam(required = false) String direction) {

//TODO find a way to unite this controller method with the commonVictoriaStats method.
LOGGER.info("Get victoria stat for flow");
if (StringUtils.isBlank(startDate)) {
return buildVictoriaBadRequestErrorRes(REQUIRED_START_DATE_ERROR);
Expand All @@ -201,73 +129,13 @@ public ResponseEntity<VictoriaStatsRes> getFlowVictoriaStats(@PathVariable Strin
statsService.getTransformedFlowVictoriaStats(statsType, startDate, endDate, step,
flowId, metric, Direction.byDisplayName(direction));

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());
}
res = convertToVictoriaStatsRes(victoriaResult);
} catch (InvalidRequestException e) {
res = buildVictoriaBadRequestErrorRes(e.getMessage());
}
return res;
}

/**
* Gets the switch isl loss packet stats.
*
* @param srcSwitch the src switch
* @param srcPort the src port
* @param dstSwitch the dst switch
* @param dstPort the dst port
* @param startDate the start date
* @param endDate the end date
* @param downsample the downsample
* @param metric the metric
* @return the isl loss packet stats
*/
@RequestMapping(value =
"isl/losspackets/{srcSwitch}/{srcPort}/{dstSwitch}/{dstPort}/{startDate}/{endDate}/{downsample}/{metric}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_ISL})
@ResponseBody
public String getIslLossPacketStats(@PathVariable String srcSwitch, @PathVariable String srcPort,
@PathVariable String dstSwitch, @PathVariable String dstPort,
@PathVariable String startDate, @PathVariable String endDate,
@PathVariable String downsample, @PathVariable String metric) {

LOGGER.info("Get stat of Isl loss packet");
return statsService.getSwitchIslLossPacketStats(startDate, endDate, downsample, srcSwitch, srcPort, dstSwitch,
dstPort, metric);
}

/**
* Gets the flow loss packet stats.
*
* @param flowid the flowid
* @param startDate the start date
* @param endDate the end date
* @param downsample the downsample
* @param direction the direction
* @return the flow loss packet stats
*/
@RequestMapping(value = "flow/losspackets/{flowid:.+}/{startDate}/{endDate}/{downsample}/{direction}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_FLOWS})
@ResponseBody
public String getFlowLossPacketStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample,
@PathVariable String direction) {

LOGGER.info("Get stat of flow loss packet");
return statsService.getFlowLossPacketStats(startDate, endDate, downsample, flowid, direction);
}

/**
* Gets the flow path stat from victoria db.
*
Expand All @@ -285,15 +153,7 @@ public ResponseEntity<VictoriaStatsRes> commonVictoriaStats(@RequestBody Victori
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());
}
res = convertToVictoriaStatsRes(victoriaResult);
} catch (InvalidRequestException e) {
res = buildVictoriaBadRequestErrorRes(e.getMessage());
}
Expand Down Expand Up @@ -322,29 +182,18 @@ public List<PortInfo> switchPortsStats(@RequestBody VictoriaStatsReq statsReq) t
return statsService.getSwitchPortsStats(statsReq);
}


/**
* Gets the meter stats.
*
* @param flowid the flowid
* @param startDate the start date
* @param endDate the end date
* @param downsample the downsample
* @param direction the direction
* @param metric the metric
* @return the meter stats
*/
@RequestMapping(value = "meter/{flowid:.+}/{startDate}/{endDate}/{downsample}/{metric}/{direction}",
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = {IConstants.Permission.MENU_FLOWS})
@ResponseBody
public String getMeterStats(@PathVariable String flowid, @PathVariable String startDate,
@PathVariable String endDate, @PathVariable String downsample,
@PathVariable String metric, @PathVariable String direction) {

LOGGER.info("Get stat for meter");
return statsService.getMeterStats(startDate, endDate, downsample, flowid, metric, direction);
private ResponseEntity<VictoriaStatsRes> convertToVictoriaStatsRes(List<VictoriaData> victoriaResult) {
ResponseEntity<VictoriaStatsRes> res;
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());
}
return res;
}

private boolean hasError(VictoriaData victoriaData) {
Expand Down
Loading

0 comments on commit 3a8d487

Please sign in to comment.