-
Notifications
You must be signed in to change notification settings - Fork 100
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
Conversation
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: |
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.
we need to do this because the rpm doesn't set up the config files with correct ownership (see Teradata/presto#358)
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.
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} && " \ |
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.
Can you put the space at the beginning of this line at the end of the line above?
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.
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): |
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 thought the directory had to have permissions 644. Why is the default 755?
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 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,)) |
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.
In (user,)
what's the comma for? Is it required?
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 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,)) |
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.
Same question about the comma here as well.
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.
same answer
@@ -41,7 +42,7 @@ | |||
|
|||
def deploy_files(filenames, local_dir, remote_dir, user_group, mode=0600): |
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 comment explaining why the mode for connectors is different than for regular config now that they're different.
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.
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): |
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.
typo: connnector
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.
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,)) |
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.
Everything but the ls command is the same in this and assert_file_perm_owner. Please consolidate.
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.
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) |
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.
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.
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.
Actually, let's not worry about symlinks for now...
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.
done
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.
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): |
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 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} && " \ |
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.
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,)) |
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 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,)) |
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.
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) |
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.
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): |
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.
done
@@ -41,7 +42,7 @@ | |||
|
|||
def deploy_files(filenames, local_dir, remote_dir, user_group, mode=0600): |
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.
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,)) |
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.
done
c553b77
to
ae6d73d
Compare
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.
ae6d73d
to
c38b7dc
Compare
fixes #266