Skip to content

Commit

Permalink
Fixing indexing bugs for workers-scale (#126)
Browse files Browse the repository at this point in the history
Signed-off-by: Vishnu Challa <[email protected]>
Co-authored-by: Vishnu Challa <[email protected]>
  • Loading branch information
vishnuchalla and Vishnu Challa authored Oct 26, 2024
1 parent c86b6a2 commit c972a46
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ jobs:
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false

- name: Set up Go 1.21.1
uses: actions/setup-go@v5
with:
go-version: 1.21.1

- name: Set up Go environment
run: go env -w GOPROXY=direct

Expand Down
6 changes: 6 additions & 0 deletions pkg/workerscale/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,13 @@ func calculateMetrics(machineSetsToEdit *sync.Map, scaledMachineDetails map[stri
nmValue, _ := nodeMetrics.Load(info.nodeUID)
nodeMetricValue := nmValue.(measurements.NodeMetric)
uuid = nodeMetricValue.UUID
// Prevents OS indexing error due to conflicts
if osID, exists := nodeMetricValue.Labels["node.openshift.io/os_id"]; exists {
nodeMetricValue.Labels["node_openshift_io_os_id"] = osID
delete(nodeMetricValue.Labels, "node.openshift.io/os_id")
}
normLatencies = append(normLatencies, NodeReadyMetric{
Timestamp: time.Now().UTC(),
ScaleEventTimestamp: scaleEventTimestamp,
MachineCreationTimestamp: machineCreationTimeStamp,
MachineCreationLatency: int(machineCreationTimeStamp.Sub(scaleEventTimestamp).Milliseconds()),
Expand Down
7 changes: 7 additions & 0 deletions pkg/workerscale/rosa.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"os/exec"
"sync"
"time"
Expand Down Expand Up @@ -125,6 +126,8 @@ func editMachinepool(clusterID string, minReplicas int, maxReplicas int, autoSca
cmdArgs = append(cmdArgs, fmt.Sprintf("--replicas=%d", maxReplicas))
}
cmd := exec.Command("rosa", cmdArgs...)
// Pass the current environment to the command
cmd.Env = os.Environ()
editOutput, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("Failed to edit machinepool: %v. Output: %s", err, string(editOutput))
Expand All @@ -144,6 +147,8 @@ func verifyRosaInstall() {
log.Info("ROSA CLI is installed.")

cmd := exec.Command("rosa", "whoami")
// Pass the current environment to the command
cmd.Env = os.Environ()
output, err := cmd.CombinedOutput()
if err != nil {
log.Fatal("You are not logged in. Please login using 'rosa login' and retry.")
Expand Down Expand Up @@ -173,6 +178,8 @@ func getClusterID(dynamicClient dynamic.Interface, mcPrescence bool) string {
// Special case for hcp where cluster version object has external ID
if mcPrescence {
cmd := exec.Command("rosa", "describe", "cluster", "-c", clusterID, "-o", "json")
// Pass the current environment to the command
cmd.Env = os.Environ()
output, err := cmd.CombinedOutput()
if err != nil {
log.Fatalf("Failed to describe cluster: %v", err)
Expand Down
3 changes: 2 additions & 1 deletion pkg/workerscale/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ type ProviderStatus struct {

// NodeReadyMetric to capture details on node bootup
type NodeReadyMetric struct {
ScaleEventTimestamp time.Time `json:"-"`
Timestamp time.Time `json"timestamp"`

Check failure on line 79 in pkg/workerscale/types.go

View workflow job for this annotation

GitHub Actions / ci-tests / lint / linters

structtag: struct field tag `json"timestamp"` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair (govet)
ScaleEventTimestamp time.Time `json:"scaleEventTimestamp"`
MachineCreationTimestamp time.Time `json:"-"`
MachineCreationLatency int `json:"machineCreationLatency"`
MachineReadyTimestamp time.Time `json:"-"`
Expand Down
3 changes: 3 additions & 0 deletions workers-scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func NewWorkersScale(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata
Long: "If no other indexer is specified, local indexer is used by default",
SilenceUsage: true,
PostRun: func(cmd *cobra.Command, args []string) {
log.Info("👋 Exiting kube-burner ", uuid)
os.Exit(rc)
},
Run: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -96,6 +97,8 @@ func NewWorkersScale(metricsEndpoint *string, ocpMetaAgent *ocpmetadata.Metadata
}

clusterMetadata, err = ocpMetaAgent.GetClusterMetadata()
clusterMetadata.WorkerNodesCount += additionalWorkerNodes
clusterMetadata.TotalNodes += additionalWorkerNodes
if err != nil {
log.Fatal("Error obtaining clusterMetadata: ", err.Error())
}
Expand Down

0 comments on commit c972a46

Please sign in to comment.