From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Filipp Gunbin Newsgroups: gmane.emacs.devel Subject: Re: master 55eabe96c9: ; Improve manual for Tramp kubernetes method Date: Mon, 24 Oct 2022 23:41:50 +0300 Message-ID: References: <166637666472.14803.2269230477358344016@vcs2.savannah.gnu.org> <20221021182424.F0E84C00B0F@vcs2.savannah.gnu.org> <87tu3w6v74.fsf@gmx.de> <87a65l6z0l.fsf@gmx.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30119"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-devel@gnu.org To: Michael Albinus Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 24 23:03:00 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 1on4b1-0007Vi-Qv for ged-emacs-devel@m.gmane-mx.org; Mon, 24 Oct 2022 23:02:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on4Gq-0007Fa-7P; Mon, 24 Oct 2022 16:42:04 -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 1on4Gn-0007FH-MC for emacs-devel@gnu.org; Mon, 24 Oct 2022 16:42:01 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on4Gh-0006dl-OP for emacs-devel@gnu.org; Mon, 24 Oct 2022 16:42:01 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 7E49B3200908; Mon, 24 Oct 2022 16:41:53 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 24 Oct 2022 16:41:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1666644113; x=1666730513; bh=XnZeCz/90y 7zJLeVpPJAmvbIGNEd6s2XBXOkMLW8tXA=; b=MSbFCXwfEDRVGl2cgtcpWnkStY N5JRuZJKOEwvVYsw1/F8+p74SJLiYXymY+pNZuyPVUqmR4KeCbDH3UakfrL7JbuC qGEb4XM6skWYwssgjEEg61ew4ogZoUlo6GJSmJTvlL9J2wtR8YuJo1HwisM061H6 6Gd3KHVnu0ip662cvLpzJHV7pwuFHm4nHmChyu11Hz4/5vW9ZfvjbkHkX5K+1pcf NFzGHl4NXk4hR0Ra8iLaILBq7fcrg0kEknx2Jf3fKeC3STj4GnrJCrgK24suAiYf UlbcIK3/77o8XP4Hioq2Vo+jSM7r5i5tnTI6TUxfBgdyGRiNN6D/S3tBsMzA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1666644113; x=1666730513; bh=XnZeCz/90y7zJLeVpPJAmvbIGNEd 6s2XBXOkMLW8tXA=; b=qE4FeF8e7C1Qvqs1F6nxJtjEoMMw1V8gVsXMieU8HO19 oAB97Upy4uu/hv9pSRf5D6bTGlsC8NLrJQhDuJIuWDKSupzLKURCz5xjfm6OgnBr GYjwkumOixrcHYB7AeYwWv3XvKU7xePerFfqpfYkHCkVuLBEKVkNr1rvu6TWy5/w /xixk1HerbXlztI0vy0hUWuL2Thwdc0RetuB7j7BfYC+97EOkZ01aSCseR6wKnZd XTux0BE6sSoY540pnl0U30JEVF5cY1ozdunNBM8FDijlDSgsStbk/fC+DRr6Dgcu UVOLL6lQKTR4BctgSrx5OEZNDcbseHSr0Mx4/LBlKg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgedtgedgudegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufgjfhgffffkgggtsehttdertddtredtnecuhfhrohhmpefhihhl ihhpphcuifhunhgsihhnuceofhhguhhnsghinhesfhgrshhtmhgrihhlrdhfmheqnecugg ftrfgrthhtvghrnhepudeitdekhffhhfduieeggfekhfeuleefhefglefhtdelffffjeef keegudejjedtnecuffhomhgrihhnpehkuhgsvghrnhgvthgvshdrihhonecuvehluhhsth gvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepfhhguhhnsghinhesfhgr shhtmhgrihhlrdhfmh X-ME-Proxy: Feedback-ID: id48c41f1:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 24 Oct 2022 16:41:52 -0400 (EDT) In-Reply-To: <87a65l6z0l.fsf@gmx.de> (Michael Albinus's message of "Mon, 24 Oct 2022 17:07:38 +0200") Mail-Followup-To: Michael Albinus , emacs-devel@gnu.org Received-SPF: pass client-ip=64.147.123.20; envelope-from=fgunbin@fastmail.fm; helo=wout4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-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:298423 Archived-At: 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 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