Related: https://pagure.io/koji/issue/3890
rebased onto 18884d9c41941c5363b49a0952ff0f402ab8a1d3
rebased onto d267b7aee3c24dfc1732bd2be5fd05f61fa74f17
Iv'e reworked it a bit and providing cached property directly in ClientSession. (Inspired by https://github.com/obriencj/koji-smoky-dingo/blob/master/kojismokydingo/init.py#L1312)
In handle_add_channel, why move the print statement inside the try?
handle_add_channel
try: self.__hub_version = self.getKojiVersion(as_string=False) except GenericError: self.__hub_version = (1, 22, 0)
This PR adds the as_string param, so this call will fail on all older hubs. If you want the client to report the version tuple from 1.22 to 1.34, you'll need to call without the arg and parse the result.
This is marked for 1.34.1, but it involves an api change. Unless there is a strong reason otherwise, I'd say we should defer it to 1.35
rebased onto 3e0a4529d25345aa421108ed6d74a1ba1061f91a
Is it worth adding the as_string option if we're not using it?
as_string
If the string version is what we're fetching from the hub, perhaps it would be better to cache that and have the tuple property perform conversion rather than the other way around.
The cached hub version could become invalid for a long lived session if the hub is upgraded.
It might be a good idea for the hub to return a Koji-Version header each time. The client could populate/update the cache with this. This would help address the above, at least once this behavior is established.
Koji-Version
rebased onto 72164d48f56f91e14b9503d9dbd0f08ad3ada149
Header is probably nice solution.
except GenericError: # hub is older than 1.23, return latest version without the getKojiVersion self.__hub_version = '1.22.0'
We can't assume that GenericError means this. Even the the call handler itself is very simple, there are still a number of ways we could get an error from the hub. E.g. various session related errors if we have already logged in. We need to check for "Invalid method" and re-raise If not, else we could mask other issues.
It seems a bit more natural to me to have the string property do the fetching if the string value is what we're fetching. Maybe like this?
https://pagure.io/fork/mikem/koji/commits/pr3891tweak
Aggred, added commit to PR.
1 new commit added
move version fetching to hub_version_str property
self.__hub_version = r.headers.get('Koji-Version')
Hmm, I just realized that this will erase the cache every call for koji<1.35
Also, what do you think about including the version in koji hello output?
koji hello
2 new commits added
show hub version in koji hello
avoid clearing cached hub version
added
:thumbsup:
Metadata Update from @tkopecek: - Pull-request tagged with: testing-ready
Metadata Update from @mfilip: - Pull-request tagged with: testing-done
Commit d6a59cb5 fixes this pull-request
Pull-Request has been merged by tkopecek
Related: https://pagure.io/koji/issue/3890