Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
slapos.core
Commits
2ea07536
Commit
2ea07536
authored
May 27, 2021
by
Thomas Gambier
🚴🏼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli/boot: fix possible KeyError in _waitIpv6Ready
parent
69095b74
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
slapos/cli/boot.py
slapos/cli/boot.py
+7
-9
slapos/tests/test_cli.py
slapos/tests/test_cli.py
+10
-4
No files found.
slapos/cli/boot.py
View file @
2ea07536
...
...
@@ -141,15 +141,13 @@ def _waitIpv6Ready(ipv6_interface):
"""
test if ipv6 is ready on ipv6_interface
"""
ipv6_address
=
""
print
(
"[BOOT] Checking if %r has IPv6..."
%
ipv6_interface
)
while
ipv6_address
==
""
:
for
inet_dict
in
netifaces
.
ifaddresses
(
ipv6_interface
)
[
socket
.
AF_INET6
]
:
while
True
:
for
inet_dict
in
netifaces
.
ifaddresses
(
ipv6_interface
)
.
get
(
socket
.
AF_INET6
,
())
:
ipv6_address
=
inet_dict
[
'addr'
].
split
(
'%'
)[
0
]
if
isGlobalScopeAddress
(
ipv6_address
):
break
else
:
ipv6_address
=
""
return
print
(
"[BOOT] [ERROR] No IPv6 found on interface %r, "
"try again in 5 seconds..."
%
ipv6_interface
)
sleep
(
5
)
...
...
slapos/tests/test_cli.py
View file @
2ea07536
...
...
@@ -340,14 +340,19 @@ class TestCliBoot(CliMixin):
timestamp
)
def
test_boot_failure
(
self
):
# In this test, node and bang command will fail two time each.
# In this test, the network interfaces will not have
# IP address at the beginning, the global IPv6 address only appears later,
# then format and bang commands will fail two time each.
# `slapos node boot` command retries on failures.
app
=
slapos
.
cli
.
entry
.
SlapOSApp
()
net1
=
{
socket
.
AF_INET
:
({
'addr'
:
'127.0.0.1'
},),}
net2
=
{
socket
.
AF_INET
:
({
'addr'
:
'127.0.0.1'
},),
socket
.
AF_INET6
:
({
'addr'
:
'fe80::1'
},),}
net3
=
{
socket
.
AF_INET
:
({
'addr'
:
'127.0.0.1'
},),
socket
.
AF_INET6
:
({
'addr'
:
'fe80::1'
},
{
'addr'
:
'2000::1'
},),}
with
patch
(
'slapos.cli.boot.check_root_user'
,
return_value
=
True
)
as
check_root_user
,
\
patch
(
'slapos.cli.boot.sleep'
)
as
sleep
,
\
patch
(
'slapos.cli.boot.netifaces.ifaddresses'
,
return_value
=
{
socket
.
AF_INET6
:
({
'addr'
:
'2000::1'
},),},
),
\
side_effect
=
[
net1
,
net2
,
net3
]
),
\
patch
(
'slapos.cli.boot._ping_hostname'
,
return_value
=
0
),
\
patch
(
'slapos.cli.format.check_root_user'
,
return_value
=
True
),
\
patch
(
'slapos.cli.format.logging.FileHandler'
,
return_value
=
logging
.
NullHandler
()),
\
...
...
@@ -362,8 +367,9 @@ class TestCliBoot(CliMixin):
self
.
assertEqual
(
do_format
.
call_count
,
3
)
self
.
assertEqual
(
do_bang
.
call_count
,
3
)
# between retries we sleep 15 seconds.
sleep
.
assert_called_with
(
15
)
# between retries of ping, we sleep 5 seconds
# between retries of bang, we sleep 15 seconds
self
.
assertEqual
(
sleep
.
mock_calls
,
[
mock
.
call
(
5
)]
*
2
+
[
mock
.
call
(
15
)]
*
4
)
# we have only one logger on the console
from
slapos.cli
import
coloredlogs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment