mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
missed a file
This commit is contained in:
parent
48d58a15ec
commit
63841dadb1
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user