Skip to content

Conversation

@AmitSahastra
Copy link

What type of PR is this?

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Checklist:

  • squashed commits
  • includes documentation
  • includes emoji in title
  • adds unit tests
  • adds or updates e2e tests

Release note:


Copy link

@bulwark-spectrocloud bulwark-spectrocloud bot left a comment

Choose a reason for hiding this comment

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

⚠️ GoSec scan found code issues:

  1. G401: Use of weak cryptographic primitive, Severity: MEDIUM
      1. File: /home/runner/_work/bulwark/bulwark/target-repo/pkg/cloud/services/eks/iam/iam.go:532:13
  2. G505: Blocklisted import crypto/sha1: weak cryptographic primitive, Severity: MEDIUM
      1. File: /home/runner/_work/bulwark/bulwark/target-repo/pkg/cloud/services/eks/iam/iam.go:22:2

Please review these findings and fix the issues before merging.

Copy link

@bulwark-spectrocloud bulwark-spectrocloud bot left a comment

Choose a reason for hiding this comment

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

⚠️ GoVulnCheck scan found vulnerabilities:

  1. GO-2025-3553
    • Module: github.com/golang-jwt/jwt/v4
    • Found in: v4.5.1
    • Fixed in: v4.5.2
    • Example Traces:
      1. pkg/rosa/client.go:51:70: rosa.NewOCMClient calls ocm.Build, which eventually calls authentication.Build
  2. GO-2025-4123
    • Module: github.com/dvsekhvalnov/jose2go
    • Found in: v1.6.0
    • Fixed in: v1.7.0
    • Example Traces:
      1. pkg/rosa/client.go:51:70: rosa.NewOCMClient calls ocm.Build, which eventually calls keyring.Get

Please review these findings and fix the issues before merging.

Copy link

@bulwark-spectrocloud bulwark-spectrocloud bot left a comment

Choose a reason for hiding this comment

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

⚠️ GoSec scan found code issues:

  1. G401: Use of weak cryptographic primitive, Severity: MEDIUM
      1. File: /home/runner/_work/bulwark/bulwark/target-repo/pkg/cloud/services/eks/iam/iam.go:532:13
  2. G505: Blocklisted import crypto/sha1: weak cryptographic primitive, Severity: MEDIUM
      1. File: /home/runner/_work/bulwark/bulwark/target-repo/pkg/cloud/services/eks/iam/iam.go:22:2

Please review these findings and fix the issues before merging.

Copy link

Copilot AI left a comment

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 cherry-picks upstream changes related to Host Resource Group functionality into the Palette fork of the AWS Cluster API provider. The changes add support for dedicated host allocation options including static host IDs, host resource groups, and dynamic host allocation capabilities.

Key changes include:

  • Added new API fields for dedicated host allocation (HostID, HostResourceGroupArn, LicenseConfigurationArns, HostAffinity)
  • Implemented validation logic to ensure mutually exclusive host allocation options
  • Added support for capacity reservation preferences and CPU options for confidential computing

Reviewed changes

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

Show a summary per file
File Description
pkg/cloud/services/ec2/instances.go Implements host allocation logic in instance creation and adds error handling for licensing issues
api/v1beta2/types.go Defines new types for host allocation, capacity reservations, and CPU options
api/v1beta2/awsmachine_types.go Adds host allocation fields to AWSMachineSpec
api/v1beta2/awsmachine_webhook.go Implements validation for mutually exclusive host allocation options
api/v1beta2/awsmachine_webhook_test.go Adds test cases for host allocation validation
api/v1beta2/awsmachinetemplate_webhook.go Adds validation logic for host allocation in machine templates
api/v1beta2/awsmachinetemplate_webhook_test.go Adds test cases for template validation
api/v1beta2/zz_generated.deepcopy.go Auto-generated deep copy methods for new types
api/v1beta1/zz_generated.conversion.go Auto-generated conversion warnings for v1beta1 compatibility
api/v1beta1/awsmachine_conversion.go Implements conversion logic for new fields
api/v1beta1/awscluster_conversion.go Implements conversion logic for bastion host fields
config/crd/bases/*.yaml Updates CRD definitions with new fields and enhanced field descriptions
Comments suppressed due to low confidence (1)

api/v1beta2/awsmachinetemplate_webhook_test.go:1

  • Test case expects validation to pass when hostResourceGroupArn is specified without licenseConfigurationArns, but the validation logic at line 200-204 of awsmachinetemplate_webhook.go requires licenseConfigurationArns when hostResourceGroupArn is set. This test should expect wantErr: true.
/*

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

Comment on lines +261 to +272
//hostID, err := s.ensureDedicatedHostAllocation(context.Background(), scope)
//if err != nil {
// return nil, errors.Wrap(err, "failed to allocate dedicated host")
//}
//input.HostID = aws.String(hostID)
//input.HostAffinity = aws.String("host")

//if scope.AWSMachine.Status.DedicatedHost == nil {
// scope.AWSMachine.Status.DedicatedHost = &infrav1.DedicatedHostStatus{}
//}
//// Update machine status with allocated host ID
//scope.AWSMachine.Status.DedicatedHost.ID = &hostID
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The commented-out implementation for dynamic host allocation should either be removed or uncommented. Dead code that's checked in reduces code clarity and maintainability.

Suggested change
//hostID, err := s.ensureDedicatedHostAllocation(context.Background(), scope)
//if err != nil {
// return nil, errors.Wrap(err, "failed to allocate dedicated host")
//}
//input.HostID = aws.String(hostID)
//input.HostAffinity = aws.String("host")
//if scope.AWSMachine.Status.DedicatedHost == nil {
// scope.AWSMachine.Status.DedicatedHost = &infrav1.DedicatedHostStatus{}
//}
//// Update machine status with allocated host ID
//scope.AWSMachine.Status.DedicatedHost.ID = &hostID
// Dynamic host allocation is enabled, but implementation is currently not provided.

Copilot uses AI. Check for mistakes.

input.CapacityReservationPreference = scope.AWSMachine.Spec.CapacityReservationPreference

//input.CPUOptions = scope.AWSMachine.Spec.CPUOptions
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

Remove commented-out code for CPUOptions assignment. Since CPUOptions is defined in the API types, either implement the functionality or remove the comment.

Suggested change
//input.CPUOptions = scope.AWSMachine.Spec.CPUOptions

Copilot uses AI. Check for mistakes.
HostResourceGroupArn: aws.String("arn:aws:resource-groups:us-west-2:123456789012:group/test-group"),
},
},
wantErr: false,
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

Test case expects validation to pass when hostResourceGroupArn is specified without licenseConfigurationArns, but the validation logic at line 485-488 of awsmachine_webhook.go requires licenseConfigurationArns when hostResourceGroupArn is set. This test should expect wantErr: true.

Suggested change
wantErr: false,
wantErr: true,

Copilot uses AI. Check for mistakes.
@spectro-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AmitSahastra, snehala27
To complete the pull request process, please assign after the PR has been reviewed.
You can assign the PR to them by writing /assign in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants