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

Upgrade the agent scaler which introduces a new agent endpoint param #1437

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

wolfeidau
Copy link
Contributor

@wolfeidau wolfeidau commented Jan 20, 2025

Warning

This release will force an upgrade of the agent scaler by checking the version is 1.9.1 or higher. This is required so we can introduce a new parameter to the agent scaler to pass through agent endpoint.

see buildkite/buildkite-agent-scaler#203

This is an go based test which shows the regex works as intended, maybe helpful in the future.

package semver

import (
	"regexp"
	"testing"
)

func isGreaterThan190(version string) bool {
	pattern := `^(?:(?:[2-9]|[1-9]\d+)\.\d+\.\d+|1\.(?:[1-9]\d+\.\d+|9\.[1-9]\d*))$`
	matched, _ := regexp.MatchString(pattern, version)
	return matched
}

func TestVersionValidation(t *testing.T) {
	tests := []struct {
		name        string
		version     string
		want        bool
		description string
	}{
		{
			name:        "equal_to_boundary",
			version:     "1.9.0",
			want:        false,
			description: "Equal to boundary version",
		},
		{
			name:        "just_above_boundary",
			version:     "1.9.1",
			want:        true,
			description: "Just above boundary version",
		},
		{
			name:        "above_boundary",
			version:     "1.9.2",
			want:        true,
			description: "Above boundary version",
		},
		{
			name:        "minor_version_increment",
			version:     "1.10.0",
			want:        true,
			description: "Minor version increment",
		},
		{
			name:        "major_version_increment",
			version:     "2.0.0",
			want:        true,
			description: "Major version increment",
		},
		{
			name:        "below_boundary",
			version:     "1.8.9",
			want:        false,
			description: "Below boundary version",
		},
		{
			name:        "lower_major_version",
			version:     "0.9.9",
			want:        false,
			description: "Lower major version",
		},
		{
			name:        "higher_major_version",
			version:     "2.9.1",
			want:        true,
			description: "Higher major version",
		},
		{
			name:        "double_digit_patch",
			version:     "1.9.10",
			want:        true,
			description: "Double digit patch version",
		},
		{
			name:        "double_digit_major",
			version:     "10.0.0",
			want:        true,
			description: "Double digit major version",
		},
	}

	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			got := isGreaterThan190(tt.version)
			if got != tt.want {
				t.Errorf("\nVersion: %v\nWant: %v\nGot: %v\nDescription: %v",
					tt.version, tt.want, got, tt.description)
			}
		})
	}
}

Results:

%  go test -v ./semver_test.go
=== RUN   TestVersionValidation
=== RUN   TestVersionValidation/equal_to_boundary
=== RUN   TestVersionValidation/just_above_boundary
=== RUN   TestVersionValidation/above_boundary
=== RUN   TestVersionValidation/minor_version_increment
=== RUN   TestVersionValidation/major_version_increment
=== RUN   TestVersionValidation/below_boundary
=== RUN   TestVersionValidation/lower_major_version
=== RUN   TestVersionValidation/higher_major_version
=== RUN   TestVersionValidation/double_digit_patch
=== RUN   TestVersionValidation/double_digit_major
--- PASS: TestVersionValidation (0.00s)
    --- PASS: TestVersionValidation/equal_to_boundary (0.00s)
    --- PASS: TestVersionValidation/just_above_boundary (0.00s)
    --- PASS: TestVersionValidation/above_boundary (0.00s)
    --- PASS: TestVersionValidation/minor_version_increment (0.00s)
    --- PASS: TestVersionValidation/major_version_increment (0.00s)
    --- PASS: TestVersionValidation/below_boundary (0.00s)
    --- PASS: TestVersionValidation/lower_major_version (0.00s)
    --- PASS: TestVersionValidation/higher_major_version (0.00s)
    --- PASS: TestVersionValidation/double_digit_patch (0.00s)
    --- PASS: TestVersionValidation/double_digit_major (0.00s)
PASS
ok      command-line-arguments  0.248s

This introduces a check on the agent scaler version which requires it to be above 1.9.1 to use the new agent endpoint parameter.
@wolfeidau wolfeidau force-pushed the feat_override_agent_endpoint_for_scaler branch from bd26749 to 6af2550 Compare January 20, 2025 23:24
templates/aws-stack.yml Outdated Show resolved Hide resolved
@wolfeidau wolfeidau requested a review from DrJosh9000 January 21, 2025 01:16
@wolfeidau wolfeidau merged commit 0ea96a9 into main Jan 21, 2025
1 check passed
@wolfeidau wolfeidau deleted the feat_override_agent_endpoint_for_scaler branch January 21, 2025 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants