Skip to content

Commit

Permalink
fix(common): use FQDN for the metadata service (#13139)
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan authored Nov 15, 2023
1 parent 04c532a commit a6cdcdb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion google/cloud/internal/compute_engine_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ std::string GceMetadataScheme() { return "http"; }

std::string GceMetadataHostname() {
return google::cloud::internal::GetEnv(GceMetadataHostnameEnvVar())
.value_or("metadata.google.internal");
.value_or("metadata.google.internal.");
}

} // namespace internal
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/internal/compute_engine_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEST(ComputeEngineUtilTest, CanOverrideGceMetadataHostname) {
// If not overridden for testing, we should get the actual hostname.
google::cloud::testing_util::ScopedEnvironment gce_metadata_hostname_unset(
GceMetadataHostnameEnvVar(), {});
EXPECT_EQ(std::string("metadata.google.internal"), GceMetadataHostname());
EXPECT_EQ(std::string("metadata.google.internal."), GceMetadataHostname());
}

} // namespace
Expand Down
4 changes: 2 additions & 2 deletions google/cloud/internal/unified_rest_credentials_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ TEST(UnifiedRestCredentialsTest, AdcIsComputeEngine) {
auto client = std::make_unique<MockRestClient>();
auto expected_request = AllOf(
Property(&RestRequest::path,
absl::StrCat("http://metadata.google.internal/",
absl::StrCat("http://metadata.google.internal./",
"computeMetadata/v1/instance/service-accounts/",
"default/")),
Property(&RestRequest::headers,
Expand All @@ -259,7 +259,7 @@ TEST(UnifiedRestCredentialsTest, AdcIsComputeEngine) {
auto client = std::make_unique<MockRestClient>();
auto expected_request = AllOf(
Property(&RestRequest::path,
absl::StrCat("http://metadata.google.internal/",
absl::StrCat("http://metadata.google.internal./",
"computeMetadata/v1/instance/service-accounts/",
"default/", "token")),
Property(&RestRequest::headers,
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/storage/internal/compute_engine_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace internal {

std::string GceMetadataHostname() {
return google::cloud::internal::GetEnv(GceMetadataHostnameEnvVar())
.value_or("metadata.google.internal");
.value_or("metadata.google.internal.");
}

} // namespace internal
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/storage/internal/compute_engine_util_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TEST_F(ComputeEngineUtilTest, CanOverrideGceMetadataHostname) {
// If not overridden for testing, we should get the actual hostname.
google::cloud::testing_util::ScopedEnvironment gce_metadata_hostname_unset(
GceMetadataHostnameEnvVar(), {});
EXPECT_EQ(std::string("metadata.google.internal"), GceMetadataHostname());
EXPECT_EQ(std::string("metadata.google.internal."), GceMetadataHostname());
}

} // namespace
Expand Down

0 comments on commit a6cdcdb

Please sign in to comment.