-
Notifications
You must be signed in to change notification settings - Fork 319
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
OCPBUGS-44698: Create AWS clients on every reconcile instead of at initialization #5179
base: main
Are you sure you want to change the base?
Conversation
Moves client creation for the private link endpoint controller into the reconcile loop instead of when the reconciler is initially registered. This allows the controller to recover from initial issues assuming a shared vpc role. Adds additional error logging when AWS cloud API calls fail.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: csrwng The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@csrwng: This pull request references Jira Issue OCPBUGS-44698, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
No GitHub users were found matching the public email listed for the QA contact in Jira ([email protected]), skipping review request. The bug has been updated to refer to the pull request using the external bug tracker. In 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. |
@csrwng: The following test failed, say
Full PR test history. Your PR dashboard. 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 kubernetes-sigs/prow repository. I understand the commands that are listed here. |
GroupId: aws.String(sgID), | ||
IpPermissions: ingressPermissions, | ||
}); err != nil { | ||
log.Error(err, "failed to sect security group ingress rules", "id", sgID) |
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.
typo sect?
Why are we unconditionally logging here then right below we are logging again via
if supportawsutil.AWSErrorCode(err) != "InvalidPermission.Duplicate" {
return fmt.Errorf("failed to set security group ingress rules, code: %s", supportawsutil.AWSErrorCode(err))
}
log.Info("WARNING: got duplicate permissions error when setting security group ingress permissions", "sgID", sgID)
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.
typo sect?
yes
Will also fix the unconditional logging
@@ -756,14 +861,17 @@ func (r *AWSEndpointServiceReconciler) createSecurityGroup(ctx context.Context, | |||
describeSGInput := &ec2.DescribeSecurityGroupsInput{ | |||
GroupIds: []*string{aws.String(sgID)}, | |||
} | |||
if err = r.ec2Client.WaitUntilSecurityGroupExistsWithContext(ctx, describeSGInput); err != nil { | |||
if err = ec2Client.WaitUntilSecurityGroupExistsWithContext(ctx, describeSGInput); err != nil { | |||
log.Error(err, "failed to wait for security group to exist", "id", sgID) |
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.
why are we logging in addition to the returned error and with different message?
@@ -513,3 +488,7 @@ func NewStartCommand() *cobra.Command { | |||
|
|||
return cmd | |||
} | |||
|
|||
func isAWS() bool { | |||
return os.Getenv("AWS_REGION") != "" |
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.
Should this be:
func isAWSPrivate() bool {
return os.Getenv("AWS_REGION") != "" && hcp.Spec.Platform.Type == hyperv1.AWSPlatform
}
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.
We are no longer retrieving the hcp on startup, but we're always setting AWS_REGION on the CPO when platform.Type == AWS:
hypershift/hypershift-operator/controllers/hostedcluster/hostedcluster_controller.go
Lines 2739 to 2770 in a3791d6
switch hc.Spec.Platform.Type { | |
case hyperv1.AWSPlatform: | |
deployment.Spec.Template.Spec.Volumes = append(deployment.Spec.Template.Spec.Volumes, | |
corev1.Volume{ | |
Name: "cloud-token", | |
VolumeSource: corev1.VolumeSource{ | |
EmptyDir: &corev1.EmptyDirVolumeSource{ | |
Medium: corev1.StorageMediumMemory, | |
}, | |
}, | |
}, | |
corev1.Volume{ | |
Name: "provider-creds", | |
VolumeSource: corev1.VolumeSource{ | |
Secret: &corev1.SecretVolumeSource{ | |
SecretName: platformaws.ControlPlaneOperatorCredsSecret("").Name, | |
}, | |
}, | |
}) | |
deployment.Spec.Template.Spec.Containers[0].Env = append(deployment.Spec.Template.Spec.Containers[0].Env, | |
corev1.EnvVar{ | |
Name: "AWS_SHARED_CREDENTIALS_FILE", | |
Value: "/etc/provider/credentials", | |
}, | |
corev1.EnvVar{ | |
Name: "AWS_REGION", | |
Value: hc.Spec.Platform.AWS.Region, | |
}, | |
corev1.EnvVar{ | |
Name: "AWS_SDK_LOAD_CONFIG", | |
Value: "true", | |
}) |
So just retrieving the hcp on startup for the same check seemed unnecessary
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.
ah I see. Where I was actually trying to get is that I guess we should only run this if we are in aws private, i.e. should we check hcp.spec.EndpointAccess?
if err != nil { | ||
return nil, nil, err | ||
} | ||
if b.assumeEndpointRoleARN != "" { |
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.
nit:
// When sharedVPC we need assume these additional roles
?
type clientBuilder struct { | ||
mu sync.Mutex | ||
initialized bool | ||
assumeEndpointRoleARN string |
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.
assumeSharedVPCEndpointRoleARN
assumeSharedVPCRoute53RoleARN
?
b.mu.Lock() | ||
defer b.mu.Unlock() | ||
|
||
if !b.initialized { |
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.
would it make any difference if this func is just
b.warnOnDifferentValues(log, hcp)
b.setFromHCP(hcp)
b.initialized = true
without the conditional?
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.
we'd warn unnecessarily when initially setting the values
What this PR does / why we need it:
Moves client creation for the private link endpoint controller into the reconcile loop instead of when the reconciler is initially registered. This allows the controller to recover from initial issues assuming a shared vpc role.
Adds additional error logging when AWS cloud API calls fail.
Which issue(s) this PR fixes (optional, use
fixes #<issue_number>(, fixes #<issue_number>, ...)
format, where issue_number might be a GitHub issue, or a Jira story:Fixes #OCPBUGS-44698
Checklist