-
Notifications
You must be signed in to change notification settings - Fork 35
feat(aws): add --vpc-id flag to deploy into existing VPCs #850
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -40,6 +40,7 @@ type rhelAIRequest struct { | |||||||||||||||||||
| spot bool | ||||||||||||||||||||
| timeout *string | ||||||||||||||||||||
| serviceEndpoints []string | ||||||||||||||||||||
| vpcID *string | ||||||||||||||||||||
| allocationData *allocation.AllocationResult | ||||||||||||||||||||
| diskSize *int | ||||||||||||||||||||
| model *string | ||||||||||||||||||||
|
|
@@ -81,6 +82,7 @@ func Create(mCtxArgs *mc.ContextArgs, args *apiRHELAI.RHELAIArgs) (err error) { | |||||||||||||||||||
| arch: &args.Arch, | ||||||||||||||||||||
| timeout: &args.Timeout, | ||||||||||||||||||||
| serviceEndpoints: args.ServiceEndpoints, | ||||||||||||||||||||
| vpcID: args.VpcID, | ||||||||||||||||||||
| diskSize: args.ComputeRequest.DiskSize, | ||||||||||||||||||||
| model: &args.Model, | ||||||||||||||||||||
| hfToken: &args.HFToken, | ||||||||||||||||||||
|
|
@@ -97,6 +99,7 @@ func Create(mCtxArgs *mc.ContextArgs, args *apiRHELAI.RHELAIArgs) (err error) { | |||||||||||||||||||
| ComputeRequest: args.ComputeRequest, | ||||||||||||||||||||
| AMIProductDescription: &amiProduct, | ||||||||||||||||||||
| Spot: args.Spot, | ||||||||||||||||||||
| VpcID: args.VpcID, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||
| return err | ||||||||||||||||||||
|
|
@@ -228,6 +231,7 @@ func (r *rhelAIRequest) deploy(ctx *pulumi.Context) error { | |||||||||||||||||||
| AZ: *r.allocationData.AZ, | ||||||||||||||||||||
| CreateLoadBalancer: r.allocationData.SpotPrice != nil, | ||||||||||||||||||||
| ServiceEndpoints: r.serviceEndpoints, | ||||||||||||||||||||
| VpcID: r.vpcID, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||
| return err | ||||||||||||||||||||
|
|
@@ -243,7 +247,7 @@ func (r *rhelAIRequest) deploy(ctx *pulumi.Context) error { | |||||||||||||||||||
| ctx.Export(fmt.Sprintf("%s-%s", *r.prefix, outputUserPrivateKey), | ||||||||||||||||||||
| keyResources.PrivateKey.PrivateKeyPem) | ||||||||||||||||||||
| // Security groups | ||||||||||||||||||||
| securityGroups, err := r.securityGroups(ctx, r.mCtx, nw.Vpc) | ||||||||||||||||||||
| securityGroups, err := r.securityGroups(ctx, r.mCtx, nw.Vpc, nw.IsPublic) | ||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||
| return err | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -265,7 +269,7 @@ func (r *rhelAIRequest) deploy(ctx *pulumi.Context) error { | |||||||||||||||||||
| LB: nw.LoadBalancer, | ||||||||||||||||||||
| Eip: nw.Eip, | ||||||||||||||||||||
| LBTargetGroups: r.lbTargetGroups()} | ||||||||||||||||||||
| if r.allocationData.SpotPrice != nil { | ||||||||||||||||||||
| if r.allocationData.SpotPrice != nil && nw.IsPublic { | ||||||||||||||||||||
| cr.Spot = true | ||||||||||||||||||||
| cr.SpotPrice = *r.allocationData.SpotPrice | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
@@ -289,6 +293,12 @@ func (r *rhelAIRequest) deploy(ctx *pulumi.Context) error { | |||||||||||||||||||
| return err | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if !nw.IsPublic { | ||||||||||||||||||||
| if r.autoStart { | ||||||||||||||||||||
| return fmt.Errorf("--auto-start requires SSH access to configure RHAIIS; private subnet deployments do not support --auto-start") | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return nil | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+296
to
+301
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Don’t report success when private RHEL AI cannot run auto-start setup. This returns before Proposed guard if !nw.IsPublic {
+ if r.autoStart {
+ return fmt.Errorf("auto-start is not supported in private subnets without SSH connectivity")
+ }
return nil
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| if !r.autoStart { | ||||||||||||||||||||
| return c.Readiness(ctx, command.CommandPing, *r.prefix, awsRHELDedicatedID, | ||||||||||||||||||||
| keyResources.PrivateKey, amiUserDefault, nil, c.Dependencies) | ||||||||||||||||||||
|
|
@@ -321,22 +331,22 @@ func (r *rhelAIRequest) manageResults(stackResult auto.UpResult) error { | |||||||||||||||||||
| return output.Write(stackResult, r.mCtx.GetResultsOutputPath(), results) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // security group for mac machine with ingress rules for ssh and vnc | ||||||||||||||||||||
| func (r *rhelAIRequest) securityGroups(ctx *pulumi.Context, mCtx *mc.Context, | ||||||||||||||||||||
| vpc *ec2.Vpc) (pulumi.StringArray, error) { | ||||||||||||||||||||
| // ingress for ssh access from 0.0.0.0 | ||||||||||||||||||||
| sshIngressRule := securityGroup.SSH_TCP | ||||||||||||||||||||
| sshIngressRule.CidrBlocks = infra.NETWORKING_CIDR_ANY_IPV4 | ||||||||||||||||||||
| ingressRules := []securityGroup.IngressRules{sshIngressRule} | ||||||||||||||||||||
| for _, port := range r.exposePorts { | ||||||||||||||||||||
| rule := securityGroup.IngressRules{ | ||||||||||||||||||||
| Description: fmt.Sprintf("port-%d", port), | ||||||||||||||||||||
| FromPort: port, | ||||||||||||||||||||
| ToPort: port, | ||||||||||||||||||||
| Protocol: "tcp", | ||||||||||||||||||||
| CidrBlocks: infra.NETWORKING_CIDR_ANY_IPV4, | ||||||||||||||||||||
| vpc *ec2.Vpc, public bool) (pulumi.StringArray, error) { | ||||||||||||||||||||
| var ingressRules []securityGroup.IngressRules | ||||||||||||||||||||
| if public { | ||||||||||||||||||||
| sshIngressRule := securityGroup.SSH_TCP | ||||||||||||||||||||
| sshIngressRule.CidrBlocks = infra.NETWORKING_CIDR_ANY_IPV4 | ||||||||||||||||||||
| ingressRules = []securityGroup.IngressRules{sshIngressRule} | ||||||||||||||||||||
| for _, port := range r.exposePorts { | ||||||||||||||||||||
| ingressRules = append(ingressRules, securityGroup.IngressRules{ | ||||||||||||||||||||
| Description: fmt.Sprintf("port-%d", port), | ||||||||||||||||||||
| FromPort: port, | ||||||||||||||||||||
| ToPort: port, | ||||||||||||||||||||
| Protocol: "tcp", | ||||||||||||||||||||
| CidrBlocks: infra.NETWORKING_CIDR_ANY_IPV4, | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| ingressRules = append(ingressRules, rule) | ||||||||||||||||||||
| } | ||||||||||||||||||||
| // Create SG with ingress rules | ||||||||||||||||||||
| sg, err := securityGroup.SGRequest{ | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Empty-string
--vpc-idtreated as “set”.viper.IsSetreturns true once the flag isChanged, even if the value is""(e.g.--vpc-id="$VPC_ID"with an unset env var in a CI script).NetworkVpcID()then returns a pointer to""instead ofnil, and downstream (NetworkArgs.VpcID != nil) will route intoexistingVPCNetworkand callec2.GetVpcwith an empty ID, failing deep in the Pulumi provider instead of failing fast with a clear message.🔧 Proposed fix
func NetworkVpcID() *string { - if viper.IsSet(VpcID) { - v := viper.GetString(VpcID) - return &v - } - return nil + if v := viper.GetString(VpcID); v != "" { + return &v + } + return nil }📝 Committable suggestion
🤖 Prompt for AI Agents