Skip to content
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

Merged
merged 5 commits into from Jun 10, 2020
Merged

Conversation

gekios
Copy link

@gekios gekios commented Mar 12, 2020

Adding a ceph-salt task and suite and also having suse suite point at it instead of deepsea so it runs on our CI.

Comment on lines 7 to 10
if [ ! -n "$BRANCH" ]
then
BRANCH="master"
fi
Copy link

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
Copy link

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?

Copy link
Author

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

Comment on lines 118 to 119
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c',
'systemctl restart salt-minion'])
Copy link

@kshtsk kshtsk Mar 12, 2020

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')

Comment on lines 146 to 150
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'])
Copy link

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?

Copy link

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.

Comment on lines 163 to 166
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c',
'cat /etc/hosts' ])
self.ctx.cluster.run(args=[ 'sudo', 'sh', '-c',
'chattr +i /etc/hosts'])
Copy link

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')

'/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',
Copy link

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.

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.
'''
Copy link

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?

Copy link
Author

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

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

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"))
Copy link

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.

Copy link
Author

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

List updates and perform update if needed
"""
zypper_lu = "sudo salt \\* cmd.run \'zypper lu || true\' 2>/dev/null"
zypper_up = "zypper -n up"
Copy link

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?

Copy link
Author

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.

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():
Copy link

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))

Copy link
Author

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

Copy link

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 ;-)

@toabctl
Copy link

toabctl commented Mar 12, 2020

ok to test

@kshtsk
Copy link

kshtsk commented Mar 18, 2020

resolve conflict required

@gekios gekios force-pushed the wip-ses7-ceph-salt branch 7 times, most recently from 54fe89a to b3d1075 Compare March 19, 2020 12:47
@gekios gekios force-pushed the wip-ses7-ceph-salt branch 2 times, most recently from 9e9f93f to ea7c914 Compare June 9, 2020 10:56
@gekios
Copy link
Author

gekios commented Jun 9, 2020

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

@gekios
Copy link
Author

gekios commented Jun 9, 2020

Copy link

@kshtsk kshtsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

tasks:
- ceph_salt:
repo: https://github.com/ceph/ceph-salt.git
branch: master

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...

@@ -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]

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.

Copy link
Author

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.

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

self.scripts.run(
self.master_remote,
'install_ceph_salt.sh'
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

self.master_remote,
'install_ceph_salt.sh',
args=[ceph_salt_ctx['repo'], ceph_salt_ctx['branch']]
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

self.master_remote,
'install_ceph_salt.sh',
args=ceph_salt_ctx['repo']
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

logger=log.getChild('mon.' + first_mon),
wait=False,
started=True,
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

logger=log.getChild('mgr.' + first_mgr),
wait=False,
started=True,
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

: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):

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

@gekios gekios force-pushed the wip-ses7-ceph-salt branch 2 times, most recently from b105f91 to 60c38c4 Compare June 9, 2020 16:55
@gekios
Copy link
Author

gekios commented Jun 9, 2020

I was running tox that has flake8 but wasn't finding the errors for some reason. I fixed all of them. It's clean

@smithfarm
Copy link

smithfarm commented Jun 10, 2020

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 which and then I will merge it.

Georgios Kyratsas added 4 commits June 10, 2020 10:13
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>
@smithfarm smithfarm added this to the ses7 milestone Jun 10, 2020
Copy link

@smithfarm smithfarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@smithfarm smithfarm merged commit 80000ce into SUSE:ses7 Jun 10, 2020
@gekios gekios deleted the wip-ses7-ceph-salt branch June 11, 2020 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants