Merge pull request #85875 from yutedz/gce-ctx-timeout-inst

Utilize Context with timeout in gce_instances.go
This commit is contained in:
Kubernetes Prow Robot 2019-12-04 12:11:14 -08:00 committed by GitHub
commit de63e573ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,7 +111,7 @@ func (g *Cloud) NodeAddresses(_ context.Context, _ types.NodeName) ([]v1.NodeAdd
// NodeAddressesByProviderID will not be called from the node that is requesting this ID.
// i.e. metadata service and other local methods cannot be used here
func (g *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID string) ([]v1.NodeAddress, error) {
timeoutCtx, cancel := cloud.ContextWithCallTimeout()
timeoutCtx, cancel := context.WithTimeout(ctx, 1*time.Hour)
defer cancel()
_, zone, name, err := splitProviderID(providerID)
@ -229,7 +229,7 @@ func (g *Cloud) InstanceType(ctx context.Context, nodeName types.NodeName) (stri
// AddSSHKeyToAllInstances adds an SSH public key as a legal identity for all instances
// expected format for the key is standard ssh-keygen format: <protocol> <blob>
func (g *Cloud) AddSSHKeyToAllInstances(ctx context.Context, user string, keyData []byte) error {
ctx, cancel := cloud.ContextWithCallTimeout()
ctx, cancel := context.WithTimeout(ctx, 1*time.Hour)
defer cancel()
return wait.Poll(2*time.Second, 30*time.Second, func() (bool, error) {