Skip to content

Commit 199df64

Browse files
Merge pull request #9676 from tthvo/OCPBUGS-55324
OCPBUGS-55324: fix nil field access when describing security groups
2 parents 08aa270 + dfacd3d commit 199df64

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/asset/installconfig/aws/validation.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ func validatePublicIpv4Pool(ctx context.Context, meta *Metadata, fldPath *field.
203203

204204
sess, err := meta.Session(ctx)
205205
if err != nil {
206-
return append(allErrs, field.Invalid(fldPath, nil, fmt.Sprintf("unable to start a session: %s", err.Error())))
206+
return append(allErrs, field.InternalError(fldPath, fmt.Errorf("unable to retrieve aws session: %w", err)))
207207
}
208+
208209
publicIpv4Pool, err := DescribePublicIpv4Pool(ctx, sess, config.Platform.AWS.Region, poolID)
209210
if err != nil {
210211
return append(allErrs, field.Invalid(fldPath, poolID, err.Error()))
@@ -493,7 +494,12 @@ func validateSecurityGroupIDs(ctx context.Context, meta *Metadata, fldPath *fiel
493494
return append(allErrs, field.Invalid(fldPath, vpc, errMsg))
494495
}
495496

496-
securityGroups, err := DescribeSecurityGroups(ctx, meta.session, pool.AdditionalSecurityGroupIDs, platform.Region)
497+
session, err := meta.Session(ctx)
498+
if err != nil {
499+
return append(allErrs, field.InternalError(fldPath, fmt.Errorf("unable to retrieve aws session: %w", err)))
500+
}
501+
502+
securityGroups, err := DescribeSecurityGroups(ctx, session, pool.AdditionalSecurityGroupIDs, platform.Region)
497503
if err != nil {
498504
return append(allErrs, field.Invalid(fldPath, pool.AdditionalSecurityGroupIDs, err.Error()))
499505
}
@@ -773,7 +779,7 @@ func validateServiceEndpoints(fldPath *field.Path, region string, services []aws
773779
func validateZoneLocal(ctx context.Context, meta *Metadata, fldPath *field.Path, zoneName string) *field.Error {
774780
sess, err := meta.Session(ctx)
775781
if err != nil {
776-
return field.Invalid(fldPath, zoneName, fmt.Sprintf("unable to start a session: %s", err.Error()))
782+
return field.Invalid(fldPath, zoneName, fmt.Sprintf("unable to retrieve aws session: %s", err.Error()))
777783
}
778784
zones, err := describeFilteredZones(ctx, sess, meta.Region, []string{zoneName})
779785
if err != nil {
@@ -904,7 +910,7 @@ func isHostedZoneAssociatedWithVPC(hostedZone *route53.GetHostedZoneOutput, vpcI
904910
func validateInstanceProfile(ctx context.Context, meta *Metadata, fldPath *field.Path, pool *awstypes.MachinePool) *field.Error {
905911
session, err := meta.Session(ctx)
906912
if err != nil {
907-
return field.InternalError(fldPath, fmt.Errorf("unable to start a session: %w", err))
913+
return field.InternalError(fldPath, fmt.Errorf("unable to retrieve aws session: %w", err))
908914
}
909915
client := iam.New(session)
910916
res, err := client.GetInstanceProfileWithContext(ctx, &iam.GetInstanceProfileInput{

0 commit comments

Comments
 (0)