Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor project in node.spec.providerID #779

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions providers/gce/gce_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ func (g *Cloud) NodeAddressesByProviderID(ctx context.Context, providerID string
timeoutCtx, cancel := context.WithTimeout(ctx, 1*time.Hour)
defer cancel()

_, zone, name, err := splitProviderID(providerID)
project, zone, name, err := splitProviderID(providerID)
if err != nil {
return []v1.NodeAddress{}, err
}

instance, err := g.c.Instances().Get(timeoutCtx, meta.ZonalKey(canonicalizeInstanceName(name), zone))
instance, err := g.c.Instances().Get(timeoutCtx, meta.ZonalKey(canonicalizeInstanceName(name), zone), cloud.ForceProjectID(project))
if err != nil {
return []v1.NodeAddress{}, fmt.Errorf("error while querying for providerID %q: %v", providerID, err)
}
Expand Down Expand Up @@ -365,7 +365,7 @@ func (g *Cloud) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprov
}
}

_, zone, name, err := splitProviderID(providerID)
project, zone, name, err := splitProviderID(providerID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is cross project communication here a potential escalation path? Does this possibility exist elsewhere already, or is this the first place this is being added?

if err != nil {
return nil, err
}
Expand All @@ -377,7 +377,7 @@ func (g *Cloud) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprov

var addresses []v1.NodeAddress
var instanceType string
instance, err := g.c.Instances().Get(timeoutCtx, meta.ZonalKey(canonicalizeInstanceName(name), zone))
instance, err := g.c.Instances().Get(timeoutCtx, meta.ZonalKey(canonicalizeInstanceName(name), zone), cloud.ForceProjectID(project))
if err != nil {
return nil, fmt.Errorf("error while querying for providerID %q: %v", providerID, err)
}
Expand Down Expand Up @@ -578,13 +578,13 @@ func (g *Cloud) AliasRangesByProviderID(providerID string) (cidrs []string, err
ctx, cancel := cloud.ContextWithCallTimeout()
defer cancel()

_, zone, name, err := splitProviderID(providerID)
project, zone, name, err := splitProviderID(providerID)
if err != nil {
return nil, err
}

var res *compute.Instance
res, err = g.c.Instances().Get(ctx, meta.ZonalKey(canonicalizeInstanceName(name), zone))
res, err = g.c.Instances().Get(ctx, meta.ZonalKey(canonicalizeInstanceName(name), zone), cloud.ForceProjectID(project))
if err != nil {
return
}
Expand Down Expand Up @@ -623,12 +623,12 @@ func (g *Cloud) AddAliasToInstanceByProviderID(providerID string, alias *net.IPN
ctx, cancel := cloud.ContextWithCallTimeout()
defer cancel()

_, zone, name, err := splitProviderID(providerID)
project, zone, name, err := splitProviderID(providerID)
if err != nil {
return err
}

instance, err := g.c.BetaInstances().Get(ctx, meta.ZonalKey(canonicalizeInstanceName(name), zone))
instance, err := g.c.BetaInstances().Get(ctx, meta.ZonalKey(canonicalizeInstanceName(name), zone), cloud.ForceProjectID(project))
if err != nil {
return err
}
Expand Down Expand Up @@ -763,7 +763,7 @@ func (g *Cloud) getInstanceFromProjectInZoneByName(project, zone, name string) (

name = canonicalizeInstanceName(name)
mc := newInstancesMetricContext("get", zone)
res, err := g.c.Instances().Get(ctx, meta.ZonalKey(name, zone))
res, err := g.c.Instances().Get(ctx, meta.ZonalKey(name, zone), cloud.ForceProjectID(project))
mc.Observe(err)
if err != nil {
return nil, err
Expand Down Expand Up @@ -917,12 +917,12 @@ func (g *Cloud) InstanceByProviderID(providerID string) (res *compute.Instance,
ctx, cancel := cloud.ContextWithCallTimeout()
defer cancel()

_, zone, name, err := splitProviderID(providerID)
project, zone, name, err := splitProviderID(providerID)
if err != nil {
return nil, err
}

res, err = g.c.Instances().Get(ctx, meta.ZonalKey(canonicalizeInstanceName(name), zone))
res, err = g.c.Instances().Get(ctx, meta.ZonalKey(canonicalizeInstanceName(name), zone), cloud.ForceProjectID(project))
if err != nil {
return nil, err
}
Expand Down