Skip to content

Commit

Permalink
Haproxy version (#37)
Browse files Browse the repository at this point in the history
## Type of change

- [ ] Refactor
- [x] New feature
- [ ] Bug fix
- [ ] Optimization
- [ ] Documentation Update

## Description

Capturing HAProxy RPM version using `rpm -qa | grep haproxy` and
including it in the metadata:

## Related Tickets & Documents

- Related Issue #
- Closes #36 

## Checklist before requesting a review

- [x] I have performed a self-review of my code.
- [ ] If it is a core feature, I have added thorough tests.

## Testing
Quick example shows:

```json
[                                                                                                                                                                                                                                             
  {                                                                                                                                                                                                                                           
    "uuid": "9ddf05c5-f6ec-410d-bf7c-aa07f5957707",                                                                                                                                                                                           
    "sample": 1,                                                                                                                                                                                                                              
    "config": {                                                                                                                                                                                                                               
      "termination": "http",                                                                                                                                                                                                                  
      "connections": 20,                                                                                                                                                                                                                      
      "samples": 1,                                                                                                                                                                                                                           
      "duration": 10000000000,                                                                                                                                                                                                                
      "path": "/1024.html",                                                                                                                                                                                                                   
      "concurrency": 1,                                                                                                                                                                                                                       
      "procs": 1,                                                                                                                                                                                                                             
      "tool": "wrk",                                                                                                                                                                                                                          
      "serverReplicas": 90,                                                                                                                                                                                                                   
      "tuningPatch": "",                                                                                                                                                                                                                      
      "Delay": 0,                                                                                                                                                                                                                             
      "RequestTimeout": 2000000000                                                                                                                                                                                                            
    },                                                                                                                                                                                                                                        
    "pods": [                                                                                                          
      {                                                                                                                                                                                                                                       
        "pod": "ingress-perf-client-c8d5548c9-s5rgw",                                                                                                                                                                                         
        "node": "ip-10-0-217-162.us-west-2.compute.internal",                                                          
        "instanceType": "m5.2xlarge",                                                                                                                                                                                                         
        "rps": 8234.8,                                                                                                 
        "rps_stdev": 558.69,                                                                                                                                                                                                                  
        "stdev_lat": 1693.48,                                                                                                                                                                                                                 
        "avg_lat_us": 2607.02,                                                                                         
        "max_lat_us": 33100,                                                                                           
        "p90_lat_us": 3930,                                                                                                                                                                                                                   
        "p95_lat_us": 5845,                                                                                                                                                                                                                   
        "p99_lat_us": 10033,                                                                                           
        "http_errors": 0,                                                                                                                                                                                                                     
        "read_errors": 0,                                                                                                                                                                                                                     
        "write_errors": 0,                                                                                             
        "requests": 83167,                                                                                                                                                                                                                    
        "timeouts": 0                                                                                                  
      }                                                                                                                
    ],                                                                                                                                                                                                                                        
    "timestamp": "2023-09-21T10:22:54.989431717Z",                                                                                                                                                                                            
    "total_avg_rps": 8234.8,                                                                                           
    "rps_stdev": 558.69,                                                                                                                                                                                                                      
    "stdev_lat": 1693.48,                                                                                              
    "avg_lat_us": 2607.02,                                                                                                                                                                                                                    
    "max_lat_us": 33100,                                                                                                                                                                                                                      
    "p90_lat_us": 3930,                                                                                                                                                                                                                       
    "p95_lat_us": 5845,                                                                                                
    "p99_lat_us": 10033,                                                                                               
    "http_errors": 0,                                                                                                  
    "read_errors": 0,                                                                                                  
    "write_errors": 0,                                                                                                                                                                                                                        
    "requests": 83167,                                                                                                                                                                                                                        
    "timeouts": 0,                                                                                                                                                                                                                            
    "version": "haproxy-version@4370fc8",                                                                                                                                                                    
    "platform": "AWS",                                                                                                                                                                                                                        
    "clusterType": "self-managed",                                                                                                                                                                                                            
    "ocpVersion": "4.12.18",                                                                                                                                                                                                                  
    "ocpMajorVersion": "4.12",                                                                                         
    "k8sVersion": "v1.25.8+37a9a08",                                                                                   
    "masterNodesType": "m5.2xlarge",                                                                                                                                                                                                          
    "workerNodesType": "m5.large",      
    "masterNodesCount": 3,                                                                                             
    "infraNodesType": "",                                                                                              
    "workerNodesCount": 5,                                                                                             
    "infraNodesCount": 0,                                                                                              
    "otherNodesCount": 0,        
    "totalNodes": 5,                                                                                                   
    "sdnType": "OpenShiftSDN",                                                                                         
    "clusterName": "cloud-bulldozer-ci-6hwqr",
    "region": "us-west-2",               
    "haproxyVersion": "haproxy22-2.2.24-3.rhaos4.12.el8.x86_64"                                                        
  }                                                                                                                    
] 
```

Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 authored Sep 22, 2023
1 parent 1186865 commit 00d857b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
3 changes: 1 addition & 2 deletions pkg/runner/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"sync"
"time"

ocpmetadata "github.com/cloud-bulldozer/go-commons/ocp-metadata"
"github.com/cloud-bulldozer/go-commons/version"
"github.com/cloud-bulldozer/ingress-perf/pkg/config"
"github.com/cloud-bulldozer/ingress-perf/pkg/runner/tools"
Expand All @@ -36,7 +35,7 @@ import (

var lock = &sync.Mutex{}

func runBenchmark(cfg config.Config, clusterMetadata ocpmetadata.ClusterMetadata) ([]tools.Result, error) {
func runBenchmark(cfg config.Config, clusterMetadata tools.ClusterMetadata) ([]tools.Result, error) {
var aggAvgRps, aggAvgLatency, aggP99Latency float64
var timeouts, httpErrors int64
var benchmarkResult []tools.Result
Expand Down
52 changes: 52 additions & 0 deletions pkg/runner/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package runner

import (
"bytes"
"context"
"strings"

log "github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/remotecommand"
)

func getHAProxyVersion() (string, error) {
var stdout, stderr bytes.Buffer
podList, err := clientSet.CoreV1().Pods("openshift-ingress").List(context.TODO(),
metav1.ListOptions{
LabelSelector: "ingresscontroller.operator.openshift.io/deployment-ingresscontroller=default",
FieldSelector: "status.phase=Running"},
)
if err != nil {
return "", err
}
routerPod := podList.Items[0]
req := clientSet.CoreV1().RESTClient().Post().
Resource("pods").
Name(routerPod.Name).
Namespace(routerPod.Namespace).
SubResource("exec")
req.VersionedParams(&corev1.PodExecOptions{
Container: "router",
Stdin: false,
Stdout: true,
Stderr: true,
Command: []string{"bash", "-c", "rpm -qa | grep haproxy"},
TTY: false,
}, scheme.ParameterCodec)
exec, err := remotecommand.NewSPDYExecutor(restConfig, "POST", req.URL())
if err != nil {
log.Error(err.Error())
return "", err
}
err = exec.StreamWithContext(context.TODO(), remotecommand.StreamOptions{
Stdout: &stdout,
Stderr: &stderr,
})
if err != nil {
return "", err
}
return strings.TrimRight(stdout.String(), "\n"), err
}
7 changes: 6 additions & 1 deletion pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func Start(uuid, baseUUID, baseIndex string, tolerancy int, indexer *indexers.In
var kubeconfig string
var benchmarkResult []tools.Result
var comparator comparison.Comparator
var clusterMetadata tools.ClusterMetadata
passed := true
if os.Getenv("KUBECONFIG") != "" {
kubeconfig = os.Getenv("KUBECONFIG")
Expand All @@ -72,7 +73,11 @@ func Start(uuid, baseUUID, baseIndex string, tolerancy int, indexer *indexers.In
if err != nil {
return err
}
clusterMetadata, err := ocpMetadata.GetClusterMetadata()
clusterMetadata.ClusterMetadata, err = ocpMetadata.GetClusterMetadata()
if err != nil {
return err
}
clusterMetadata.HAProxyVersion, err = getHAProxyVersion()
if err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/runner/tools/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ import (
"github.com/cloud-bulldozer/ingress-perf/pkg/config"
)

// We need to embed ClusterMetadata in order to add extra fields to it
type ClusterMetadata struct {
ocpmetadata.ClusterMetadata
HAProxyVersion string `json:"haproxyVersion,omitempty"`
}

type Tool interface {
ParseResult(string, string) (PodResult, error)
Cmd() []string
Expand Down Expand Up @@ -65,5 +71,5 @@ type Result struct {
Requests int64 `json:"requests"`
Timeouts int64 `json:"timeouts"`
Version string `json:"version"`
ocpmetadata.ClusterMetadata
ClusterMetadata
}

0 comments on commit 00d857b

Please sign in to comment.