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

Permissions of deployed files and keep node.id #270

Merged
merged 4 commits into from
Sep 29, 2016

Conversation

rschlussel-zz
Copy link
Member

fixes #266

secure_create_file(node_file_path, PRESTO_STANDALONE_USER_GROUP)
if not exists(node_file_path, use_sudo=True):
secure_create_file(node_file_path, PRESTO_STANDALONE_USER_GROUP, mode=644)
else:
Copy link
Member Author

Choose a reason for hiding this comment

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

we need to do this because the rpm doesn't set up the config files with correct ownership (see Teradata/presto#358)

@rschlussel-zz
Copy link
Member Author

@petroav @ebd2

Copy link
Contributor

@petroav petroav left a comment

Choose a reason for hiding this comment

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

Everything looks good except for one question on the default permissions on the connector directory.

missing_owner_code = 42
command = \
"( getent passwd {user} >/dev/null || exit {missing_owner_code} ) &&" \
" mkdir -p {filepath} && " \
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put the space at the beginning of this line at the end of the line above?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -118,6 +118,26 @@ def secure_create_file(filepath, user_group, mode=600):
abort("Failed to securely create file %s" % (filepath))


def secure_create_directory(filepath, user_group, mode=755):
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought the directory had to have permissions 644. Why is the default 755?

Copy link
Member Author

Choose a reason for hiding this comment

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

it should have 755 permissions so that it is traversable. I'll fix the commit message

result = sudo(command)
if result.return_code == missing_owner_code:
abort("User %s does not exist. Make sure the Presto server RPM "
"is installed and try again" % (user,))
Copy link
Contributor

Choose a reason for hiding this comment

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

In (user,) what's the comma for? Is it required?

Copy link
Member Author

Choose a reason for hiding this comment

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

The comma makes this a tuple, but I'll change this to not be a tuple. when only one argument is needed to % operator, you don't need a tuple

@@ -269,6 +269,13 @@ def assert_config_perms(self, host, filepath):
self.assert_file_perm_owner(
host, filepath, '-rw-------', 'presto', 'presto')

def assert_directory_perm_owner(self, host, filepath, permissions, owner, group):
ls = self.cluster.exec_cmd_on_host(host, "ls -l -d %s" % (filepath,))
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question about the comma here as well.

Copy link
Member Author

@rschlussel-zz rschlussel-zz Sep 27, 2016

Choose a reason for hiding this comment

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

same answer

@@ -41,7 +42,7 @@

def deploy_files(filenames, local_dir, remote_dir, user_group, mode=0600):
Copy link
Contributor

@ebd2 ebd2 Sep 26, 2016

Choose a reason for hiding this comment

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

Please comment explaining why the mode for connectors is different than for regular config now that they're different.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -267,8 +267,19 @@ def get_file_content(self, host, filepath):

def assert_config_perms(self, host, filepath):
self.assert_file_perm_owner(
host, filepath, '-rw-r--r--', 'presto', 'presto')

def assert_connnector_perms(self, host, filepath):
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: connnector

Copy link
Member Author

Choose a reason for hiding this comment

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

done

host, filepath, '-rw-------', 'presto', 'presto')

def assert_directory_perm_owner(self, host, filepath, permissions, owner, group):
ls = self.cluster.exec_cmd_on_host(host, "ls -l -d %s" % (filepath,))
Copy link
Contributor

Choose a reason for hiding this comment

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

Everything but the ls command is the same in this and assert_file_perm_owner. Please consolidate.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

def assert_directory_perm_owner(self, host, filepath, permissions, owner, group):
ls = self.cluster.exec_cmd_on_host(host, "ls -l -d %s" % (filepath,))
fields = ls.split()
self.assertEqual(fields[0], permissions)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should probably assert that the expected perms includes the 'd' or 'l' at the beginning or there's no way the perms are going to match. This assertion will fail, but it's misleading because it's the expected value that's totally bogus.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, let's not worry about symlinks for now...

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member Author

@rschlussel-zz rschlussel-zz left a comment

Choose a reason for hiding this comment

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

Addressed comments

@@ -118,6 +118,26 @@ def secure_create_file(filepath, user_group, mode=600):
abort("Failed to securely create file %s" % (filepath))


def secure_create_directory(filepath, user_group, mode=755):
Copy link
Member Author

Choose a reason for hiding this comment

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

it should have 755 permissions so that it is traversable. I'll fix the commit message

missing_owner_code = 42
command = \
"( getent passwd {user} >/dev/null || exit {missing_owner_code} ) &&" \
" mkdir -p {filepath} && " \
Copy link
Member Author

Choose a reason for hiding this comment

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

done

result = sudo(command)
if result.return_code == missing_owner_code:
abort("User %s does not exist. Make sure the Presto server RPM "
"is installed and try again" % (user,))
Copy link
Member Author

Choose a reason for hiding this comment

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

The comma makes this a tuple, but I'll change this to not be a tuple. when only one argument is needed to % operator, you don't need a tuple

@@ -269,6 +269,13 @@ def assert_config_perms(self, host, filepath):
self.assert_file_perm_owner(
host, filepath, '-rw-------', 'presto', 'presto')

def assert_directory_perm_owner(self, host, filepath, permissions, owner, group):
ls = self.cluster.exec_cmd_on_host(host, "ls -l -d %s" % (filepath,))
Copy link
Member Author

@rschlussel-zz rschlussel-zz Sep 27, 2016

Choose a reason for hiding this comment

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

same answer

def assert_directory_perm_owner(self, host, filepath, permissions, owner, group):
ls = self.cluster.exec_cmd_on_host(host, "ls -l -d %s" % (filepath,))
fields = ls.split()
self.assertEqual(fields[0], permissions)
Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -267,8 +267,19 @@ def get_file_content(self, host, filepath):

def assert_config_perms(self, host, filepath):
self.assert_file_perm_owner(
host, filepath, '-rw-r--r--', 'presto', 'presto')

def assert_connnector_perms(self, host, filepath):
Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -41,7 +42,7 @@

def deploy_files(filenames, local_dir, remote_dir, user_group, mode=0600):
Copy link
Member Author

Choose a reason for hiding this comment

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

done

host, filepath, '-rw-------', 'presto', 'presto')

def assert_directory_perm_owner(self, host, filepath, permissions, owner, group):
ls = self.cluster.exec_cmd_on_host(host, "ls -l -d %s" % (filepath,))
Copy link
Member Author

Choose a reason for hiding this comment

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

done

@rschlussel-zz rschlussel-zz force-pushed the deploy branch 2 times, most recently from c553b77 to ae6d73d Compare September 27, 2016 18:42
The catalog directory should be owned by presto:presto and have 755
permissions.
Keep the node.id consistent across multiple runs of configuration
deploy.  Instead of overwriting the file if it exists, append to it, and
just make sure it has the right permissions and ownership.
@rschlussel-zz rschlussel-zz merged commit c38b7dc into prestodb:master Sep 29, 2016
@rschlussel-zz rschlussel-zz deleted the deploy branch November 14, 2016 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configuration deploy doesn't keep the node.id
3 participants