Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
318705fe
Commit
318705fe
authored
Feb 08, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20378 from…
Merge pull request #20378 from jtblin/jtblin/11543-aws-cloud-provider-private-hosted-dns-zone-via-api Auto commit by PR queue bot
parents
3b150b5e
0a36db19
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
aws.go
pkg/cloudprovider/providers/aws/aws.go
+6
-3
aws_test.go
pkg/cloudprovider/providers/aws/aws_test.go
+17
-3
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
318705fe
...
...
@@ -660,6 +660,7 @@ func (aws *AWSCloud) NodeAddresses(name string) ([]api.NodeAddress, error) {
}
return
[]
api
.
NodeAddress
{
{
Type
:
api
.
NodeInternalIP
,
Address
:
internalIP
},
{
Type
:
api
.
NodeLegacyHostIP
,
Address
:
internalIP
},
{
Type
:
api
.
NodeExternalIP
,
Address
:
externalIP
},
},
nil
}
...
...
@@ -1134,10 +1135,13 @@ func (s *AWSCloud) getSelfAWSInstance() (*awsInstance, error) {
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error fetching instance-id from ec2 metadata service: %v"
,
err
)
}
privateDnsName
,
err
:=
s
.
metadata
.
GetMetadata
(
"local-hostname"
)
// privateDnsName, err := s.metadata.GetMetadata("local-hostname")
// See #11543 - need to use ec2 API to get the privateDnsName in case of private dns zone e.g. mydomain.io
instance
,
err
:=
s
.
getInstanceByID
(
instanceId
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error f
etching local-hostname from ec2 metadata service: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"error f
inding instance %s: %v"
,
instanceId
,
err
)
}
privateDnsName
:=
aws
.
StringValue
(
instance
.
PrivateDnsName
)
availabilityZone
,
err
:=
getAvailabilityZone
(
s
.
metadata
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error fetching availability zone from ec2 metadata service: %v"
,
err
)
...
...
@@ -2183,7 +2187,6 @@ func (s *AWSCloud) UpdateLoadBalancer(name, region string, hosts []string) error
}
// Returns the instance with the specified ID
// This function is currently unused, but seems very likely to be needed again
func
(
a
*
AWSCloud
)
getInstanceByID
(
instanceID
string
)
(
*
ec2
.
Instance
,
error
)
{
instances
,
err
:=
a
.
getInstancesByIDs
([]
*
string
{
&
instanceID
})
if
err
!=
nil
{
...
...
pkg/cloudprovider/providers/aws/aws_test.go
View file @
318705fe
...
...
@@ -133,6 +133,8 @@ func NewFakeAWSServices() *FakeAWSServices {
s
.
instanceId
=
"i-self"
s
.
privateDnsName
=
"ip-172-20-0-100.ec2.internal"
s
.
internalIP
=
"192.168.0.1"
s
.
externalIP
=
"1.2.3.4"
var
selfInstance
ec2
.
Instance
selfInstance
.
InstanceId
=
&
s
.
instanceId
selfInstance
.
PrivateDnsName
=
&
s
.
privateDnsName
...
...
@@ -587,9 +589,10 @@ func TestNodeAddresses(t *testing.T) {
// (we test that this produces an error)
var
instance0
ec2
.
Instance
var
instance1
ec2
.
Instance
var
instance2
ec2
.
Instance
//0
instance0
.
InstanceId
=
aws
.
String
(
"i
nstance-same
"
)
instance0
.
InstanceId
=
aws
.
String
(
"i
-self
"
)
instance0
.
PrivateDnsName
=
aws
.
String
(
"instance-same.ec2.internal"
)
instance0
.
PrivateIpAddress
=
aws
.
String
(
"192.168.0.1"
)
instance0
.
PublicIpAddress
=
aws
.
String
(
"1.2.3.4"
)
...
...
@@ -600,7 +603,7 @@ func TestNodeAddresses(t *testing.T) {
instance0
.
State
=
&
state0
//1
instance1
.
InstanceId
=
aws
.
String
(
"i
nstance-same
"
)
instance1
.
InstanceId
=
aws
.
String
(
"i
-self
"
)
instance1
.
PrivateDnsName
=
aws
.
String
(
"instance-same.ec2.internal"
)
instance1
.
PrivateIpAddress
=
aws
.
String
(
"192.168.0.2"
)
instance1
.
InstanceType
=
aws
.
String
(
"c3.large"
)
...
...
@@ -609,7 +612,18 @@ func TestNodeAddresses(t *testing.T) {
}
instance1
.
State
=
&
state1
instances
:=
[]
*
ec2
.
Instance
{
&
instance0
,
&
instance1
}
//2
instance2
.
InstanceId
=
aws
.
String
(
"i-self"
)
instance2
.
PrivateDnsName
=
aws
.
String
(
"instance-other.ec2.internal"
)
instance2
.
PrivateIpAddress
=
aws
.
String
(
"192.168.0.1"
)
instance2
.
PublicIpAddress
=
aws
.
String
(
"1.2.3.4"
)
instance2
.
InstanceType
=
aws
.
String
(
"c3.large"
)
state2
:=
ec2
.
InstanceState
{
Name
:
aws
.
String
(
"running"
),
}
instance2
.
State
=
&
state2
instances
:=
[]
*
ec2
.
Instance
{
&
instance0
,
&
instance1
,
&
instance2
}
aws1
,
_
:=
mockInstancesResp
([]
*
ec2
.
Instance
{})
_
,
err1
:=
aws1
.
NodeAddresses
(
"instance-mismatch.ec2.internal"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment