-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: upgrade envoy.ip_tagging to v3alpha. (#9150)
This is a manual pilot of the v3 API type upgade inside of Envoy. The IP tagging filter was picked as its API dependencies are relatively confined in scope, allowing a self-contained PoC to be written. This will be followed by automated upgrade via the API type database for the bulk of Envoy's internals. Part of #8082 Risk level: Low Testing: Additional unit and integration tests added (version_integration_test). Signed-off-by: Harvey Tuch <[email protected]>
- Loading branch information
Showing
29 changed files
with
358 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "common/config/api_type_db.h" | ||
|
||
#include "common/protobuf/utility.h" | ||
|
||
#include "udpa/type/v1/typed_struct.pb.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
const Protobuf::Descriptor* | ||
ApiTypeDb::inferEarlierVersionDescriptor(absl::string_view extension_name, | ||
const ProtobufWkt::Any& typed_config, | ||
absl::string_view target_type) { | ||
// This is just a placeholder for where we will load from the API type | ||
// database. | ||
absl::string_view type = TypeUtil::typeUrlToDescriptorFullName(typed_config.type_url()); | ||
|
||
udpa::type::v1::TypedStruct typed_struct; | ||
if (type == udpa::type::v1::TypedStruct::default_instance().GetDescriptor()->full_name()) { | ||
MessageUtil::unpackTo(typed_config, typed_struct); | ||
type = TypeUtil::typeUrlToDescriptorFullName(typed_struct.type_url()); | ||
ENVOY_LOG_MISC(debug, "Extracted embedded type {}", type); | ||
} | ||
|
||
// We have an earlier version if (i) we know about the extension (ii) its type | ||
// is different (v3alpha vs. v2) and (iii) we haven't reached the end of the | ||
// upgrade chain. | ||
if (extension_name == "envoy.ip_tagging" && type != target_type && | ||
target_type != "envoy.config.filter.http.ip_tagging.v2.IPTagging") { | ||
const Protobuf::Descriptor* desc = | ||
Protobuf::DescriptorPool::generated_pool()->FindMessageTypeByName( | ||
"envoy.config.filter.http.ip_tagging.v2.IPTagging"); | ||
ASSERT(desc != nullptr); | ||
ENVOY_LOG_MISC(debug, "Inferred {}", desc->full_name()); | ||
return desc; | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "common/protobuf/protobuf.h" | ||
|
||
#include "absl/strings/string_view.h" | ||
|
||
namespace Envoy { | ||
namespace Config { | ||
|
||
class ApiTypeDb { | ||
public: | ||
/** | ||
* Based on the presented extension config and name, determine if this is | ||
* configuration for an earlier version than the latest alpha version | ||
* supported by Envoy internally. If so, return the descriptor for the earlier | ||
* message, to support upgrading via VersionConverter::upgrade(). | ||
* | ||
* @param extension_name name of extension corresponding to config. | ||
* @param typed_config opaque config packed in google.protobuf.Any. | ||
* @param target_type target type of conversion. | ||
* @return const Protobuf::Descriptor* descriptor for earlier message version | ||
* corresponding to config, if any, otherwise nullptr. | ||
*/ | ||
static const Protobuf::Descriptor* | ||
inferEarlierVersionDescriptor(absl::string_view extension_name, | ||
const ProtobufWkt::Any& typed_config, | ||
absl::string_view target_type); | ||
}; | ||
|
||
} // namespace Config | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.