From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C18DDA00E6 for ; Tue, 6 Aug 2019 11:41:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B5CD21BE3A; Tue, 6 Aug 2019 11:41:33 +0200 (CEST) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by dpdk.org (Postfix) with ESMTP id 14C001BE3B for ; Tue, 6 Aug 2019 11:41:33 +0200 (CEST) Received: by mail-pl1-f171.google.com with SMTP id m9so37509864pls.8 for ; Tue, 06 Aug 2019 02:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=2KYsVCXoKkKvUo/EzTe5eT2PY5Eww03PVMISKWLa4xc=; b=mRFQ1wFrPLk0lhTS916VKbHTCqGVHbD5sROVjU3SM11/dIR/2VqX68SJ37oY+ZcawV JWAEVKbvJ5iBlIoureyC4P/WZpUiNzHMCLf5zkQGTy0TTPZMda8koJlufYOQctzMLzAJ UG1kRrgLG+Q5js/ruByj+hg/srK8eBeIYAn7EcR1OoJj/4KYKqo34Qy2I1bW8yvpNIho 4PpDsSo7/bc69EPYcQR/TWNaHSUJbfvDhuRr37OWp5m7RRsLwOpOXhBLqTKIRBoEvUNP BsvdMyvN4/mEwU7uaLNPMUAIfs4yEANpth4/Wa2Wwj0wtsJMDP6eiaGI5JlrP0sW4rtg bkPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=2KYsVCXoKkKvUo/EzTe5eT2PY5Eww03PVMISKWLa4xc=; b=asWJkaKm0rz7I94XxAThesEVn3PqiSnE/9UBV2Dd4Ju+zFeWtcxmk36rqWrktBuN4L H0z7Yqikf6dv3iIelIoEodxVlvgy8LfE4bfX/z0HCxE6zbTu/CSFIitPgFD/E3O4M83K imItGE0gnC5tBDWgTePGNrcuyhUD3IU2V639LdL+Ujr9dwPtgMIxLxK1h96vmCP5ehVY W4ZooshJoC+MjaS/eKF6Ci+j+t2Ws5/Vz+5uTcQ0QxRX7YZ/hg8P5zVrNIBepMUztnue NWsvmugWeWZgrzvdhiL74m39uBRQgIGvGsvDObrr88ErZHOmqiPYuozZvuMgHZNs17zc 1vSQ== X-Gm-Message-State: APjAAAWf3q6K5eynpStIKWNQ9YGbiAFOU/BtEQGOlA/NeqTha0S5D9DH xpczP/BNDOPBWFavkodbkWVClq10 X-Google-Smtp-Source: APXvYqxFQmECO2oASYwQ1w2RHuoCGuj1OyCzZmFNme+5lVN1fPJ2oXYR/Jl4lMWfqI2gDIUM6+FrWA== X-Received: by 2002:a17:902:b70c:: with SMTP id d12mr2200783pls.314.1565084492172; Tue, 06 Aug 2019 02:41:32 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id f27sm70605754pgm.60.2019.08.06.02.41.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 02:41:31 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Tue, 6 Aug 2019 18:41:25 +0900 Message-Id: <20190806094125.12400-1-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [spp] [PATCH] cli: fix used sec ID is not updated X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa Shared variable `spp_common.used_sec_ids` was introduced to avoid that two secondary processes are launched with duplicated sec IDs. However, it is not updated if secondary process is terminated, and its ID cannot be used again although the ID is released actually. To fix the issue, change to get used sec IDs everytime it is referred and remove nouse `spp_common.used_sec_ids`. Fixes: 6da5038472d9 ("controller: avoid launch with duplicated IDs") Signed-off-by: Yasufumi Ogawa --- src/cli/commands/pri.py | 18 ++++++++++-------- src/cli/spp_common.py | 3 --- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py index 5ad0539..01a2522 100644 --- a/src/cli/commands/pri.py +++ b/src/cli/commands/pri.py @@ -351,10 +351,11 @@ class SppPrimary(object): cli_config['max_secondary']['val']) if tokens[2] in spp_common.SEC_TYPES: - used_ids = spp_common.used_sec_ids + used_sec_ids = [str(i) for i in self._get_sec_ids()] candidates = [ str(i+1) for i in range(max_secondary) - if str(i+1) not in used_ids] + if str(i+1) not in used_sec_ids] + logger.debug(candidates) else: logger.error( 'Error: max_secondary is not defined in config') @@ -365,7 +366,8 @@ class SppPrimary(object): # Sec ID is contained as the third entry in tokens. Here is an # example of tokens. # ['pri;', 'launch', 'nfv', '1', ''] - if tokens[3] not in spp_common.used_sec_ids: + used_sec_ids = [str(i) for i in self._get_sec_ids()] + if tokens[3] not in used_sec_ids: candidates = self._setup_launch_opts( tokens, cli_config) @@ -527,25 +529,25 @@ class SppPrimary(object): opts['app']['--client-id'] = sec_id # Check if sec ID is already used. - if sec_id in spp_common.used_sec_ids: + used_sec_ids = [str(i) for i in self._get_sec_ids()] + if sec_id in used_sec_ids: print('Secondary ID {sid} is already used!'.format( sid=sec_id)) return None logger.debug('launch, {}'.format(opts)) - # Send request for launch secondary. + # Send request for launching secondary. res = self.spp_ctl_cli.put('primary/launch', opts) if res is not None: error_codes = self.spp_ctl_cli.rest_common_error_codes if res.status_code == 204: - # Wait for launch secondary as best effort + # Wait for launching secondary as best effort time.sleep(wait_time) print('Send request to launch {ptype}:{sid}.'.format( ptype=proc_type, sid=sec_id)) - # Add used ID to avoid to launch with duplicated ID. - spp_common.used_sec_ids.append(sec_id) + elif res.status_code in error_codes: pass else: diff --git a/src/cli/spp_common.py b/src/cli/spp_common.py index 5ddca46..b717fb0 100644 --- a/src/cli/spp_common.py +++ b/src/cli/spp_common.py @@ -14,9 +14,6 @@ LOGFILE = 'spp_cli.log' # name of logfile under `/src/controller/log/` # Current server under management of SPP CLI. cur_server_addr = None -# Entry of used secondary IDs to avoid to launch duplicated ID. -used_sec_ids = [] - # Setup logger object logger = logging.getLogger(__name__) # handler = logging.StreamHandler() -- 2.17.1