Skip to content

Commit

Permalink
should update the example to use the released version
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Aug 6, 2024
1 parent bff5af4 commit 0b0e2d8
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 29 deletions.
1 change: 1 addition & 0 deletions MAINTAIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ To release a new version, please follow the steps below:
6. Submit a new commit with the changes below:
* Once the image is ready, update the version in the `manifests/charts/*/Chart.yaml`.
* Run `make fmt-go`.
* Update the `./examples/dev_your_plugin` to use the released version.
7. The CI will create a new chart package.
8. Merge the release branch to the main branch.

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ lint-go:
.PHONY: fmt-go
fmt-go: install-go-fmtter
# go mod tidy doesn't recognize the go.work file, see https://github.com/golang/go/issues/50750.
# It will report 'missing directory' error if the 'missing directory' is added in the other module.
# Even running `go work sync` first doesn't solve the problem, if the 'missing directory' is not released.
# It will report 'missing directory' error even if the 'missing directory' is already added in the other module.
# Running `go work sync` first doesn't solve the problem, if the 'missing directory' is not released.
# So we add `-e` to attempt to proceed despite errors encountered while loading packages.
$(foreach PKG, $(GO_MODULES_EXCLUDE_SITE), \
pushd ./${PKG} && \
Expand Down
20 changes: 10 additions & 10 deletions examples/dev_your_plugin/cmd/libgolang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ import (
"github.com/envoyproxy/envoy/contrib/golang/filters/http/source/go/pkg/http"

"mosn.io/htnn/api/pkg/filtermanager"
// For utility plugins provided in the test framework.
// don't import this if you want to produce the shared library for product environment.
_ "mosn.io/htnn/api/plugins/tests/integration/data_plane"
// For utility plugins provided in the test framework.
// don't import this if you want to produce the shared library for product environment.
_ "mosn.io/htnn/api/plugins/tests/integration/dataplane"

// If you want to use the built-in plugins, you can import them here:
// _ "mosn.io/htnn/plugins/plugins"
//
// Note that because we only update the module dependency in the release, if you use
// a non-release version of mosn.io/htnn/plugins module, you may need to manually update the
// dependency yourself, such as using replace in go.mod
_ "mosn.io/htnn/dev_your_plugin/plugins"
// If you want to use the built-in plugins, you can import them here:
// _ "mosn.io/htnn/plugins/plugins"
//
// Note that because we only update the module dependency in the release, if you use
// a non-release version of mosn.io/htnn/plugins module, you may need to manually update the
// dependency yourself, such as using replace in go.mod
_ "mosn.io/htnn/dev_your_plugin/plugins"
)

func init() {
Expand Down
6 changes: 3 additions & 3 deletions examples/dev_your_plugin/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ module mosn.io/htnn/dev_your_plugin
go 1.21

require (
github.com/envoyproxy/envoy v1.29.2
github.com/envoyproxy/envoy v1.29.4
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.33.0
mosn.io/htnn/api v0.2.2-0.20240411084247-3ed33295ba57
mosn.io/htnn/api v0.3.1
)

require (
Expand All @@ -41,6 +41,6 @@ require (
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.0 // indirect
google.golang.org/grpc v1.63.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
12 changes: 6 additions & 6 deletions examples/dev_your_plugin/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa h1:jQCWAUqqlij9Pgj2i/P
github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq8dk6e9PdstVsDgu9RuyIIJqAaF//0IM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/envoy v1.29.2 h1:VhXwGhSt1whNoYZzErcfY3OabVOYoSSDCrln87GcgGA=
github.com/envoyproxy/envoy v1.29.2/go.mod h1:c2OGLXJVY9BaTYPiWFRz6eUNaC+3TfqFKmkWS9brdKo=
github.com/envoyproxy/envoy v1.29.4 h1:1c52LYxzA6arnSjpTfDyxCSrtztwVAnzekcGHirvq8Y=
github.com/envoyproxy/envoy v1.29.4/go.mod h1:c2OGLXJVY9BaTYPiWFRz6eUNaC+3TfqFKmkWS9brdKo=
github.com/envoyproxy/go-control-plane v0.12.1-0.20240117015050-472addddff92 h1:/3bsjkhOTh0swUKDBxL1+3MrXCxrf/sEEMseiIEJg00=
github.com/envoyproxy/go-control-plane v0.12.1-0.20240117015050-472addddff92/go.mod h1:ZBTaoJ23lqITozF0M6G4/IragXCQKCnYbmlmtHvwRG0=
github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
Expand Down Expand Up @@ -48,14 +48,14 @@ google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de h1:
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8=
google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mosn.io/htnn/api v0.2.2-0.20240411084247-3ed33295ba57 h1:BR/NFsFA0iK+QD3YmNFdqiwG/nBiRjVZDj2IHyKTqiA=
mosn.io/htnn/api v0.2.2-0.20240411084247-3ed33295ba57/go.mod h1:ZAHgwF2BbyiWqGCHJgqf7enDGqp00arh1SeQmR1yZRQ=
mosn.io/htnn/api v0.3.1 h1:vQMJI1XCgrWb3PdK7/T9ygdytl1Fps43Ekj36OY1vRk=
mosn.io/htnn/api v0.3.1/go.mod h1:DumqbmMou8J1/DzEDaRIZWpan82bOqxGceWxTju7WkU=
4 changes: 2 additions & 2 deletions examples/dev_your_plugin/plugins/your_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import (
)

const (
Name = "your_plugin"
Name = "yourPlugin"
)

func init() {
plugins.RegisterHttpPlugin(Name, &plugin{})
plugins.RegisterPlugin(Name, &plugin{})
}

type plugin struct {
Expand Down
2 changes: 1 addition & 1 deletion examples/dev_your_plugin/tests/integration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"
"time"

"mosn.io/htnn/api/plugins/tests/integration/control_plane"
"mosn.io/htnn/api/plugins/tests/integration/controlplane"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/stretchr/testify/require"

"mosn.io/htnn/api/pkg/filtermanager"
"mosn.io/htnn/api/plugins/tests/integration/control_plane"
"mosn.io/htnn/api/plugins/tests/integration/data_plane"
"mosn.io/htnn/api/plugins/tests/integration/controlplane"
"mosn.io/htnn/api/plugins/tests/integration/dataplane"
)

func TestYourPlugin(t *testing.T) {
Expand All @@ -41,7 +41,7 @@ func TestYourPlugin(t *testing.T) {
}{
{
name: "happy path",
config: control_plane.NewSinglePluinConfig("your_plugin", map[string]interface{}{}),
config: control_plane.NewSinglePluinConfig("yourPlugin", map[string]interface{}{}),
expect: func(t *testing.T, resp *http.Response) {
assert.Equal(t, "text/plain", resp.Header.Get("content-type"), resp)
},
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/developer-guide/get_involved.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Traditionally, there are two ways to alter the behavior of Istio:

HTNN does not use the methods above but instead modifies Istio to embed its own process into Istio. The specific changes can be referred to in the `patch/istio` directory's patch files. The reason for not using method 1 is that writing stateful EnvoyFilter leads to observability and high availability becoming more challenging and prone to problems. Method 2 is not used because to ensure the consistency of network policy and network routing, the network routing part also needs to be integrated into the MCP server, otherwise, there will be a situation where the policy is still reconciling and the routing has been published online. Providing network routing configurations in MCP server would undoubtedly be a significant workload.

If you develop your own Native Plugin or Service Registry in a third-party repository and want to use it in HTNN, you can use a patch to introduce that repository into Istio. For details, refer to this patch: https://github.com/mosn/htnn/blob/main/patch/istio/1.21/20240410-htnn-go-mod.patch. When importing the repository, make sure to place it after the HTNN official plugin package to avoid being overwritten by plugins with the same name.
If you develop your own Native Plugin or Service Registry in a third-party repository and want to use it in HTNN, you can use a patch to introduce that repository into Istio. For details, refer to this patch: https://github.com/mosn/htnn/blob/main/patch/istio/1.21/20240410-htnn-go-mod.patch.

If you want to run the HTNN control plane, you can refer to the implementation of `make e2e-prepare-controller-image` in the `e2e/` directory to see how to package the Istio embedded with HTNN into an image.

Expand Down
2 changes: 1 addition & 1 deletion site/content/zh-hans/docs/developer-guide/get_involved.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ HTNN 在 `controller/` 模块主要做了下面的事:

HTNN 没有用上述方法,而是通过修改 istio,把自己的流程嵌入到 istio 当中。具体的改动可参考 `patch/istio` 目录下的 patch 文件。之所以不用方法 1,是因为写入带状态的 EnvoyFilter 会导致可观测性和高可用变得更加困难,容易出问题。不用方法 2 的原因在于要想保证策略和路由的一致性,需要将路由也接入到 MCP server 中,否则会出现策略还在调和过程中,路由已经发布上线的情况。将路由也一并在 MCP server 里处理,无疑会是很大的工作量。

如果你在第三方仓库下开发了自己的 Native Plugin 或 Service Registry,想要在 HTNN 中使用,可以通过 patch 的方式将该仓库引入到 istio 当中来。具体参考 https://github.com/mosn/htnn/blob/main/patch/istio/1.21/20240410-htnn-go-mod.patch 这个 patch。注意 import 该仓库时需要把它放到 HTNN 官方插件 package 的后面,这样才能避免被同名的插件覆盖掉。
如果你在第三方仓库下开发了自己的 Native Plugin 或 Service Registry,想要在 HTNN 中使用,可以通过 patch 的方式将该仓库引入到 istio 当中来。具体参考 https://github.com/mosn/htnn/blob/main/patch/istio/1.21/20240410-htnn-go-mod.patch 这个 patch。

如果要想运行 HTNN 的控制面,可以参考 `e2e/` 目录下 `make e2e-prepare-controller-image` 的实现,看看如何将嵌入了 HTNN 的 istio 打包成镜像。

Expand Down

0 comments on commit 0b0e2d8

Please sign in to comment.