mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Update Healthcheck to use generated code
This commit is contained in:
parent
48ad2eed8e
commit
f83c5379dc
@ -17,13 +17,18 @@ limitations under the License.
|
|||||||
package gce
|
package gce
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/core/v1"
|
"context"
|
||||||
"k8s.io/kubernetes/pkg/master/ports"
|
|
||||||
utilversion "k8s.io/kubernetes/pkg/util/version"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
computealpha "google.golang.org/api/compute/v0.alpha"
|
computealpha "google.golang.org/api/compute/v0.alpha"
|
||||||
compute "google.golang.org/api/compute/v1"
|
compute "google.golang.org/api/compute/v1"
|
||||||
|
|
||||||
|
"k8s.io/api/core/v1"
|
||||||
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/filter"
|
||||||
|
"k8s.io/kubernetes/pkg/cloudprovider/providers/gce/cloud/meta"
|
||||||
|
"k8s.io/kubernetes/pkg/master/ports"
|
||||||
|
utilversion "k8s.io/kubernetes/pkg/util/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -54,48 +59,32 @@ func newHealthcheckMetricContextWithVersion(request, version string) *metricCont
|
|||||||
// GetHttpHealthCheck returns the given HttpHealthCheck by name.
|
// GetHttpHealthCheck returns the given HttpHealthCheck by name.
|
||||||
func (gce *GCECloud) GetHttpHealthCheck(name string) (*compute.HttpHealthCheck, error) {
|
func (gce *GCECloud) GetHttpHealthCheck(name string) (*compute.HttpHealthCheck, error) {
|
||||||
mc := newHealthcheckMetricContext("get_legacy")
|
mc := newHealthcheckMetricContext("get_legacy")
|
||||||
v, err := gce.service.HttpHealthChecks.Get(gce.projectID, name).Do()
|
v, err := gce.c.HttpHealthChecks().Get(context.Background(), meta.GlobalKey(name))
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateHttpHealthCheck applies the given HttpHealthCheck as an update.
|
// UpdateHttpHealthCheck applies the given HttpHealthCheck as an update.
|
||||||
func (gce *GCECloud) UpdateHttpHealthCheck(hc *compute.HttpHealthCheck) error {
|
func (gce *GCECloud) UpdateHttpHealthCheck(hc *compute.HttpHealthCheck) error {
|
||||||
mc := newHealthcheckMetricContext("update_legacy")
|
mc := newHealthcheckMetricContext("update_legacy")
|
||||||
op, err := gce.service.HttpHealthChecks.Update(gce.projectID, hc.Name, hc).Do()
|
return mc.Observe(gce.c.HttpHealthChecks().Update(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteHttpHealthCheck deletes the given HttpHealthCheck by name.
|
// DeleteHttpHealthCheck deletes the given HttpHealthCheck by name.
|
||||||
func (gce *GCECloud) DeleteHttpHealthCheck(name string) error {
|
func (gce *GCECloud) DeleteHttpHealthCheck(name string) error {
|
||||||
mc := newHealthcheckMetricContext("delete_legacy")
|
mc := newHealthcheckMetricContext("delete_legacy")
|
||||||
op, err := gce.service.HttpHealthChecks.Delete(gce.projectID, name).Do()
|
return mc.Observe(gce.c.HttpHealthChecks().Delete(context.Background(), meta.GlobalKey(name)))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateHttpHealthCheck creates the given HttpHealthCheck.
|
// CreateHttpHealthCheck creates the given HttpHealthCheck.
|
||||||
func (gce *GCECloud) CreateHttpHealthCheck(hc *compute.HttpHealthCheck) error {
|
func (gce *GCECloud) CreateHttpHealthCheck(hc *compute.HttpHealthCheck) error {
|
||||||
mc := newHealthcheckMetricContext("create_legacy")
|
mc := newHealthcheckMetricContext("create_legacy")
|
||||||
op, err := gce.service.HttpHealthChecks.Insert(gce.projectID, hc).Do()
|
return mc.Observe(gce.c.HttpHealthChecks().Insert(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListHttpHealthChecks lists all HttpHealthChecks in the project.
|
// ListHttpHealthChecks lists all HttpHealthChecks in the project.
|
||||||
func (gce *GCECloud) ListHttpHealthChecks() (*compute.HttpHealthCheckList, error) {
|
func (gce *GCECloud) ListHttpHealthChecks() ([]*compute.HttpHealthCheck, error) {
|
||||||
mc := newHealthcheckMetricContext("list_legacy")
|
mc := newHealthcheckMetricContext("list_legacy")
|
||||||
// TODO: use PageToken to list all not just the first 500
|
v, err := gce.c.HttpHealthChecks().List(context.Background(), filter.None)
|
||||||
v, err := gce.service.HttpHealthChecks.List(gce.projectID).Do()
|
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,50 +93,32 @@ func (gce *GCECloud) ListHttpHealthChecks() (*compute.HttpHealthCheckList, error
|
|||||||
// GetHttpsHealthCheck returns the given HttpsHealthCheck by name.
|
// GetHttpsHealthCheck returns the given HttpsHealthCheck by name.
|
||||||
func (gce *GCECloud) GetHttpsHealthCheck(name string) (*compute.HttpsHealthCheck, error) {
|
func (gce *GCECloud) GetHttpsHealthCheck(name string) (*compute.HttpsHealthCheck, error) {
|
||||||
mc := newHealthcheckMetricContext("get_legacy")
|
mc := newHealthcheckMetricContext("get_legacy")
|
||||||
v, err := gce.service.HttpsHealthChecks.Get(gce.projectID, name).Do()
|
v, err := gce.c.HttpsHealthChecks().Get(context.Background(), meta.GlobalKey(name))
|
||||||
mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
return v, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateHttpsHealthCheck applies the given HttpsHealthCheck as an update.
|
// UpdateHttpsHealthCheck applies the given HttpsHealthCheck as an update.
|
||||||
func (gce *GCECloud) UpdateHttpsHealthCheck(hc *compute.HttpsHealthCheck) error {
|
func (gce *GCECloud) UpdateHttpsHealthCheck(hc *compute.HttpsHealthCheck) error {
|
||||||
mc := newHealthcheckMetricContext("update_legacy")
|
mc := newHealthcheckMetricContext("update_legacy")
|
||||||
op, err := gce.service.HttpsHealthChecks.Update(gce.projectID, hc.Name, hc).Do()
|
return mc.Observe(gce.c.HttpsHealthChecks().Update(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
mc.Observe(err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteHttpsHealthCheck deletes the given HttpsHealthCheck by name.
|
// DeleteHttpsHealthCheck deletes the given HttpsHealthCheck by name.
|
||||||
func (gce *GCECloud) DeleteHttpsHealthCheck(name string) error {
|
func (gce *GCECloud) DeleteHttpsHealthCheck(name string) error {
|
||||||
mc := newHealthcheckMetricContext("delete_legacy")
|
mc := newHealthcheckMetricContext("delete_legacy")
|
||||||
op, err := gce.service.HttpsHealthChecks.Delete(gce.projectID, name).Do()
|
return mc.Observe(gce.c.HttpsHealthChecks().Delete(context.Background(), meta.GlobalKey(name)))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateHttpsHealthCheck creates the given HttpsHealthCheck.
|
// CreateHttpsHealthCheck creates the given HttpsHealthCheck.
|
||||||
func (gce *GCECloud) CreateHttpsHealthCheck(hc *compute.HttpsHealthCheck) error {
|
func (gce *GCECloud) CreateHttpsHealthCheck(hc *compute.HttpsHealthCheck) error {
|
||||||
mc := newHealthcheckMetricContext("create_legacy")
|
mc := newHealthcheckMetricContext("create_legacy")
|
||||||
op, err := gce.service.HttpsHealthChecks.Insert(gce.projectID, hc).Do()
|
return mc.Observe(gce.c.HttpsHealthChecks().Insert(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListHttpsHealthChecks lists all HttpsHealthChecks in the project.
|
// ListHttpsHealthChecks lists all HttpsHealthChecks in the project.
|
||||||
func (gce *GCECloud) ListHttpsHealthChecks() (*compute.HttpsHealthCheckList, error) {
|
func (gce *GCECloud) ListHttpsHealthChecks() ([]*compute.HttpsHealthCheck, error) {
|
||||||
mc := newHealthcheckMetricContext("list_legacy")
|
mc := newHealthcheckMetricContext("list_legacy")
|
||||||
// TODO: use PageToken to list all not just the first 500
|
v, err := gce.c.HttpsHealthChecks().List(context.Background(), filter.None)
|
||||||
v, err := gce.service.HttpsHealthChecks.List(gce.projectID).Do()
|
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,77 +127,51 @@ func (gce *GCECloud) ListHttpsHealthChecks() (*compute.HttpsHealthCheckList, err
|
|||||||
// GetHealthCheck returns the given HealthCheck by name.
|
// GetHealthCheck returns the given HealthCheck by name.
|
||||||
func (gce *GCECloud) GetHealthCheck(name string) (*compute.HealthCheck, error) {
|
func (gce *GCECloud) GetHealthCheck(name string) (*compute.HealthCheck, error) {
|
||||||
mc := newHealthcheckMetricContext("get")
|
mc := newHealthcheckMetricContext("get")
|
||||||
v, err := gce.service.HealthChecks.Get(gce.projectID, name).Do()
|
v, err := gce.c.HealthChecks().Get(context.Background(), meta.GlobalKey(name))
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAlphaHealthCheck returns the given alpha HealthCheck by name.
|
// GetAlphaHealthCheck returns the given alpha HealthCheck by name.
|
||||||
func (gce *GCECloud) GetAlphaHealthCheck(name string) (*computealpha.HealthCheck, error) {
|
func (gce *GCECloud) GetAlphaHealthCheck(name string) (*computealpha.HealthCheck, error) {
|
||||||
mc := newHealthcheckMetricContextWithVersion("get", computeAlphaVersion)
|
mc := newHealthcheckMetricContextWithVersion("get", computeAlphaVersion)
|
||||||
v, err := gce.serviceAlpha.HealthChecks.Get(gce.projectID, name).Do()
|
v, err := gce.c.AlphaHealthChecks().Get(context.Background(), meta.GlobalKey(name))
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateHealthCheck applies the given HealthCheck as an update.
|
// UpdateHealthCheck applies the given HealthCheck as an update.
|
||||||
func (gce *GCECloud) UpdateHealthCheck(hc *compute.HealthCheck) error {
|
func (gce *GCECloud) UpdateHealthCheck(hc *compute.HealthCheck) error {
|
||||||
mc := newHealthcheckMetricContext("update")
|
mc := newHealthcheckMetricContext("update")
|
||||||
op, err := gce.service.HealthChecks.Update(gce.projectID, hc.Name, hc).Do()
|
return mc.Observe(gce.c.HealthChecks().Update(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateAlphaHealthCheck applies the given alpha HealthCheck as an update.
|
// UpdateAlphaHealthCheck applies the given alpha HealthCheck as an update.
|
||||||
func (gce *GCECloud) UpdateAlphaHealthCheck(hc *computealpha.HealthCheck) error {
|
func (gce *GCECloud) UpdateAlphaHealthCheck(hc *computealpha.HealthCheck) error {
|
||||||
mc := newHealthcheckMetricContextWithVersion("update", computeAlphaVersion)
|
mc := newHealthcheckMetricContextWithVersion("update", computeAlphaVersion)
|
||||||
op, err := gce.serviceAlpha.HealthChecks.Update(gce.projectID, hc.Name, hc).Do()
|
return mc.Observe(gce.c.AlphaHealthChecks().Update(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteHealthCheck deletes the given HealthCheck by name.
|
// DeleteHealthCheck deletes the given HealthCheck by name.
|
||||||
func (gce *GCECloud) DeleteHealthCheck(name string) error {
|
func (gce *GCECloud) DeleteHealthCheck(name string) error {
|
||||||
mc := newHealthcheckMetricContext("delete")
|
mc := newHealthcheckMetricContext("delete")
|
||||||
op, err := gce.service.HealthChecks.Delete(gce.projectID, name).Do()
|
return mc.Observe(gce.c.HealthChecks().Delete(context.Background(), meta.GlobalKey(name)))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateHealthCheck creates the given HealthCheck.
|
// CreateHealthCheck creates the given HealthCheck.
|
||||||
func (gce *GCECloud) CreateHealthCheck(hc *compute.HealthCheck) error {
|
func (gce *GCECloud) CreateHealthCheck(hc *compute.HealthCheck) error {
|
||||||
mc := newHealthcheckMetricContext("create")
|
mc := newHealthcheckMetricContext("create")
|
||||||
op, err := gce.service.HealthChecks.Insert(gce.projectID, hc).Do()
|
return mc.Observe(gce.c.HealthChecks().Insert(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateAlphaHealthCheck creates the given alpha HealthCheck.
|
// CreateAlphaHealthCheck creates the given alpha HealthCheck.
|
||||||
func (gce *GCECloud) CreateAlphaHealthCheck(hc *computealpha.HealthCheck) error {
|
func (gce *GCECloud) CreateAlphaHealthCheck(hc *computealpha.HealthCheck) error {
|
||||||
mc := newHealthcheckMetricContextWithVersion("create", computeAlphaVersion)
|
mc := newHealthcheckMetricContextWithVersion("create", computeAlphaVersion)
|
||||||
op, err := gce.serviceAlpha.HealthChecks.Insert(gce.projectID, hc).Do()
|
return mc.Observe(gce.c.AlphaHealthChecks().Insert(context.Background(), meta.GlobalKey(hc.Name), hc))
|
||||||
if err != nil {
|
|
||||||
return mc.Observe(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return gce.waitForGlobalOp(op, mc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListHealthChecks lists all HealthCheck in the project.
|
// ListHealthChecks lists all HealthCheck in the project.
|
||||||
func (gce *GCECloud) ListHealthChecks() (*compute.HealthCheckList, error) {
|
func (gce *GCECloud) ListHealthChecks() ([]*compute.HealthCheck, error) {
|
||||||
mc := newHealthcheckMetricContext("list")
|
mc := newHealthcheckMetricContext("list")
|
||||||
// TODO: use PageToken to list all not just the first 500
|
v, err := gce.c.HealthChecks().List(context.Background(), filter.None)
|
||||||
v, err := gce.service.HealthChecks.List(gce.projectID).Do()
|
|
||||||
return v, mc.Observe(err)
|
return v, mc.Observe(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user