Skip to content

Commit

Permalink
fix onGKE to use the cluster location, as name may be registered (#907)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme authored Oct 31, 2024
1 parent dcf7039 commit 8ed7574
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion detectors/gcp/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestCloudPlatformAppEngineStandard(t *testing.T) {

func TestCloudPlatformGKE(t *testing.T) {
d := NewTestDetector(newFakeMetadataTransport(t,
"instance/attributes/cluster-name", "cluster-name",
"instance/attributes/cluster-location", "us-central-1a",
), &FakeOSProvider{
Vars: map[string]string{
k8sServiceHostEnv: "foo",
Expand Down
2 changes: 1 addition & 1 deletion detectors/gcp/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (d *Detector) onGKE() bool {
}
// If we are on k8s, make sure that we are actually on GKE, and not a
// different managed k8s platform.
_, err := d.GKEClusterName()
_, err := d.metadata.InstanceAttributeValueWithContext(context.TODO(), clusterLocationMetadataAttr)
return err == nil
}

Expand Down

0 comments on commit 8ed7574

Please sign in to comment.