Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create remote site cache based on remote auth version #12130

Merged
merged 5 commits into from
Apr 26, 2022

Conversation

rosstimothy
Copy link
Contributor

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth and proxy version in response to a version request.
To maintain backward compatibility the reverse tunnel server will
fallback to using the proxy version if the response does not
contain an auth version.

Fixes #12010

Copy link
Contributor

@smallinsky smallinsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.
@jakule Could you also take a look ?

lib/reversetunnel/agent.go Outdated Show resolved Hide resolved
lib/reversetunnel/srv.go Outdated Show resolved Hide resolved
@smallinsky smallinsky requested a review from jakule April 21, 2022 09:02
@jakule
Copy link
Contributor

jakule commented Apr 21, 2022

@rosstimothy I was using this logic in my other PR, but this PR won't make a huge difference #12040.
But there is other thing. I assume that this PR will be backported to v9. The function checks if the cluster that you're connecting to is before v8. Technically we allow only one version different, so if this PR makes only to v9, then the only cluster that you can connect to older than v9 is v8. From what I understand this is not supported scenario in our case? Correct me if I'm wrong.

lib/reversetunnel/srv.go Outdated Show resolved Hide resolved
lib/reversetunnel/agent.go Outdated Show resolved Hide resolved
@rosstimothy
Copy link
Contributor Author

@rosstimothy I was using this logic in my other PR, but this PR won't make a huge difference #12040. But there is other thing. I assume that this PR will be backported to v9. The function checks if the cluster that you're connecting to is before v8. Technically we allow only one version different, so if this PR makes only to v9, then the only cluster that you can connect to older than v9 is v8. From what I understand this is not supported scenario in our case? Correct me if I'm wrong.

This PR needs to be backported as far as possible. It was actually found by a customer upgrading from v6 -> v7. I don't think any of the changes introduced here really change the logic in which clusters you can connect to. It simply changes which service in the remote cluster is used to determine its version. Using the agent version is incorrect both for determining the cache policy, and for the new use case that you added in #12040. Since the cache is generated by connecting to the auth server, and the remote watchers are all created from the cache we need to know the auth version. Things only work as is if the auth version and agent version are the same.

@jakule
Copy link
Contributor

jakule commented Apr 22, 2022

@rosstimothy I was using this logic in my other PR, but this PR won't make a huge difference #12040. But there is other thing. I assume that this PR will be backported to v9. The function checks if the cluster that you're connecting to is before v8. Technically we allow only one version different, so if this PR makes only to v9, then the only cluster that you can connect to older than v9 is v8. From what I understand this is not supported scenario in our case? Correct me if I'm wrong.

This PR needs to be backported as far as possible. It was actually found by a customer upgrading from v6 -> v7. I don't think any of the changes introduced here really change the logic in which clusters you can connect to. It simply changes which service in the remote cluster is used to determine its version. Using the agent version is incorrect both for determining the cache policy, and for the new use case that you added in #12040. Since the cache is generated by connecting to the auth server, and the remote watchers are all created from the cache we need to know the auth version. Things only work as is if the auth version and agent version are the same.

In this case can we rename the function isPreV8Cluster() to something like isOldCachePolicy()? I was under the impression that this function is only needed in v9 cluster, but from what I understand is not true.

@rosstimothy
Copy link
Contributor Author

@rosstimothy I was using this logic in my other PR, but this PR won't make a huge difference #12040. But there is other thing. I assume that this PR will be backported to v9. The function checks if the cluster that you're connecting to is before v8. Technically we allow only one version different, so if this PR makes only to v9, then the only cluster that you can connect to older than v9 is v8. From what I understand this is not supported scenario in our case? Correct me if I'm wrong.

