This is an automated email from the ASF dual-hosted git repository.
hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git
The following commit(s) were added to refs/heads/master by this push:
new d7dc395 fix(agent): write the agent config when a provider is bound
d7dc395 is described below
commit d7dc3955deb59cfb6462fc47d10f952021c36353
Author: Yang Luo <[email protected]>
AuthorDate: Tue Aug 25 16:35:24 2026 +0800
fix(agent): write the agent config when a provider is bound
---
controllers/agent.go | 9 ++++-----
controllers/agent_provider.go | 12 ++++++++----
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/controllers/agent.go b/controllers/agent.go
index 8dd88bc..52289e9 100644
--- a/controllers/agent.go
+++ b/controllers/agent.go
@@ -95,11 +95,10 @@ func (c *ApiController) GetAgents() {
// to, to the providers tried when that one cannot answer, and to the way it
// reaches them. The binding is per agent id.
//
-// An installation whose configuration file Gateway already wrote is rewritten
-// here: in gateway mode the file does not change, which is what makes a switch
-// take effect without restarting the agent, but in direct mode the new
provider
-// only reaches the agent through its own configuration. Unbinding the agent
-// puts that configuration back the way it was found.
+// The configuration file of every installation Gateway can write is written
+// here, since a binding an agent never reads is one that does nothing: it
keeps
+// calling the provider its own configuration names. Unbinding the agent puts
+// that configuration back the way it was found.
func (c *ApiController) UpdateAgentRouting() {
if c.RequireAdmin() {
return
diff --git a/controllers/agent_provider.go b/controllers/agent_provider.go
index e192adc..f873b3b 100644
--- a/controllers/agent_provider.go
+++ b/controllers/agent_provider.go
@@ -184,9 +184,11 @@ func gatewayAgentUrl(agentId string) string {
return fmt.Sprintf("http://127.0.0.1:%d/v1/agents/%s",
conf.GetHttpPort(), agentId)
}
-// reapplyAgentProvider rewrites the configuration of every installation
Gateway
-// already switched, which is what a routing change means for an agent pointed
-// straight at a provider. It reports what it could not rewrite rather than
+// reapplyAgentProvider writes the bound provider into the configuration of
every
+// installation of one agent, which is what makes a routing change reach the
+// agent at all: an installation Gateway never wrote keeps talking to the
+// provider its own configuration names, and in gateway mode there is nothing
+// else to point it at the proxy. It reports what it could not write rather
than
// failing the routing change, which is already stored by then.
func reapplyAgentProvider(agentId string) string {
installations, err := agent.Scan(false)
@@ -201,7 +203,9 @@ func reapplyAgentProvider(agentId string) string {
continue
}
target := providerTarget(targetOf(installation))
- if !agentprovider.StatusOf(target).Applied {
+ // An agent whose configuration format Gateway cannot write is
reached
+ // through the environment variables the UI shows instead.
+ if !agentprovider.StatusOf(target).Supported {
continue
}
if endpointErr != nil {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]