Skip to content

feat: kubernetes deploy and real-time status update #68

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

Merged
merged 30 commits into from
Mar 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b467185
dev: generic methods for calculating percentiles
ghkdqhrbals Mar 30, 2024
27d0372
dev: javadocs style commenting
ghkdqhrbals Mar 30, 2024
cfa4f7e
dev: change MTTFB percentile map value with Long
ghkdqhrbals Mar 30, 2024
4dada9f
dev: stop status append
ghkdqhrbals Mar 30, 2024
4266a62
dev: already running errorcode append
ghkdqhrbals Mar 30, 2024
da11973
dev: validation update
ghkdqhrbals Mar 30, 2024
1e25a7f
dev: agent stop event, avg cal, preftest update
ghkdqhrbals Mar 30, 2024
4d3e3b4
dev: agent deploy as statefulSet
ghkdqhrbals Mar 31, 2024
ee64d87
dev: status logging
ghkdqhrbals Mar 31, 2024
739be94
dev: adjust test method
ghkdqhrbals Mar 31, 2024
a3bd173
dev: stomp socket handling due to k8s
ghkdqhrbals Mar 31, 2024
976ee34
dev: remove unused ingress
ghkdqhrbals Mar 31, 2024
1675772
dev: setup stomp with SockJS
ghkdqhrbals Mar 31, 2024
9f6f386
dev: kubernetes profile agent loader
ghkdqhrbals Mar 31, 2024
f44e2e5
dev: docker buildx multiplatform image
ghkdqhrbals Mar 31, 2024
10ad4ec
dev: setup EUREKA k8s config
ghkdqhrbals Mar 31, 2024
edb7817
dev: local image pusher script
ghkdqhrbals Mar 31, 2024
de1270e
chore: undo issuer
ghkdqhrbals Mar 31, 2024
9594a40
dev: agent renewal parallel execution
ghkdqhrbals Mar 31, 2024
a3e8316
chore: gradle clean and build
ghkdqhrbals Mar 31, 2024
3b312ce
dev: websocket service exporter
ghkdqhrbals Mar 31, 2024
ad113c6
dev: imagePulling always & eureka connect
ghkdqhrbals Mar 31, 2024
23a1d76
dev: SockJS script src added
ghkdqhrbals Mar 31, 2024
bc2e8ba
dev: ddl-auto validate to update
ghkdqhrbals Mar 31, 2024
cb196a0
dev: spring cloud kubernetes import
ghkdqhrbals Mar 31, 2024
84ba204
dev: RBAC role & rolebinding to serviceaccount
ghkdqhrbals Mar 31, 2024
398c83f
dev: ingress rule update
ghkdqhrbals Mar 31, 2024
219f80a
Merge branch 'develop' into feature/tps-rtp-avg
ghkdqhrbals Mar 31, 2024
a8aa303
dev: limiting resource
ghkdqhrbals Mar 31, 2024
41ad271
dev: tls issuer and connect to ingress
ghkdqhrbals Mar 31, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/gke-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
run: chmod +x ./gradlew

- name: Build and test project
run: ./gradlew build
run: ./gradlew clean build