This PR needs to be backported as far as possible. It was actually found by a customer upgrading from v6 -> v7. I don't think any of the changes introduced here really change the logic in which clusters you can connect to. It simply changes which service in the remote cluster is used to determine its version. Using the agent version is incorrect both for determining the cache policy, and for the new use case that you added in #12040. Since the cache is generated by connecting to the auth server, and the remote watchers are all created from the cache we need to know the auth version. Things only work as is if the auth version and agent version are the same.

In this case can we rename the function isPreV8Cluster() to something like isOldCachePolicy()? I was under the impression that this function is only needed in v9 cluster, but from what I understand is not true.

Yeah this could probably be named better. I believe it was initially added in v7 due to the need to support resource changes in the backend which introduced the two different remote cache policies. It looks like over the course of newer versions the name isPreXCluster has just kept incrementing the version number:

ok, err := isPreV7Cluster(closeContext, sconn)

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth and proxy version in response to a version request.
To maintain backward compatability the reverse tunnel server will
fallback to using the proxy version if the response does not
contain an auth version.

Fixes #12010
@rosstimothy rosstimothy force-pushed the tross/remote_version branch from ff7d0cb to ac35e46 Compare April 25, 2022 17:49
if err != nil {
log.Debugf("Failed to reply to %v request: %v.", r.Type, err)
a.log.WithError(err).Debugf("Failed to ping auth server.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we increase severity level to INFO ?
In case where the ping call failed it hole addRemoteCluster operation fails so it would be nice to have insight about this.

log.Debugf("Failed to reply to %v request: %v.", r.Type, err)
a.log.WithError(err).Debugf("Failed to ping auth server.")
if err := r.Reply(false, []byte("Failed to retrieve auth version")); err != nil {
a.log.Debugf("Failed to reply to %version request: %v.", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
a.log.Debugf("Failed to reply to %version request: %v.", err)
a.log.Debugf("Failed to reply to %v request: %v.", r.Type, err)

@rosstimothy rosstimothy merged commit 4f2ad1f into master Apr 26, 2022
@rosstimothy rosstimothy deleted the tross/remote_version branch April 26, 2022 14:39
rosstimothy added a commit that referenced this pull request Apr 26, 2022
* Create remote site cache based on remote auth version

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth version in response to a version request.

Fixes #12010

(cherry picked from commit 4f2ad1f)

# Conflicts:
#	lib/reversetunnel/srv.go
@rosstimothy
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
branch/v7
branch/v8
branch/v9

Questions ?

Please refer to the Backport tool documentation

rosstimothy added a commit that referenced this pull request Apr 26, 2022
* Create remote site cache based on remote auth version

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth version in response to a version request.

Fixes #12010

(cherry picked from commit 4f2ad1f)
rosstimothy added a commit that referenced this pull request Apr 26, 2022
* Create remote site cache based on remote auth version

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth version in response to a version request.

Fixes #12010

(cherry picked from commit 4f2ad1f)
rosstimothy added a commit that referenced this pull request Apr 27, 2022
* Create remote site cache based on remote auth version

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth version in response to a version request.

Fixes #12010

(cherry picked from commit 4f2ad1f)

# Conflicts:
#	lib/reversetunnel/srv.go
rosstimothy added a commit that referenced this pull request Apr 27, 2022
* Create remote site cache based on remote auth version

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth version in response to a version request.

Fixes #12010

(cherry picked from commit 4f2ad1f)
rosstimothy added a commit that referenced this pull request Apr 28, 2022
* Create remote site cache based on remote auth version

The cache policy used for a remote site is determined based on
the response from a version request. However the version response
was only returning the proxy version. If the remote site was not
running the same version for both auth and proxy, then the cache
policy chosen could be invalid.

The reverse tunnel agent now pings its auth server and reports
both the auth version in response to a version request.

Fixes #12010

(cherry picked from commit 4f2ad1f)
@webvictim webvictim mentioned this pull request Jun 8, 2022
@marcoandredinis marcoandredinis removed their request for review March 24, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote Site should check version of Auth server not Proxy server
3 participants