From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method Date: Mon, 24 Oct 2022 20:54:42 +0200 Message-ID: <871qqx6oi5.fsf@gmx.de> References: <166637666472.14803.2269230477358344016@vcs2.savannah.gnu.org> <20221021182424.F0E84C00B0F@vcs2.savannah.gnu.org> <87tu3w6v74.fsf@gmx.de> <87a65l6z0l.fsf@gmx.de> <875yg96xu8.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1624"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 24 21:27:07 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1on36I-0000CT-LN for ged-emacs-devel@m.gmane-mx.org; Mon, 24 Oct 2022 21:27:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on2b1-0004k9-M3; Mon, 24 Oct 2022 14:54:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on2b0-0004k1-IR for emacs-devel@gnu.org; Mon, 24 Oct 2022 14:54:46 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on2ay-0003ts-GC for emacs-devel@gnu.org; Mon, 24 Oct 2022 14:54:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1666637683; bh=vP+3Wx0wLBX3KK5tGD79NhP2NouQPyCBz6pmfoutOXc=; h=X-UI-Sender-Class:From:To:Subject:In-Reply-To:References:Date; b=Kk7co+ACcvC/0OaPoFT3Kr9xvtLK2eBWs2aauJNZ5ILVK/DSrvh9abAqpZSl65IPh +2ea/RbzY3STuQfOXDMoAnkN69IUB78KtAEEfOaqwhwAJs40MV2EwldQ8DTvfiQNhv sOwBl/SZeVjz2+4ikQmfU7O4lUVbPCwXiB4bbCtc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([213.220.148.109]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Msq2E-1p6coc3L2G-00tFxm for ; Mon, 24 Oct 2022 20:54:42 +0200 In-Reply-To: <875yg96xu8.fsf@gmx.de> (Michael Albinus's message of "Mon, 24 Oct 2022 17:33:03 +0200") X-Provags-ID: V03:K1:Y1WZgY+Db1gUmGGZJrSN8e3RbkU3Cq7yF3C1KCC8c5rcLUOgBhW jFUObkcfKjjSxiuy/uAI6djhVqEiCrLg3w6sDUgdSdjEhjyXBMFvqT3d8phlD7LHl/O5deg RXazr6T3aG1kHNof8mkH/t76z4uGCkVRFqL3cH28GDukgTqJyb3uvHadgKmGoVtj2Z6k2y/ F4uz64Vy0qHc4pda+qvUA== X-UI-Out-Filterresults: notjunk:1;V03:K0:p5UAca+eCkw=:uwq5qZd7SyqfrRt3Y4aZrS hYFTmkqWvLV87wf9m2eUMgloqh7RZw2OQrQrUJPD8Mi++KOTP6g/kUUYRdYeZoAfwdB2T55BE pHyrTp7eU68cn2+8pEpUXAM5F2VaVUUEGxL9KBAReoa61mNpG+4zby6dErChMcHCFYfyprPgo tfRNQK7fUjTZMx28yDHVi0GtdQWEz+7MBEFGjY5nk3+vrKxmik6xYwryoRDTFfoeMZz/fd0Bs yUtMXf4HUjugG07r3DpNoiUbpz1K8t1ELvP98OxKblq9tDpyev/NTw2thsD2+8eiL2rshgfS2 14+dAeWuHF+HL/c0eh9DXmDuTt8KQJ7s2l64lIbbaBy8FbqtTXr/dJCMD91ryv2mkwldkyMnJ APxjcDfW1PnANRh1swP5DEoyFA7ShEmjGm0hfuBHVfzgZpeDK9llaX2d73jt0O938KAYlLmsX 8t4wOYlXmD8OKtluNazd1k05uuqJ3KLsTx1TcuiflGdkESaSb9BS8rM4nhXkqVRtb7N0lYd0a dZFqBRuNJ3Ic1oXsmNKTgG3BauvJZNbqlXkikYAFVRKGpm7/b68uVNSZIYNhSjCsaTiR5edJ6 AAiCsFntqu2dhimAkEnCHswagBMd87PiudNwEGMcHpxPwmxg3nbWyMAVhTm++pOLDqodTBDpK hM2VGaOR/h3FIpehyGPcoNCT01DNpgxxacywbPOY9PdAE4f5A6PPScYrCeOa5wMatrAtUdP8g pGnkqdWqSQAOBLNVwNU6of0B769LckKPDqy93dON1PZp2Qmkjoz2hg0ZnvGc2A8pSIkCvzWC Received-SPF: pass client-ip=212.227.15.15; envelope-from=michael.albinus@gmx.de; helo=mout.gmx.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298409 Archived-At: --=-=-= Content-Type: text/plain Michael Albinus 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/tramp-container.el b/lisp/tramp-container.el index e104babe..5603fa0f 100644 =2D-- 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)))) + ;;;###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 =2D-- 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) + ;; 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 =2D-- 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 + 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 --=-=-=--