From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0BF62424C0; Mon, 10 Jun 2024 15:36:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E78EB402DE; Mon, 10 Jun 2024 15:36:48 +0200 (CEST) Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mails.dpdk.org (Postfix) with ESMTP id A7F58402CA for ; Mon, 10 Jun 2024 15:36:46 +0200 (CEST) Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-35f1c490c13so1828859f8f.3 for ; Mon, 10 Jun 2024 06:36:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1718026606; x=1718631406; darn=dpdk.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FNkXf9piVh3TyQ/qztC8YLXl79vfd1UE6rfzDjqqO6w=; b=o/ax24SYin5LeKJzvpMmTunrrO3KKiYIi3/RlsSalHFdFKhrXZ5AygE+cMFLJ9ty2d aejHmVB4SYjPt3GqeJojJl6Ltm4ZuxuG6LzGUdamjs3tOcitv8iRak3fHeL5V/xryHdG KDTzn8SfGs9FiKiXS4EBuIwNCtQiBinrdi5RaEMEqCHopIy9g4rgXR0vaSe3yRvEnMjI B+cVp/96oxBnXDy1u+OmsIVqDe9qwnQIFdsPwunDKcogiAcKFvcME/5W8QvKkSl0ZOtv FOt1lT7eFKWvNlHNqqPd0ceMFPNxXr+VgemNyI7voq/ixXGvJUgqHYVfKpVbg3biiOCG RSdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718026606; x=1718631406; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FNkXf9piVh3TyQ/qztC8YLXl79vfd1UE6rfzDjqqO6w=; b=qYbPIZUDDYjvU0LViQGCMl1hGwtqQMQrKNUulbqid4Lknvr+z7/02Q3CdWJKxuJSkn Le+wWR2zIis4L7uBiYq5A0639u9V6Bze+egt8IIzYEDTEIdRg5yxwAqio/m0SNOcRU8l k4500Ftlx6YKnj28ymFsGNiO7ZkoAwIxRY3g/BJ79OlYHcbmXYAjt02rSQUQ8/KblUMt IEHFoa5wnMVNNLBStP+GzjLCWRgqDc59la0YcVsDt/Z8+aFYplqO1JdpezYQmdYcXm4Z LdoQ6C/86vzflweTUmK1ije5d1KYN29okdhHHUawhZnShCtJ2c3GcdSuoSoxVpqPMcs7 t1Yg== X-Gm-Message-State: AOJu0YwmOmNG7SuVdFNB1wrfToNk8oUbMyke19TeDXPDB4ckL0vrWAM3 QOnlW0BxVat4GTeX85q3vuGvpNcb/gn/1I1iVRnVqDsf8dvomBgseJsZ/47w4kQ= X-Google-Smtp-Source: AGHT+IGHj1Yj2rwECailP2wUYuiC5iVz1yy37vXJjO47635/p5gQWdr7v1CunCj7m6M22xTDpD3UPw== X-Received: by 2002:a05:6000:144b:b0:35f:1846:72cc with SMTP id ffacd0b85a97d-35f1846737cmr5189468f8f.7.1718026606391; Mon, 10 Jun 2024 06:36:46 -0700 (PDT) Received: from [192.168.1.113] ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35f123a8635sm6595752f8f.62.2024.06.10.06.36.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jun 2024 06:36:46 -0700 (PDT) Message-ID: <3555c2df-e2fc-417f-b999-845e9415ef47@pantheon.tech> Date: Mon, 10 Jun 2024 15:36:44 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/4] dts: improve starting and stopping interactive shells To: jspewock@iol.unh.edu, Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu, paul.szczepanek@arm.com, thomas@monjalon.net, wathsala.vithanage@arm.com, npratte@iol.unh.edu, yoan.picchi@foss.arm.com, Luca.Vizzarro@arm.com Cc: dev@dpdk.org References: <20240514201436.2496-1-jspewock@iol.unh.edu> <20240605213148.21371-1-jspewock@iol.unh.edu> <20240605213148.21371-2-jspewock@iol.unh.edu> Content-Language: en-US From: =?UTF-8?Q?Juraj_Linke=C5=A1?= In-Reply-To: <20240605213148.21371-2-jspewock@iol.unh.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > diff --git a/dts/framework/remote_session/interactive_shell.py b/dts/framework/remote_session/interactive_shell.py > index 5cfe202e15..921c73d9df 100644 > --- a/dts/framework/remote_session/interactive_shell.py > +++ b/dts/framework/remote_session/interactive_shell.py > @@ -32,6 +34,10 @@ class InteractiveShell(ABC): > and collecting input until reaching a certain prompt. All interactive applications > will use the same SSH connection, but each will create their own channel on that > session. > + > + Attributes: > + is_started: :data:`True` if the application has started successfully, :data:`False` > + otherwise. > """ > > _interactive_session: SSHClient > @@ -41,6 +47,7 @@ class InteractiveShell(ABC): > _logger: DTSLogger > _timeout: float > _app_args: str > + _finalizer: weakref.finalize > > #: Prompt to expect at the end of output when sending a command. > #: This is often overridden by subclasses. > @@ -58,6 +65,8 @@ class InteractiveShell(ABC): > #: for DPDK on the node will be prepended to the path to the executable. > dpdk_app: ClassVar[bool] = False > > + is_started: bool = False A better name would be is_alive to unify it with SSHSession. > + > def __init__( > self, > interactive_session: SSHClient, > @@ -93,17 +102,39 @@ def __init__( > def _start_application(self, get_privileged_command: Callable[[str], str] | None) -> None: > """Starts a new interactive application based on the path to the app. > > - This method is often overridden by subclasses as their process for > - starting may look different. > + This method is often overridden by subclasses as their process for starting may look > + different. Initialization of the shell on the host can be retried up to 5 times. This is > + done because some DPDK applications need slightly more time after exiting their script to > + clean up EAL before others can start. > + > + When the application is started we also bind a class for finalization to this instance of > + the shell to ensure proper cleanup of the application. Let's also include the explanation from the commit message. > > Args: > get_privileged_command: A function (but could be any callable) that produces > the version of the command with elevated privileges. > """ > + self._finalizer = weakref.finalize(self, self._close) This looks like exactly what we should do, but out of curiosity, do Paramiko docs mention how we should handle channel closing? > + max_retries = 5 > + self._ssh_channel.settimeout(5) > start_command = f"{self.path} {self._app_args}" > if get_privileged_command is not None: > start_command = get_privileged_command(start_command) > - self.send_command(start_command) > + self.is_started = True > + for retry in range(max_retries): > + try: > + self.send_command(start_command) > + break > + except TimeoutError: > + self._logger.info( > + "Interactive shell failed to start, retrying... " > + f"({retry+1} out of {max_retries})" > + ) > + else: > + self._ssh_channel.settimeout(self._timeout) > + self.is_started = False # update state on failure to start > + raise InteractiveCommandExecutionError("Failed to start application.") > + self._ssh_channel.settimeout(self._timeout) > > def send_command(self, command: str, prompt: str | None = None) -> str: > """Send `command` and get all output before the expected ending string.