[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method
From: |
Filipp Gunbin |
Subject: |
Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method |
Date: |
Mon, 24 Oct 2022 23:41:50 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Michael,
While I briefly looked at the patch, I have a doubt that it will help,
see below.
On 24/10/2022 17:07 +0200, Michael Albinus wrote:
> Filipp Gunbin <fgunbin@fastmail.fm> writes:
>
>> Hi Michael,
>
> Hi Filipp,
>
>>> Can we automate this? I mean, when pod data are cached, and Tramp
>>> detects a changed namespace, the cached data should be flushed?
>>>
>>> Tramp does something similar with other connection methods, for example
>>> it checks "uname -sr" on remote hosts, and caches the result. Whenever a
>>> new connection to a host is established, Tramp calls again "uname -sr",
>>> and compares with the cached value. If the values differ, all cached
>>> data for this connection are flushed.
>>>
>>> Is there a similar way to retieve (and cache) the current context and
>>> namespace for pods?
>>
>> (I've actually wrote a message to emacs-devel about this, but then
>> decided it's just simpler to advise resetting cache, and didn't send the
>> message; maybe I should have asked first)
>
> No problem that's what code review is good for :-)
>
>> AFAIU, the general way would be to call "kubectl config view -o json",
>> then calculate checksum of the output and cache it. This would catch
>> any change in context (namespace it just one case of many).
>
> Yep, but I would recommend "kubectl config view --context=$(kubectl
> config current-context) -o json". We don't need the information about
> other context.
First, I think we do need all context info. "kubectl config
use-context" is no different from other configuration changes, which a
user may do "outside" of Emacs at any time.
>> However, there're two things to consider here:
>>
>> - "config view" command is not instantaneous: on my machine it's about
>> 100ms, and calling it on each (say) host completion would be annoying.
>
> I don't recommend it for hostname completion. I recommend it for opening
> a connection; the cleanup shall happen in tramp-maybe-open-connection
> via a hook.
>
> If a user changes the context while there is an active connection in
> Tramp, she will be lost. But this isn't an Emacs/Tramp specific
> situation, so we don't need to care or document it.
Second, I (seem to) understand what the uname check is for. It may help
if some host on the network is recreated. Or if a user changes network
and the same hostname/IP starts referring to another machine. But here,
first of all I stumbled upon this problem:
- set some namespace
- open container
- .. then your connection somehow closes, which can be simulated by
tramp-cleanup-this-connection...
- change namespace
- at this point, if you type "/kubernetes:", you'll get your old pod
name in the completion
I think completion is much more important in case of Kubernetes than
when dealing with normal hosts: pods usually will have unpredictable
technical names with random parts. So to get around it, we'll have to
refresh context on every completion. Doing this when opening connection
doesn't have much sense: you anyway get an error, and you anyway won't
know proper pod names.
We could try checking config file modtime, its faster then kubectl
config view. https://kubernetes.io/docs/reference/kubectl/ says:
--8<---------------cut here---------------start------------->8---
For configuration, kubectl looks for a file named config in the
$HOME/.kube directory. You can specify other kubeconfig files by setting
the KUBECONFIG environment variable or by setting the --kubeconfig flag.
--8<---------------cut here---------------end--------------->8---
But then we have to follow this, and require the user to tell Emacs
about --kubeconfig in use (if any).
So I end up at the conclusion that in this case it's better for user to
learn that she should reset Tramp cache. Our help could become more
confusing than helping.
WDYT?
Thanks,
Filipp
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, (continued)
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Michael Albinus, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Yuri Khan, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Robert Pluim, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Yuri Khan, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Michael Albinus, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Filipp Gunbin, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Michael Albinus, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Filipp Gunbin, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Filipp Gunbin, 2022/10/25
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Michael Albinus, 2022/10/26
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method,
Filipp Gunbin <=
- Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method, Filipp Gunbin, 2022/10/24