Skip to content
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

Add support for custom endpoints #327

Merged
merged 2 commits into from
Jul 29, 2020
Merged

Add support for custom endpoints #327

merged 2 commits into from
Jul 29, 2020

Conversation

alexander-demicev
Copy link

This PR adds support for custom endpoints, in order to do so we need to:

  1. Fetch infrastructure object
  2. Check if it contains custom endpoints in platform spec
  3. Create custom endpoint resolver and use with AWS client

https://docs.aws.amazon.com/sdk-for-go/v2/api/aws/endpoints/
https://github.com/openshift/enhancements/pull/163/files
https://github.com/openshift/installer/pull/3277/files

@alexander-demicev
Copy link
Author

/hold
I haven't tested the PR yet

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 3, 2020
Copy link

@Danil-Grigorev Danil-Grigorev left a comment

Choose a reason for hiding this comment

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

/approve

return nil
}

customEndpointsMap := buildCustomEndpointsMap(infra.Spec.PlatformSpec.AWS.ServiceEndpoints)

Choose a reason for hiding this comment

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

Use the status and not the spec for these values.

Copy link
Member

Choose a reason for hiding this comment

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

cc @alexander-demichev can we please address this?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 27, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Danil-Grigorev

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 27, 2020
@@ -44,6 +46,8 @@ const (
AwsCredsSecretIDKey = "aws_access_key_id"
// AwsCredsSecretAccessKey is secret key containing AWS Secret Key
AwsCredsSecretAccessKey = "aws_secret_access_key"

globalInfrastuctureName = "cluster"
Copy link
Member

Choose a reason for hiding this comment

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

can you reference where this magic "cluster" is coming from so others have context? i.e the line of code in the installer where this is instantiated

Copy link
Author

Choose a reason for hiding this comment

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

👍

Choose a reason for hiding this comment

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

return nil
}

customEndpointsMap := buildCustomEndpointsMap(infra.Status.PlatformStatus.AWS.ServiceEndpoints)
Copy link
Member

Choose a reason for hiding this comment

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

this would panic if either PlatformStatus or PlatformStatus.AWS are nil?

Copy link
Author

Choose a reason for hiding this comment

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

we have a check on lines 227-229

Copy link
Member

@enxebre enxebre Jul 27, 2020

Choose a reason for hiding this comment

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

as far as I can see that's checking infra.Spec.PlatformSpec.AWS. That won't prevent this line from panicking.
I think the check above should include all the pointers that can be nil that being dereferenced here infra.Status.PlatformStatus !=nil, infra.Status.PlatformStatus.AWS != nil

Copy link
Author

Choose a reason for hiding this comment

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

PlatformSpec is not a pointer here, it can't be nil

Copy link
Member

@enxebre enxebre Jul 27, 2020

Choose a reason for hiding this comment

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

PlatformStatus is a pointer, PlatformStatus.AWS is another pointer.
You are dereferencing them without checking they are nil.
If for any reason they are nil this code will panic.
am I missing anything?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, you are right. I was looking at PlatformSpec :) I pushed a fix for that.

Comment on lines 227 to 230
// Do nothing when custom endpoints are missing
if infra.Status.PlatformStatus == nil && infra.Status.PlatformStatus.AWS == nil {
return nil
}

Choose a reason for hiding this comment

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

should this be OR ?

return nil
}

func buildCustomEndpointsMap(customEndpoints []configv1.AWSServiceEndpoint) map[string]string {

Choose a reason for hiding this comment

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

nit: add comment that explains the key values of the returned map.

@enxebre
Copy link
Member

enxebre commented Jul 28, 2020

PTAL @abhinavdahiya for the final lgtm

Copy link

@abhinavdahiya abhinavdahiya left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 28, 2020
@enxebre
Copy link
Member

enxebre commented Jul 28, 2020

/retest

@enxebre
Copy link
Member

enxebre commented Jul 29, 2020

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 29, 2020
@openshift-merge-robot openshift-merge-robot merged commit 2f581a5 into openshift:master Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants