OCPBUGS-100246: Fix e2es on CAPI-native clusters - #641
Conversation
Fixes tests which assume there is at least one MAPI machineset created by openshift-installer which they can use as a template for creating new MachineSets. Rewrites the Cluster API AWS MachineSet suite, because it no longer makes sense in the context of a CAPI native cluster. Retains the verifyCAPIInstanceOwnershipTag test as a separate test, but skips the compareInstances test because: * there's nothing to compare against * it's the default worker machineset, so the conformance tests will confirm it's correct
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@mdbooth: This pull request references Jira Issue OCPBUGS-100246, which is valid. 3 validation(s) were run on this bug
The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
WalkthroughChangesThe AWS e2e tests now support native and Machine API migration scenarios. They discover MAPI and CAPI worker MachineSets, select resources by migration authority, resolve the AWS region, and validate instances and ownership tags. Shared scheme registration, fallback discovery, machine creation, and module dependencies were updated. AWS Machine Migration E2E Support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant AWSMigrationTests
participant FeatureGate
participant KubernetesAPI
participant AWSCluster
participant AWSClient
AWSMigrationTests->>FeatureGate: Read MachineAPIMigration authority
AWSMigrationTests->>KubernetesAPI: Discover MAPI and CAPI worker MachineSets
AWSMigrationTests->>KubernetesAPI: Create temporary CAPI MachineSet when required
AWSMigrationTests->>AWSCluster: Read CAPI AWSCluster region when needed
AWSMigrationTests->>AWSClient: Initialize client for selected region
AWSMigrationTests->>AWSClient: Compare instances and verify ownership tags
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5 | ❌ 10❌ Failed checks (10 inconclusive)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: Ping-pong health check failed Comment |
|
/pipeline auto |
|
Pipeline controller notification The |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
e2e/aws_test.go (1)
22-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsolidate duplicate aliases for the same package.
machinev1(line 23) andmapiv1beta1(line 24) both aliasgithub.com/openshift/api/machine/v1beta1. Both aliases are used for the same underlying types throughout the file (for example,mapiv1beta1.MachineSetandmachinev1.MachineSetare identical types). This compiles, but it makes the MAPI/CAPI type juggling in this file harder to follow. Use a single alias for this package.Please confirm that importing the same package path twice under different local names is intentional and not left over from a refactor; if not intentional, consolidate to one alias (for example
machinev1) throughout the file.🤖 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 `@e2e/aws_test.go` around lines 22 - 34, Consolidate the duplicate imports of github.com/openshift/api/machine/v1beta1 in the e2e test: retain a single alias, preferably machinev1, and update all references currently using mapiv1beta1 to that alias while preserving the existing type behavior.
🤖 Prompt for all review comments with 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.
Inline comments:
In `@e2e/aws_helpers.go`:
- Around line 142-144: Update the failure message in the Eventually assertion
for capiMachineList to include the missing “find” verb, changing it to “Failed
to find at least one CAPI AWSMachine for MachineSet %s” while preserving the
existing formatting and assertion behavior.
In `@e2e/aws_test.go`:
- Around line 148-155: Update createCAPIMachineSetFromMAPI so DeferCleanup is
registered only when cl.Create successfully creates awsMachineTemplate; keep
cleanup unregistered when the error is apierrors.IsAlreadyExists, while
preserving failure handling for all other errors.
In `@e2e/machine_migration_helpers.go`:
- Line 152: Update the assertion message for referenceMachineSet to use the full
user-facing names “Machine API” and “Cluster API” instead of the abbreviations
“MAPI” and “CAPI”, while preserving the existing assertion behavior.
---
Nitpick comments:
In `@e2e/aws_test.go`:
- Around line 22-34: Consolidate the duplicate imports of
github.com/openshift/api/machine/v1beta1 in the e2e test: retain a single alias,
preferably machinev1, and update all references currently using mapiv1beta1 to
that alias while preserving the existing type behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: af715b86-f68a-4e9e-a350-dee92b1c8367
⛔ Files ignored due to path filters (120)
e2e/go.sumis excluded by!**/*.sumgo.sumis excluded by!**/*.sumgo.work.sumis excluded by!**/*.sumhack/tools/go.sumis excluded by!**/*.summanifests-gen/go.sumis excluded by!**/*.sumopenshift-tests-extension/go.sumis excluded by!**/*.sumvendor/github.com/aws/aws-sdk-go-v2/aws/go_module_metadata.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/aws/aws-sdk-go-v2/service/ec2/types/enums.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/aws/aws-sdk-go-v2/service/ec2/types/types.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/aws/smithy-go/CHANGELOG.mdis excluded by!**/vendor/**,!vendor/**vendor/github.com/aws/smithy-go/README.mdis excluded by!**/vendor/**,!vendor/**vendor/github.com/aws/smithy-go/go_module_metadata.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/aws/smithy-go/middleware/eventstream_middleware.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/fatih/color/color.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/fatih/color/color_windows.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/hashicorp/go-version/CHANGELOG.mdis excluded by!**/vendor/**,!vendor/**vendor/github.com/hashicorp/go-version/README.mdis excluded by!**/vendor/**,!vendor/**vendor/github.com/hashicorp/go-version/version.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/CHANGELOG.mdis excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/README.mdis excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/format/format.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/gomega_dsl.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/matchers.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/matchers/be_a_slice_matcher.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/matchers/be_an_array_matcher.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/onsi/gomega/types/types.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift-eng/openshift-tests-extension/pkg/cmd/cmdrun/runsuite.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests/scheduler.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests/spec.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests/types.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift-eng/openshift-tests-extension/pkg/extension/types.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo/parallel.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/framework/capi_helpers.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/framework/capi_machinesets.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/cluster-api-actuator-pkg/pkg/framework/machinesets.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/cluster-api-actuator-pkg/testutils/Makefileis excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/clusterautoscaler_types.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/cluster-autoscaler-operator/pkg/apis/autoscaling/v1/zz_generated.deepcopy.gois excluded by!**/vendor/**,!vendor/**,!**/zz_generated*vendor/github.com/openshift/machine-api-operator/pkg/webhooks/machine_webhook.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/machine-api-operator/pkg/webhooks/machineset_webhook.gois excluded by!**/vendor/**,!vendor/**vendor/github.com/openshift/machine-api-operator/pkg/webhooks/vap.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/.golangci.ymlis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/AGENTS.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/CHANGELOG.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/CLAUDE.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/CONTRIBUTING.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/Makefileis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/RELEASING.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/encoder.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/hash.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/internal/attribute.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/key.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/kv.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/set.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/type_string.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/attribute/value.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/baggage/baggage.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/dependencies.Dockerfileis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/metric/asyncfloat64.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/metric/asyncint64.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/metric/config.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/metric/doc.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/metric/instrument.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/metric/syncfloat64.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/metric/syncint64.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/propagation/baggage.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.37.0/attribute_group.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.39.0/attribute_group.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.39.0/httpconv/metric.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.39.0/otelconv/metric.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.39.0/rpcconv/metric.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.40.0/README.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.41.0/MIGRATION.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.41.0/README.mdis excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.41.0/attribute_group.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.41.0/doc.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.41.0/error_type.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.41.0/exception.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/semconv/v1.41.0/schema.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/trace/auto.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/trace/config.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/trace/internal/telemetry/span.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/trace/trace.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/version.gois excluded by!**/vendor/**,!vendor/**vendor/go.opentelemetry.io/otel/versions.yamlis excluded by!**/vendor/**,!vendor/**vendor/golang.org/x/mod/modfile/read.gois excluded by!**/vendor/**,!vendor/**vendor/golang.org/x/mod/modfile/rule.gois excluded by!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/annotations/client.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/annotations/field_behavior.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/annotations/field_info.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/annotations/http.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/annotations/resource.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/annotations/routing.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/checked.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/eval.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/explain.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/syntax.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/expr/v1alpha1/value.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/httpbody/httpbody.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/api/launch_stage.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/rpc/errdetails/error_details.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/google.golang.org/genproto/googleapis/rpc/status/status.pb.gois excluded by!**/*.pb.go,!**/vendor/**,!vendor/**vendor/k8s.io/utils/strings/slices/slices.gois excluded by!**/vendor/**,!vendor/**vendor/modules.txtis excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/README.mdis excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/env/env.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/env/exit.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/env/helpers.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/main.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/remote/http_client.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/remote/read_body.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/store/store.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/version/version.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/versions/version.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest/workflows/workflows.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/structured-merge-diff/v6/fieldpath/element.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/structured-merge-diff/v6/fieldpath/pathelementmap.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/structured-merge-diff/v6/fieldpath/set.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/structured-merge-diff/v6/value/allocator.gois excluded by!**/vendor/**,!vendor/**vendor/sigs.k8s.io/structured-merge-diff/v6/value/jsontagutil.gois excluded by!**/vendor/**,!vendor/**
📒 Files selected for processing (10)
e2e/aws_helpers.goe2e/aws_test.goe2e/e2e_common.goe2e/framework/providerspec.goe2e/go.mode2e/machine_migration_helpers.gogo.modhack/tools/go.modmanifests-gen/go.modopenshift-tests-extension/go.mod
| Eventually(komega.ObjectList(capiMachineList, client.InNamespace(framework.CAPINamespace), client.MatchingLabels{ | ||
| machineSetOpenshiftLabelKey: msName, | ||
| })).Should(HaveField("Items", HaveLen(1)), "Failed to find exactly one CAPI AWSMachine for MachineSet %s", msName) | ||
| clusterv1.MachineSetNameLabel: msName, | ||
| })).Should(HaveField("Items", Not(BeEmpty())), "Failed to at least one CAPI AWSMachine for MachineSet %s", msName) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Fix the failure message grammar.
The message "Failed to at least one CAPI AWSMachine for MachineSet %s" omits a verb. Use "Failed to find at least one CAPI AWSMachine for MachineSet %s" so the test failure output reads correctly.
✏️ Proposed fix
- })).Should(HaveField("Items", Not(BeEmpty())), "Failed to at least one CAPI AWSMachine for MachineSet %s", msName)
+ })).Should(HaveField("Items", Not(BeEmpty())), "Failed to find at least one CAPI AWSMachine for MachineSet %s", msName)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Eventually(komega.ObjectList(capiMachineList, client.InNamespace(framework.CAPINamespace), client.MatchingLabels{ | |
| machineSetOpenshiftLabelKey: msName, | |
| })).Should(HaveField("Items", HaveLen(1)), "Failed to find exactly one CAPI AWSMachine for MachineSet %s", msName) | |
| clusterv1.MachineSetNameLabel: msName, | |
| })).Should(HaveField("Items", Not(BeEmpty())), "Failed to at least one CAPI AWSMachine for MachineSet %s", msName) | |
| Eventually(komega.ObjectList(capiMachineList, client.InNamespace(framework.CAPINamespace), client.MatchingLabels{ | |
| clusterv1.MachineSetNameLabel: msName, | |
| })).Should(HaveField("Items", Not(BeEmpty())), "Failed to find at least one CAPI AWSMachine for MachineSet %s", msName) |
🤖 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 `@e2e/aws_helpers.go` around lines 142 - 144, Update the failure message in the
Eventually assertion for capiMachineList to include the missing “find” verb,
changing it to “Failed to find at least one CAPI AWSMachine for MachineSet %s”
while preserving the existing formatting and assertion behavior.
| func createCAPIMachineSetFromMAPI(mapiMachineSet *mapiv1beta1.MachineSet) *clusterv1.MachineSet { | ||
| awsMachineTemplate := newAWSMachineTemplate(mapiMachineSet, infra) | ||
| if err := cl.Create(ctx, awsMachineTemplate); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| Expect(err).ToNot(HaveOccurred(), "should not fail creating AWS machine template") | ||
| } | ||
| DeferCleanup(func() { | ||
| framework.DeleteObjects(ctx, cl, awsMachineTemplate) | ||
| }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔴 Critical | ⚡ Quick win
Only clean up the AWS machine template this test creates.
cl.Create tolerates apierrors.IsAlreadyExists(err), meaning the template may already exist and was not created by this test. Despite that, DeferCleanup unconditionally deletes awsMachineTemplate. If the template already existed and is owned by another resource (an existing worker MachineSet, or an automatic MAPI-to-CAPI sync mechanism), this cleanup deletes a resource this test does not own, and can break that other resource's reconciliation.
Register the cleanup only when this call actually created the object.
🛡️ Proposed fix
- awsMachineTemplate := newAWSMachineTemplate(mapiMachineSet, infra)
- if err := cl.Create(ctx, awsMachineTemplate); err != nil && !apierrors.IsAlreadyExists(err) {
- Expect(err).ToNot(HaveOccurred(), "should not fail creating AWS machine template")
- }
- DeferCleanup(func() {
- framework.DeleteObjects(ctx, cl, awsMachineTemplate)
- })
+ awsMachineTemplate := newAWSMachineTemplate(mapiMachineSet, infra)
+ err := cl.Create(ctx, awsMachineTemplate)
+ if err != nil && !apierrors.IsAlreadyExists(err) {
+ Expect(err).ToNot(HaveOccurred(), "should not fail creating AWS machine template")
+ }
+ if err == nil {
+ DeferCleanup(func() {
+ framework.DeleteObjects(ctx, cl, awsMachineTemplate)
+ })
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func createCAPIMachineSetFromMAPI(mapiMachineSet *mapiv1beta1.MachineSet) *clusterv1.MachineSet { | |
| awsMachineTemplate := newAWSMachineTemplate(mapiMachineSet, infra) | |
| if err := cl.Create(ctx, awsMachineTemplate); err != nil && !apierrors.IsAlreadyExists(err) { | |
| Expect(err).ToNot(HaveOccurred(), "should not fail creating AWS machine template") | |
| } | |
| DeferCleanup(func() { | |
| framework.DeleteObjects(ctx, cl, awsMachineTemplate) | |
| }) | |
| func createCAPIMachineSetFromMAPI(mapiMachineSet *mapiv1beta1.MachineSet) *clusterv1.MachineSet { | |
| awsMachineTemplate := newAWSMachineTemplate(mapiMachineSet, infra) | |
| err := cl.Create(ctx, awsMachineTemplate) | |
| if err != nil && !apierrors.IsAlreadyExists(err) { | |
| Expect(err).ToNot(HaveOccurred(), "should not fail creating AWS machine template") | |
| } | |
| if err == nil { | |
| DeferCleanup(func() { | |
| framework.DeleteObjects(ctx, cl, awsMachineTemplate) | |
| }) | |
| } |
🤖 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 `@e2e/aws_test.go` around lines 148 - 155, Update createCAPIMachineSetFromMAPI
so DeferCleanup is registered only when cl.Create successfully creates
awsMachineTemplate; keep cleanup unregistered when the error is
apierrors.IsAlreadyExists, while preserving failure handling for all other
errors.
| // MachineSet exists. | ||
| referenceMachineSet, err := mapiframework.GetSampleMAPIWorkerMachineSet(ctx, cl) | ||
| Expect(err).ToNot(HaveOccurred(), "getting a sample worker MachineSet should not error") | ||
| Expect(referenceMachineSet).ToNot(BeNil(), "expected to find a MAPI or CAPI worker MachineSet") |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use full API names in the assertion message.
Line 152 exposes MAPI and CAPI when the assertion fails. Replace them with Machine API and Cluster API.
As per coding guidelines, “For user-facing text like logs and errors, use 'Cluster API' and 'Machine API'.”
Proposed fix
- Expect(referenceMachineSet).ToNot(BeNil(), "expected to find a MAPI or CAPI worker MachineSet")
+ Expect(referenceMachineSet).ToNot(BeNil(), "expected to find a Machine API or Cluster API worker MachineSet")📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| Expect(referenceMachineSet).ToNot(BeNil(), "expected to find a MAPI or CAPI worker MachineSet") | |
| Expect(referenceMachineSet).ToNot(BeNil(), "expected to find a Machine API or Cluster API worker MachineSet") |
🤖 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 `@e2e/machine_migration_helpers.go` at line 152, Update the assertion message
for referenceMachineSet to use the full user-facing names “Machine API” and
“Cluster API” instead of the abbreviations “MAPI” and “CAPI”, while preserving
the existing assertion behavior.
Source: Coding guidelines
|
Scheduling tests matching the |
|
@mdbooth: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Fixes tests which assume there is at least one MAPI machineset created by openshift-installer which they can use as a template for creating new MachineSets.
Rewrites the Cluster API AWS MachineSet suite, because it no longer makes sense in the context of a CAPI native cluster. Retains the verifyCAPIInstanceOwnershipTag test as a separate test, but skips the compareInstances test because:
TODO:
/hold
Summary by CodeRabbit
Bug Fixes
Tests