From: Filipp Gunbin <fgunbin@fastmail.fm>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: emacs-devel@gnu.org
Subject: Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method
Date: Tue, 25 Oct 2022 02:42:32 +0300 [thread overview]
Message-ID: <m24jvsdc0n.fsf@fastmail.fm> (raw)
In-Reply-To: <871qqx6oi5.fsf@gmx.de> (Michael Albinus's message of "Mon, 24 Oct 2022 20:54:42 +0200")
Hi Michael,
Generally it works, thank you very much!
Test case:
1) kubectl config set-context --current --namespace=main
2) dired /kubernetes:myapp-67cd597654-wxdjn:/
3) tramp-cleanup-this-connection
4) kubectl config set-context --current --namespace=
5) again dired /kubernetes:myapp-67cd597654-wxdjn:/ - I get an error and
cache is cleared
However, now auto-completing /kubernetes: shows this, why 2?
--8<---------------cut here---------------start------------->8---
In this buffer, type RET to select the completion near point.
2 possible completions:
kubernetes:
--8<---------------cut here---------------end--------------->8---
Another issue: if at step 5 I instead use existing dired window and
type, say, "i" on a subdirectory, then I get the same-looking error, but
the Tramp cache is not cleared (perhaps this is not
Kubernetes-specific).
Also please see comments below.
On 24/10/2022 20:54 +0200, Michael Albinus wrote:
> Michael Albinus <michael.albinus@gmx.de> writes:
>
> Hi Filipp,
>
>>> Yep, but I would recommend "kubectl config view --context=$(kubectl
>>> config current-context) -o json". We don't need the information about
>>> other context.
>>
>> Oops. The better way is "kubectl config view -o json --minify".
>
> Patch is appended, could you pls test?
>
> Best regards, Michael.
>
> diff --git a/lisp/tramp-container.el b/lisp/tramp-container.el
> index e104babe..5603fa0f 100644
> --- a/lisp/tramp-container.el
> +++ b/lisp/tramp-container.el
> @@ -130,6 +130,15 @@ see its function help for a description of the format."
> (list nil name))
> names)))
>
> +(defun tramp-kubernetes--current-context-data (vec)
> + "Return current context data as JSON string."
> + (with-temp-buffer
> + (when (zerop
> + (tramp-call-process
> + vec tramp-kubernetes-program nil t nil
> + "config" "view" "--minify" "-o" "json"))
> + (buffer-string))))
> +
Let's remove --minify.
Also, maybe save the checksum (simple md5 would do it), not the full
listing? The listing may contain sensitive data (for example, mine
shows my OAuth id token).
> ;;;###tramp-autoload
> (defvar tramp-default-remote-shell) ;; Silence byte compiler.
>
> @@ -165,6 +174,7 @@ see its function help for a description of the format."
> ("-it")
> ("--")
> ("%l")))
> + (tramp-config-check tramp-kubernetes--current-context-data)
> (tramp-remote-shell ,tramp-default-remote-shell)
> (tramp-remote-shell-login ("-l"))
> (tramp-remote-shell-args ("-i" "-c"))))
> diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
> index d74afc84..39043482 100644
> --- a/lisp/tramp-sh.el
> +++ b/lisp/tramp-sh.el
> @@ -4472,7 +4472,8 @@ process to set up. VEC specifies the connection."
> ;; Check whether the output of "uname -sr" has been changed. If
> ;; yes, this is a strong indication that we must expire all
> ;; connection properties. We start again with
> - ;; `tramp-maybe-open-connection', it will be caught there.
> + ;; `tramp-maybe-open-connection', it will be caught there. The same
> + ;; check will be applied with the function kept in`tramp-config-check'.
> (tramp-message vec 5 "Checking system information")
> (let* ((old-uname (tramp-get-connection-property vec "uname"))
> (uname
> @@ -4481,8 +4482,23 @@ process to set up. VEC specifies the connection."
> old-uname
> (tramp-set-connection-property
> vec "uname"
> - (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\"")))))
> - (when (and (stringp old-uname) (not (string-equal old-uname uname)))
> + (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\""))))
> + (config-check-function
> + (tramp-get-method-parameter vec 'tramp-config-check))
> + (old-config-check
> + (and config-check-function
> + (tramp-get-connection-property vec "config-check-data")))
> + (config-check
> + (and config-check-function
> + ;; If we are in `make-process', we don't need to recompute.
> + (if (and old-config-check
> + (tramp-get-connection-property vec "process-name"))
> + old-config-check
> + (tramp-set-connection-property
> + vec "config-check-data"
> + (tramp-compat-funcall config-check-function vec))))))
> + (when (and (stringp old-uname) (stringp uname)
> + (not (string-equal old-uname uname)))
> (tramp-message
> vec 3
> "Connection reset, because remote host changed from `%s' to `%s'"
> @@ -4490,6 +4506,15 @@ process to set up. VEC specifies the connection."
> ;; We want to keep the password.
> (tramp-cleanup-connection vec t t)
> (throw 'uname-changed (tramp-maybe-open-connection vec)))
> + (when (and (stringp old-config-check) (stringp config-check)
> + (not (string-equal old-config-check config-check)))
> + (tramp-message
> + vec 3
> + "Connection reset, because remote configuration changed from `%s' to `%s'"
> + old-config-check config-check)
Currently, we'll get huge config listings here (at the level 3)? If we
change to checksums, that'd be not very useful. So perhaps don't output
those strings?
> + ;; We want to keep the password.
> + (tramp-cleanup-connection vec t t)
> + (throw 'uname-changed (tramp-maybe-open-connection vec)))
>
> ;; Try to set up the coding system correctly.
> ;; CCC this can't be the right way to do it. Hm.
> diff --git a/lisp/tramp.el b/lisp/tramp.el
> index 57063154..933bac7e 100644
> --- a/lisp/tramp.el
> +++ b/lisp/tramp.el
> @@ -281,6 +281,13 @@ pair of the form (KEY VALUE). The following KEYs are defined:
> Until now, just \"ssh\"-based, \"sshfs\"-based and
> \"adb\"-based methods do.
>
> + * `tramp-config-check'
> + A function to be called with one argument, VEC. It should
> + return a string which is used to check, whether the
Comma not needed?
> + configuration of the remote host has been changed (which
> + would require to flush the cache data). This string is kept
> + as connection property \"config-check-data\".
> +
> * `tramp-copy-program'
> This specifies the name of the program to use for remotely copying
> the file; this might be the absolute filename of scp or the name of
Also, my added paragraph in manual can be removed now.
Thanks.
Filipp
next prev parent reply other threads:[~2022-10-24 23:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <166637666472.14803.2269230477358344016@vcs2.savannah.gnu.org>
[not found] ` <20221021182424.F0E84C00B0F@vcs2.savannah.gnu.org>
2022-10-22 9:53 ` master 55eabe96c9: ; Improve manual for Tramp kubernetes method Michael Albinus
2022-10-24 14:39 ` Filipp Gunbin
2022-10-24 15:07 ` Michael Albinus
2022-10-24 15:33 ` Michael Albinus
2022-10-24 18:54 ` Michael Albinus
2022-10-24 23:42 ` Filipp Gunbin [this message]
2022-10-25 14:50 ` Michael Albinus
2022-10-25 15:43 ` Yuri Khan
2022-10-25 15:48 ` Robert Pluim
2022-10-25 16:02 ` Yuri Khan
2022-10-25 16:45 ` Michael Albinus
2022-10-25 17:29 ` Filipp Gunbin
2022-10-25 17:48 ` Michael Albinus
2022-10-25 18:41 ` Filipp Gunbin
2022-10-25 20:14 ` Filipp Gunbin
2022-10-26 12:01 ` Michael Albinus
2022-10-24 20:41 ` Filipp Gunbin
2022-10-24 22:49 ` Filipp Gunbin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m24jvsdc0n.fsf@fastmail.fm \
--to=fgunbin@fastmail.fm \
--cc=emacs-devel@gnu.org \
--cc=michael.albinus@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.