- name: Build docker image and push
run: bash ./script/img_push_multi_arch.sh -u ${{ secrets.DOCKERHUB_USERNAME }} -t ${{ secrets.DOCKERHUB_TOKEN }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,30 @@
import java.util.Arrays;
import java.util.List;

/**
* Performance Test Constants
*/
public interface PreftestConsts {
List<Double> percentiles = Arrays.asList(50D, 90D, 95D,99D,99.9D);

/**
* Required when measuring percentile of TPS and MTTFB(Mean Time To First Byte)
*/
List<Double> percentiles = Arrays.asList(50D, 90D, 95D, 99D, 99.9D);

/**
* If performance test has error rate exceed {@link PreftestConsts#errorLimitRate}, instantly
* shutdown all scheduler and emit event to bm-controller
*/
Double errorLimitRate = 50D;

/**
* ErrorLimit Lookup process will be started after this time
*/
int errorLimitCheckDelay = 10;

/**
* ErrorLimit Lookup process period
*/
int errorLimitCheckPeriod = 5;

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package org.benchmarker.bmagent.consts;

/**
* SSE constants
*/
public interface SseManageConsts {

/**
* SSE timeout constant
*/
Long SSE_TIMEOUT = 600000L;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
package org.benchmarker.bmagent.consts;

/**
* System Scheduler constants
*/
public interface SystemSchedulerConst {

/**
* System scheduler will run in this ID
*/
Long systemSchedulerId = -100L;

/**
* System scheduler's name
*/
String systemUsageSchedulerName = "cpu-memory-usage-update";

/**
* @deprecated since 2024-03-28
*/
Integer connectControllerTimeout = 10; // seconds

/**
* @deprecated since 2024-03-28
*/
Integer connectionFailedLimit = 50;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.benchmarker.bmagent.controller;


import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.Set;
import lombok.RequiredArgsConstructor;
Expand All @@ -21,11 +23,15 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;


/**
* Main RESTAPI endpoint
*
* <p>
* bm-controller will send request to here for performance testing
* </p>
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/api")
Expand All @@ -46,15 +52,16 @@ public class AgentApiController {
@PostMapping("/groups/{group_id}/templates/{template_id}")
public SseEmitter manageSSE(@PathVariable("template_id") Long templateId,
@PathVariable("group_id") String groupId,
@RequestParam("action") String action, @RequestBody TemplateInfo templateInfo) {
@RequestParam("action") String action, @RequestBody TemplateInfo templateInfo)
throws IOException {
log.info(templateInfo.toString());

if (action.equals("start")) {
agentStatusManager.getAndUpdateStatusIfReady(
AgentStatus.TESTING).orElseThrow(() -> new RuntimeException("agent is not ready"));
return sseManageService.start(templateId, groupId, templateInfo);
} else {
sseManageService.stop(templateId);
sseManageService.stopSign(templateId);
return null;
}
}
Expand All @@ -70,23 +77,26 @@ public ResponseEntity<Map<Long, SchedulerStatus>> getSchedulersStatus() {
}

@GetMapping("/status")
public AgentInfo getStatus() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
String scheme = request.getScheme(); // http or https
String serverName = request.getServerName();
int serverPort = request.getServerPort();
Set<Long> longs = scheduledTaskService.getStatus().keySet();
public AgentInfo getStatus() throws UnknownHostException {
log.info("Check current status");
InetAddress localHost = InetAddress.getLocalHost();
String serverAddress = localHost.getHostAddress();
String scheme = "http"; // Assuming it's always HTTP when accessed locally
int serverPort = 8081; // Assuming default port is 8080

String agentServerUrl = scheme + "://" + serverName + ":" + serverPort;
Set<Long> longs = scheduledTaskService.getStatus().keySet();

return AgentInfo.builder()
String agentServerUrl = scheme + "://" + serverAddress + ":" + serverPort;
AgentInfo info = AgentInfo.builder()
.templateId(longs)
.cpuUsage(agentStatusManager.getCpuUsage())
.memoryUsage(agentStatusManager.getMemoryUsage())
.startedAt(agentStatusManager.getStartedAt())
.serverUrl(agentServerUrl)
.status(agentStatusManager.getStatus().get())
.build();
log.info(info.toString());
return info;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

/**
* The Initializer class is responsible for <strong>initializing various components of the
* application when it starts up</strong>.
*
* <p>
* The Initializer will start system scheduler which recording CPU / MEMORY usage in every seconds
*/
@Component
@Profile("!test")
@Slf4j
Expand All @@ -26,7 +33,6 @@ public class Initializer implements CommandLineRunner, ApplicationContextAware {

@Override
public void run(String... args) throws Exception {
log.info("init");
// cpu, memory usage checker
scheduledTaskService.startChild(SystemSchedulerConst.systemSchedulerId,
SystemSchedulerConst.systemUsageSchedulerName, agentStatusManager::updateStats, 0, 1,
Expand Down
Loading