Skip to content

fix: compare infra versions semantically#5520

Open
immanuwell wants to merge 4 commits into
litmuschaos:masterfrom
immanuwell:fix/infra-version-comparison
Open

fix: compare infra versions semantically#5520
immanuwell wants to merge 4 commits into
litmuschaos:masterfrom
immanuwell:fix/infra-version-comparison

Conversation

@immanuwell

@immanuwell immanuwell commented May 21, 2026

Copy link
Copy Markdown

Proposed changes

Fix latest infra version picking in getVersionDetails. The old path flattened x.y.z into an int, so 3.29.0 became 590 and beat 4.0.0 as 400. tiny edge case but real.

Related: #4665, #4666

Repro:

  1. Set INFRA_COMPATIBLE_VERSIONS='["3.29.0","4.0.0"]'
  2. Call GetVersionDetails / GraphQL getVersionDetails.
  3. Before: latestVersion is 3.29.0; after: 4.0.0.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

None.

Special notes for your reviewer:

Tested with go test ./pkg/chaos_infrastructure/... -count=1

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes infra “latestVersion” selection in GetVersionDetails by replacing the previous numeric-flattening approach with a semantic (major/minor/patch) comparison, preventing cases like 3.29.0 incorrectly sorting above 4.0.0.

Changes:

  • Replaced integer-flattening version logic with semantic parsing/comparison (major.minor.patch).
  • Removed the old fetchLatestVersion / updateVersionFormat logic in favor of compareInfraVersions + parseInfraVersion.
  • Added unit tests asserting correct latest version selection for semantic versions and the "ci" tag.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go Implements semantic parsing/comparison for compatible infra versions and uses it to compute LatestVersion.
chaoscenter/graphql/server/pkg/chaos_infrastructure/service_test.go Adds regression tests for semantic latest-version selection and "ci" behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go
Comment thread chaoscenter/graphql/server/pkg/chaos_infrastructure/service.go
Comment thread chaoscenter/graphql/server/pkg/chaos_infrastructure/service_test.go
@PriteshKiri

Copy link
Copy Markdown
Contributor

Hey @immanuwell
Could you please check the review comments from Co-Pilot?

Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix/infra-version-comparison branch from b86b3d7 to df8f027 Compare June 13, 2026 14:07
@immanuwell

Copy link
Copy Markdown
Author

@PriteshKiri done, I addressed all 3 suggestions

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 38 out of 43 changed files in this pull request and generated 4 comments.

ContainerRuntimeExecutor string `required:"true" split_words:"true"`
WorkflowHelperImageVersion string `required:"true" split_words:"true"`
ChaosCenterUiEndpoint string `split_words:"true" default:"https://localhost:8080"`
ChaosGraphQLEndpoint string `split_words:"true" default:"http://chaos-litmus-server-service:9002"`
Comment on lines 22 to 29
func GetEndpoint(host string) (string, error) {
const apiPath = "/api/query"
const apiPath = "/query"
// returns endpoint from env, if provided by user
if utils.Config.ChaosCenterUiEndpoint != "" {
return strings.TrimRight(utils.Config.ChaosCenterUiEndpoint, "/") + apiPath, nil
if utils.Config.ChaosGraphQLEndpoint != "" {
return strings.TrimRight(utils.Config.ChaosGraphQLEndpoint, "/") + apiPath, nil
}

return strings.TrimRight(host, "/") + apiPath, nil
Comment on lines +14 to 16
"getProject": {string(entities.RoleOwner), string(entities.RoleViewer), string(entities.RoleExecutor)},
"getActiveProjectMembers": {string(entities.RoleOwner)},
}
Comment on lines 898 to 906
// GetVersionDetails returns the compatible infra versions and the latest infra version supported for the current control plane version
func (in *infraService) GetVersionDetails() (*model.InfraVersionDetails, error) {
// Fetching the list of infra compatible versions
compatibleVersions := utils.Config.InfraCompatibleVersions

var compatibleArray []string
if err := json.Unmarshal([]byte(compatibleVersions), &compatibleArray); err != nil {
return &model.InfraVersionDetails{}, fmt.Errorf("failed to parse InfraCompatibleVersions config: %w", err)
}
@PriteshKiri

Copy link
Copy Markdown
Contributor

Hey @immanuwell
Could you please address the review comments by co-pilot?

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.

3 participants