Skip to content
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

Fixing indexing bugs for workers-scale #126

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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"`
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
Loading