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
63841dad
Commit
63841dad
authored
May 04, 2017
by
Nick Sardo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
missed a file
parent
48d58a15
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
26 deletions
+15
-26
gce_disks.go
pkg/cloudprovider/providers/gce/gce_disks.go
+1
-1
gce_firewall.go
pkg/cloudprovider/providers/gce/gce_firewall.go
+1
-6
gce_instancegroup.go
pkg/cloudprovider/providers/gce/gce_instancegroup.go
+10
-17
gce_instances.go
pkg/cloudprovider/providers/gce/gce_instances.go
+3
-2
No files found.
pkg/cloudprovider/providers/gce/gce_disks.go
View file @
63841dad
...
...
@@ -328,7 +328,7 @@ func (gce *GCECloud) findDiskByName(diskName string, zone string) (*GCEDisk, err
Kind
:
disk
.
Kind
,
Type
:
disk
.
Type
,
}
return
d
,
mc
.
Observe
(
err
)
return
d
,
mc
.
Observe
(
nil
)
}
if
!
isHTTPErrorCode
(
err
,
http
.
StatusNotFound
)
{
return
nil
,
mc
.
Observe
(
err
)
...
...
pkg/cloudprovider/providers/gce/gce_firewall.go
View file @
63841dad
...
...
@@ -34,12 +34,7 @@ func newFirewallMetricContext(request string, region string) *metricContext {
// GetFirewall returns the Firewall by name.
func
(
gce
*
GCECloud
)
GetFirewall
(
name
string
)
(
*
compute
.
Firewall
,
error
)
{
region
,
err
:=
GetGCERegion
(
gce
.
localZone
)
if
err
!=
nil
{
return
nil
,
err
}
mc
:=
newFirewallMetricContext
(
"get"
,
region
)
mc
:=
newFirewallMetricContext
(
"get"
,
""
)
v
,
err
:=
gce
.
service
.
Firewalls
.
Get
(
gce
.
projectID
,
name
)
.
Do
()
return
v
,
mc
.
Observe
(
err
)
}
...
...
pkg/cloudprovider/providers/gce/gce_instancegroup.go
View file @
63841dad
...
...
@@ -40,7 +40,6 @@ func (gce *GCECloud) CreateInstanceGroup(name string, zone string) (*compute.Ins
op
,
err
:=
gce
.
service
.
InstanceGroups
.
Insert
(
gce
.
projectID
,
zone
,
&
compute
.
InstanceGroup
{
Name
:
name
})
.
Do
()
if
err
!=
nil
{
mc
.
Observe
(
err
)
return
nil
,
err
...
...
@@ -59,7 +58,6 @@ func (gce *GCECloud) DeleteInstanceGroup(name string, zone string) error {
op
,
err
:=
gce
.
service
.
InstanceGroups
.
Delete
(
gce
.
projectID
,
zone
,
name
)
.
Do
()
if
err
!=
nil
{
mc
.
Observe
(
err
)
return
err
...
...
@@ -70,31 +68,28 @@ func (gce *GCECloud) DeleteInstanceGroup(name string, zone string) error {
// ListInstanceGroups lists all InstanceGroups in the project and
// zone.
func
(
gce
*
GCECloud
)
ListInstanceGroups
(
zone
string
)
(
v
*
compute
.
InstanceGroupList
,
err
error
)
{
func
(
gce
*
GCECloud
)
ListInstanceGroups
(
zone
string
)
(
*
compute
.
InstanceGroupList
,
error
)
{
mc
:=
newInstanceGroupMetricContext
(
"list"
,
zone
)
defer
mc
.
Observe
(
err
)
// TODO: use PageToken to list all not just the first 500
v
,
err
=
gce
.
service
.
InstanceGroups
.
List
(
gce
.
projectID
,
zone
)
.
Do
()
return
v
,
err
:
=
gce
.
service
.
InstanceGroups
.
List
(
gce
.
projectID
,
zone
)
.
Do
()
return
v
,
mc
.
Observe
(
err
)
}
// ListInstancesInInstanceGroup lists all the instances in a given
// instance group and state.
func
(
gce
*
GCECloud
)
ListInstancesInInstanceGroup
(
name
string
,
zone
string
,
state
string
)
(
v
*
compute
.
InstanceGroupsListInstances
,
err
error
)
{
func
(
gce
*
GCECloud
)
ListInstancesInInstanceGroup
(
name
string
,
zone
string
,
state
string
)
(
*
compute
.
InstanceGroupsListInstances
,
error
)
{
mc
:=
newInstanceGroupMetricContext
(
"list_instances"
,
zone
)
defer
mc
.
Observe
(
err
)
// TODO: use PageToken to list all not just the first 500
v
,
err
=
gce
.
service
.
InstanceGroups
.
ListInstances
(
v
,
err
:
=
gce
.
service
.
InstanceGroups
.
ListInstances
(
gce
.
projectID
,
zone
,
name
,
&
compute
.
InstanceGroupsListInstancesRequest
{
InstanceState
:
state
})
.
Do
()
return
return
v
,
mc
.
Observe
(
err
)
}
// AddInstancesToInstanceGroup adds the given instances to the given
// instance group.
func
(
gce
*
GCECloud
)
AddInstancesToInstanceGroup
(
name
string
,
zone
string
,
instanceNames
[]
string
)
error
{
mc
:=
newInstanceGroupMetricContext
(
"add_instances"
,
zone
)
if
len
(
instanceNames
)
==
0
{
return
nil
}
...
...
@@ -121,10 +116,10 @@ func (gce *GCECloud) AddInstancesToInstanceGroup(name string, zone string, insta
// the instance group.
func
(
gce
*
GCECloud
)
RemoveInstancesFromInstanceGroup
(
name
string
,
zone
string
,
instanceNames
[]
string
)
error
{
mc
:=
newInstanceGroupMetricContext
(
"remove_instances"
,
zone
)
if
len
(
instanceNames
)
==
0
{
return
nil
}
instances
:=
[]
*
compute
.
InstanceReference
{}
for
_
,
ins
:=
range
instanceNames
{
instanceLink
:=
makeHostURL
(
gce
.
projectID
,
zone
,
ins
)
...
...
@@ -152,7 +147,6 @@ func (gce *GCECloud) RemoveInstancesFromInstanceGroup(name string, zone string,
// AddPortToInstanceGroup adds a port to the given instance group.
func
(
gce
*
GCECloud
)
AddPortToInstanceGroup
(
ig
*
compute
.
InstanceGroup
,
port
int64
)
(
*
compute
.
NamedPort
,
error
)
{
mc
:=
newInstanceGroupMetricContext
(
"add_port"
,
ig
.
Zone
)
for
_
,
np
:=
range
ig
.
NamedPorts
{
if
np
.
Port
==
port
{
glog
.
V
(
3
)
.
Infof
(
"Instance group %v already has named port %+v"
,
ig
.
Name
,
np
)
...
...
@@ -188,9 +182,8 @@ func (gce *GCECloud) AddPortToInstanceGroup(ig *compute.InstanceGroup, port int6
}
// GetInstanceGroup returns an instance group by name.
func
(
gce
*
GCECloud
)
GetInstanceGroup
(
name
string
,
zone
string
)
(
v
*
compute
.
InstanceGroup
,
err
error
)
{
func
(
gce
*
GCECloud
)
GetInstanceGroup
(
name
string
,
zone
string
)
(
*
compute
.
InstanceGroup
,
error
)
{
mc
:=
newInstanceGroupMetricContext
(
"get"
,
zone
)
defer
mc
.
Observe
(
err
)
v
,
err
=
gce
.
service
.
InstanceGroups
.
Get
(
gce
.
projectID
,
zone
,
name
)
.
Do
()
return
v
,
err
:=
gce
.
service
.
InstanceGroups
.
Get
(
gce
.
projectID
,
zone
,
name
)
.
Do
()
return
v
,
mc
.
Observe
(
err
)
}
pkg/cloudprovider/providers/gce/gce_instances.go
View file @
63841dad
...
...
@@ -197,7 +197,7 @@ func (gce *GCECloud) GetAllZones() (sets.String, error) {
// TODO: Parallelize, although O(zones) so not too bad (N <= 3 typically)
for
_
,
zone
:=
range
gce
.
managedZones
{
mc
:=
newInstancesMetricContext
(
"list
_zone
"
,
zone
)
mc
:=
newInstancesMetricContext
(
"list"
,
zone
)
// We only retrieve one page in each zone - we only care about existence
listCall
:=
gce
.
service
.
Instances
.
List
(
gce
.
projectID
,
zone
)
...
...
@@ -214,11 +214,12 @@ func (gce *GCECloud) GetAllZones() (sets.String, error) {
// Just a minimal set of fields - we only care about existence
listCall
=
listCall
.
Fields
(
"items(name)"
)
res
,
err
:=
listCall
.
Do
()
if
err
!=
nil
{
return
nil
,
mc
.
Observe
(
err
)
}
mc
.
Observe
(
nil
)
if
len
(
res
.
Items
)
!=
0
{
zones
.
Insert
(
zone
)
}
...
...
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