New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding ceph-salt task and suite #373
Conversation
7a99b58
to
9664fdf
Compare
if [ ! -n "$BRANCH" ] | ||
then | ||
BRANCH="master" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be replaced with single command:
BRANCH=${BRANCH:-"master"}
And in fact, it is better to move it outside of the if when you declare this variable:
BRANCH=${2:-"master"}
then | ||
BRANCH="master" | ||
fi | ||
cd /root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to go to /root
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had just copied the code from sesdev
but I don't see any particular reason to clone the repo in /root
dir so I removed it and testing it to be sure
qa/tasks/ceph_salt.py
Outdated
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c', | ||
'systemctl restart salt-minion']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'sh', '-c' are not required, you can use just:
self.ctx.cluster.run(args='sudo systemctl restart salt-minion')
qa/tasks/ceph_salt.py
Outdated
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c', | ||
'sudo zypper -n addrepo --refresh --no-gpgcheck' | ||
' http://download.suse.de/ibs/SUSE:/CA/SLE_15_SP2/ ' | ||
'\'SUSE Internal CA Certificate\'; ' | ||
'zypper -n in ca-certificates-suse']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need 'sudo' two times?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for improving readability and maintainability can this code be refactored like:
self.ctx.cluster.run(args="""
sudo zypper -n addrepo --refresh --no-gpgcheck http://download.suse.de/ibs/SUSE:/CA/SLE_15_SP2/ 'SUSE Internal CA Certificate'
sudo zypper -n in ca-certificates-suse""")
or
repo_url = 'http://download.suse.de/ibs/SUSE:/CA/SLE_15_SP2/'
repo_name = "SUSE Internal CA Certificate"
self.ctx.cluster.run(args="
sudo zypper -n addrepo --refresh --no-gpgcheck {url} '{name}'
sudo zypper -n in ca-certificates-suse".format(url=repo_url, name=repo_name))
or something else which will be easier to read.
qa/tasks/ceph_salt.py
Outdated
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c', | ||
'cat /etc/hosts' ]) | ||
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c', | ||
'chattr +i /etc/hosts']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually, 'sudo sh -c' is not required, it is only required when you want to combine calls or process specifically exit codes, so just use: cluster.run(args='sudo cat /etc/hosts')
or cluster.run(args='sudo chattr +i /etc/hosts')
qa/tasks/ceph_salt.py
Outdated
'/etc/hosts' in all hosts in order to use DNS server for names resolution. | ||
''' | ||
self.log.info(anchored("Removing localhost resolution from /etc/hosts")) | ||
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'sh -c' is not required here.
qa/tasks/ceph_salt.py
Outdated
causes salt to populate 'fqdn_ip4' with 127.0.0.1 and ceph-salt is breaking since it | ||
has a exception for localhost resolution. So this function Removes localhost entries from | ||
'/etc/hosts' in all hosts in order to use DNS server for names resolution. | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this helps to make salt use DNS for hostname resolution, have checked a possibility to give ceph-salt predefined ip addresses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not available yet on ceph-salt
. See ceph/ceph-salt#64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following PR will allow the user to explicitly set bootstrap Mon IP address: ceph/ceph-salt#156
qa/tasks/ceph_salt.py
Outdated
has a exception for localhost resolution. So this function Removes localhost entries from | ||
'/etc/hosts' in all hosts in order to use DNS server for names resolution. | ||
''' | ||
self.log.info(anchored("Removing localhost resolution from /etc/hosts")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically a workaround, we need to declare this some how.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added #FIXME
to point it out
qa/tasks/salt_manager.py
Outdated
List updates and perform update if needed | ||
""" | ||
zypper_lu = "sudo salt \\* cmd.run \'zypper lu || true\' 2>/dev/null" | ||
zypper_up = "zypper -n up" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this run successfully even without sudo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you are right my bad I missed it.
qa/tasks/ceph_salt.py
Outdated
self.master_remote.sh("sudo ceph-salt config /Cluster/Minions add {}".format(host)) | ||
for role in roles: | ||
role = role.split('.')[0] | ||
if role in ceph_salt_roles.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need to get use .keys()
to check if a dictionary has it in python, here is more pythonish style:
if role in ceph_salt_roles:
cluster_role = '/Cluster/Roles/' + ceph_salt_roles[role]
self.master_remote.sh("sudo ceph-salt config {} add {}".format(cluster_role, host))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I aggree with you on the .keys
part but I think it's more readable to have the whole command instead of having cluster_role
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for python dev it should be readable ;-)
ok to test |
resolve conflict required |
54fe89a
to
b3d1075
Compare
9e9f93f
to
ea7c914
Compare
Running a test to be sure I haven't broken anything. I reverted the salt_master role change and added the role parameter in the constructor |
ea7c914
to
977c509
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
qa/ceph_salt/ceph_salt.yaml
Outdated
tasks: | ||
- ceph_salt: | ||
repo: https://github.com/ceph/ceph-salt.git | ||
branch: master |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the CI, we should be installing ceph-salt from RPM, not from source...
qa/ceph_salt/salt.yaml
Outdated
@@ -2,5 +2,5 @@ tasks: | |||
- clock: | |||
- install: | |||
install_ceph_packages: false | |||
extra_system_packages: [salt, salt-master, salt-minion, salt-api] | |||
extra_system_packages: [salt, salt-master, salt-minion, salt-api, which, lsof] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is which
needed for? I tend to avoid it like the plague.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iirc it's is needed for ceph-salt and it was missing from the image. I will test if it works without it and remove if if it's not needed anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed for ceph-salt since ceph/ceph-salt#85 was merged
qa/tasks/ceph_salt.py
Outdated
self.scripts.run( | ||
self.master_remote, | ||
'install_ceph_salt.sh' | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
qa/tasks/ceph_salt.py
Outdated
self.master_remote, | ||
'install_ceph_salt.sh', | ||
args=[ceph_salt_ctx['repo'], ceph_salt_ctx['branch']] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
qa/tasks/ceph_salt.py
Outdated
self.master_remote, | ||
'install_ceph_salt.sh', | ||
args=ceph_salt_ctx['repo'] | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
qa/tasks/ceph_salt.py
Outdated
logger=log.getChild('mon.' + first_mon), | ||
wait=False, | ||
started=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
qa/tasks/ceph_salt.py
Outdated
logger=log.getChild('mgr.' + first_mgr), | ||
wait=False, | ||
started=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
qa/tasks/salt_manager.py
Outdated
:param ctx: Context from the main task | ||
:param role: role that will be used as Salt Master (default 'client.salt_master') | ||
""" | ||
def __init__(self, ctx, role = master_role): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, without the spaces: role=master_role
b105f91
to
60c38c4
Compare
I was running tox that has flake8 but wasn't finding the errors for some reason. I fixed all of them. It's clean |
Thanks. Please remove the |
60c38c4
to
6ec57d8
Compare
Adding Ceph-salt task and a basic suite under qa/suites/ceph_salt. Also changed suse suite to point to ceph-salt instead of deepsea. Signed-off-by: Georgios Kyratsas <gkyratsas@suse.com>
Adding currently unhandled NoValidConnectionsError exception Signed-off-by: Georgios Kyratsas <gkyratsas@suse.com>
Removing all deepsea related files from ses7. Signed-off-by: Georgios Kyratsas <gkyratsas@suse.com>
Adding as optional parameter in the constructor the teuthology role that will be used as the salt master. Signed-off-by: Georgios Kyratsas <gkyratsas@suse.com>
6ec57d8
to
3e55daf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Adding a ceph-salt task and suite and also having suse suite point at it instead of deepsea so it runs on our CI.