Skip to content
Open
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
6 changes: 5 additions & 1 deletion internal/provider/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,13 @@ func GetActualCreateClusterPlatformParams(platform *models.Platform, userManaged
if cpuArchitecture == models.ClusterCPUArchitectureS390x || cpuArchitecture == models.ClusterCPUArchitecturePpc64le {
if userManagedNetworking != nil && !*userManagedNetworking {
return nil, nil, common.NewApiError(http.StatusBadRequest, errors.Errorf("Can't disable User Managed Networking on %s architecture", cpuArchitecture))
} else if platform != nil && !isPlatformNone(platform) {
} else if platform != nil && !isPlatformNone(platform) && !common.IsPlatformExternal(platform) {
return nil, nil, common.NewApiError(http.StatusBadRequest, errors.Errorf("Can't set %s platform on %s architecture", *platform.Type, cpuArchitecture))
}
// If platform is external, keep it; otherwise default to none
if platform != nil && common.IsPlatformExternal(platform) {
return platform, swag.Bool(true), nil
}
return createPlatformFromType(models.PlatformTypeNone), swag.Bool(true), nil
Comment on lines +313 to 317
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find existing tests for GetActualCreateClusterPlatformParams and any s390x/ppc64le external coverage
rg -nP --type=go -C3 'GetActualCreateClusterPlatformParams' -g '*_test.go'
rg -nP --type=go -C3 '(S390x|Ppc64le).*([Ee]xternal)|([Ee]xternal).*(S390x|Ppc64le)' -g '*_test.go'

Repository: openshift/assisted-service

Length of output: 52


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Locate platform external handling and the broader rejection logic
rg -n "IsPlatformExternal" -S --glob='*.go' .
rg -n "userManagedNetworking|UMN|ManagedNetworking" -S --glob='*.go' .
rg -n "ppc64le|s390x" -S --glob='*.go' .
rg -n "GetActualCreateClusterPlatformParams|create cluster platform|PlatformTypeExternal|PlatformTypeNone" -S --glob='*_test.go' .

# 2) Focus tests likely touching internal/provider/platform.go
rg -n "internal/provider/platform.go|platform\.go" -S --glob='*_test.go' .
rg -n "createPlatformFromType|PlatformTypeNone" -S --glob='*_test.go' .

# 3) List tests mentioning s390x/ppc64le explicitly
rg -n "ppc64le|s390x" -S --glob='*_test.go' .

Repository: openshift/assisted-service

Length of output: 50383


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Inspect the exact create params logic around the requested line range
echo "---- internal/provider/platform.go: GetActualCreateClusterPlatformParams ----"
sed -n '260,360p' internal/provider/platform.go | nl -ba | sed -n '1,120p'

# 2) Find s390x/ppc64le occurrences in tests only (small, architecture-scoped)
echo "---- s390x occurrences in *_test.go ----"
rg -n --glob='*_test.go' -S "s390x" . | head -n 50

echo "---- ppc64le occurrences in *_test.go ----"
rg -n --glob='*_test.go' -S "ppc64le" . | head -n 50

# 3) Find External platform tests and check if they mention cpuArchitecture/arch
echo "---- External platform + architecture mentions in *_test.go ----"
rg -n --glob='*_test.go' -S "(External platform|PlatformTypeExternal|platform_is_external|IsPlatformExternal)" . | head -n 50

echo "---- External platform test file: agentclusterinstall_validation_hook_test.go (spot check around External cases) ----"
rg -n --glob='agentclusterinstall_validation_hook_test.go' -S "External platform" pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook_test.go -n

Repository: openshift/assisted-service

Length of output: 209


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) Inspect the exact create params logic around the requested line range
echo "---- internal/provider/platform.go: GetActualCreateClusterPlatformParams ----"
sed -n '260,360p' internal/provider/platform.go | nl -ba | sed -n '1,120p'

# 2) Find s390x/ppc64le occurrences in tests only
echo "---- s390x occurrences in *_test.go ----"
rg -n --glob='*_test.go' -S "s390x" . | head -n 50

echo "---- ppc64le occurrences in *_test.go ----"
rg -n --glob='*_test.go' -S "ppc64le" . | head -n 50

# 3) Find External platform tests (and quickly spot-check)
echo "---- External platform / PlatformTypeExternal occurrences in *_test.go ----"
rg -n --glob='*_test.go' -S "(External platform|PlatformTypeExternal|IsPlatformExternal|platform_is_external)" . | head -n 80

# 4) Check whether the webhook tests pass cpuArchitecture through (relevant to the s390x/ppc64le branch)
echo "---- cpuArchitecture mentions in hiveextension v1beta1 tests ----"
rg -n -S --glob='*_test.go' "cpuArchitecture" pkg/webhooks/hiveextension/v1beta1 . | head -n 50

Repository: openshift/assisted-service

Length of output: 209


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- internal/provider/platform.go: GetActualCreateClusterPlatformParams ----"
# show with line numbers via cat -n
sed -n '260,360p' internal/provider/platform.go | cat -n | sed -n '1,120p'

echo "---- s390x occurrences in *_test.go (head 50) ----"
rg -n --glob='*_test.go' -S "s390x" . | head -n 50

echo "---- ppc64le occurrences in *_test.go (head 50) ----"
rg -n --glob='*_test.go' -S "ppc64le" . | head -n 50

echo "---- External platform / PlatformTypeExternal / IsPlatformExternal occurrences in *_test.go (head 80) ----"
rg -n --glob='*_test.go' -S "(External platform|PlatformTypeExternal|IsPlatformExternal|platform_is_external)" . | head -n 80

echo "---- cpuArchitecture mentions in hiveextension v1beta1 tests (head 50) ----"
rg -n -S --glob='*_test.go' "cpuArchitecture" pkg/webhooks/hiveextension/v1beta1 . | head -n 50

Repository: openshift/assisted-service

Length of output: 38281


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- usages of GetActualCreateClusterPlatformParams in repo (tests + prod) ----"
rg -n "GetActualCreateClusterPlatformParams\\(" . --glob='*.go' | head -n 50

echo "---- look for exact error strings in *_test.go ----"
rg -n --glob='*_test.go' "Can't disable User Managed Networking on" . || true
rg -n --glob='*_test.go' "Can't set .* platform on .* architecture" . || true

echo "---- inspect hiveextension validation hook tests for cpuArchitecture in External platform cases ----"
rg -n --glob='agentclusterinstall_validation_hook_test.go' "External platform" pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook_test.go
rg -n --glob='agentclusterinstall_validation_hook_test.go' "CPUArchitecture|cpuArchitecture" pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook_test.go

Repository: openshift/assisted-service

Length of output: 2276


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook_test.go"

# Inspect the External-platform create/update test cases to see what cpuArchitecture/CPUArchitecture is used
sed -n '620,820p' "$FILE" | cat -n
sed -n '820,900p' "$FILE" | cat -n

# Search within the same file for s390x/ppc64le mentions
rg -n "s390x|ppc64le|CPUArchitecture|cpuArchitecture" "$FILE" | head -n 200

# Look for tests combining external platform with s390x/ppc64le elsewhere
rg -n --glob='*_test.go' -S "(PlatformTypeExternal|External platform).*?(s390x|ppc64le)|(s390x|ppc64le).{0,120}?(PlatformTypeExternal|External platform)" . | head -n 200

Repository: openshift/assisted-service

Length of output: 11710


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook_test.go"
echo "---- CPUArchitecture/cpuArchitecture mentions in $FILE ----"
rg -n --glob='*.go' -S "CPUArchitecture|cpuArchitecture" "$FILE" || true
rg -n --glob='*.go' -S "s390x|ppc64le|PlatformTypeExternal|ExternalPlatformType" "$FILE" | head -n 200 || true

echo "---- look for s390x/ppc64le + External platform combinations in *_test.go ----"
rg -n --glob='*_test.go' -S "(PlatformTypeExternal|External platform).{0,200}(s390x|ppc64le)|(s390x|ppc64le).{0,200}(PlatformTypeExternal|External platform)" . | head -n 200

echo "---- search for exact architecture-branch error strings in *_test.go ----"
rg -n --glob='*_test.go' -S "Can't disable User Managed Networking on|Can't set .* platform on .* architecture" . || true

echo "---- inspect provider call site in agentclusterinstall_validation_hook.go ----"
sed -n '330,430p' pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook.go | cat -n

Repository: openshift/assisted-service

Length of output: 5524


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook_test.go"
echo "---- CPUArchitecture/cpuArchitecture mentions in $FILE ----"
rg -n -S "CPUArchitecture|cpuArchitecture" "$FILE" || true
rg -n -S "s390x|ppc64le|PlatformTypeExternal|ExternalPlatformType" "$FILE" | head -n 200 || true

echo "---- look for s390x/ppc64le + External platform combinations in *_test.go ----"
rg -n --glob='*_test.go' -S "(PlatformTypeExternal|External platform).{0,200}(s390x|ppc64le)|(s390x|ppc64le).{0,200}(PlatformTypeExternal|External platform)" . | head -n 200

echo "---- search for exact architecture-branch error strings in *_test.go ----"
rg -n --glob='*_test.go' -S "Can't disable User Managed Networking on|Can't set .* platform on .* architecture" . || true

echo "---- inspect provider call site in agentclusterinstall_validation_hook.go ----"
sed -n '330,430p' pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook.go | cat -n

Repository: openshift/assisted-service

Length of output: 5524


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Search unit tests for direct calls
rg -n --glob='*_test.go' "GetActualCreateClusterPlatformParams\\(" . || true

# Search for the s390x/ppc64le-specific error messages
rg -n --glob='*_test.go' "Can't disable User Managed Networking on|Can't set .* platform on .* architecture|User Managed Networking on s390x|User Managed Networking on ppc64le" . || true

Repository: openshift/assisted-service

Length of output: 52


Add unit tests for the s390x/ppc64le external-platform handling in GetActualCreateClusterPlatformParams

  • The cpuArchitecture == s390x/ppc64le branch (UMN=false rejection, non-none/non-external rejection, external accepted) isn’t exercised by existing webhook unit tests because pkg/webhooks/hiveextension/v1beta1/agentclusterinstall_validation_hook.go passes cpuArchitecture as "", and there are no tests calling GetActualCreateClusterPlatformParams directly.
  • Add table-driven tests covering, for both s390x and ppc64le: external+UMN=true allowed; UMN=false rejected; non-none/non-external rejected.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/provider/platform.go` around lines 313 - 317, Add table-driven unit
tests that directly call GetActualCreateClusterPlatformParams to exercise the
cpuArchitecture == "s390x" and "ppc64le" branches: for each arch, include cases
where (1) platform is external and userManagedNetworking (UMN) is true — expect
success, (2) UMN is false with external platform — expect rejection/error, and
(3) platform is a non-none/non-external type — expect rejection/error. Use the
same platform helper constructors used in production (e.g.,
createPlatformFromType and common.IsPlatformExternal behavior) and assert
returned platform, boolean flag, and error matches expectations; reference the
function name GetActualCreateClusterPlatformParams, the cpuArchitecture
parameter, and models.PlatformTypeNone in your tests so the coverage
specifically targets the rejected/accepted logic for s390x/ppc64le.

}

Expand Down