Skip to content

Remove the check for the clone cluster name. #270

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

Merged
merged 5 commits into from
May 3, 2018

Conversation

alexeyklyukin
Copy link
Contributor

Clone cluster name may not adhere to the same rules as the names of the
clusters managed by the operator, as it might be just a name inside the
S3 bucket.

Clone cluster name may not adhere to the same rules as the names of the
clusters managed by the operator, as it might be just a name inside the
S3 bucket.
@Jan-M
Copy link
Member

Jan-M commented Apr 6, 2018

👍

@alexeyklyukin
Copy link
Contributor Author

👎 tests are still failing

@mgomezch
Copy link
Contributor

mgomezch commented Apr 6, 2018

This means anyone able to deploy a manifest can clone from any cluster's backups, and thus read all the data in other clusters. Just checking: does this break any currently existing privilege boundaries?

@alexeyklyukin
Copy link
Contributor Author

It pretty much depends on how different teams are separated on the infrastructure level; if all of them share the backup location there is no way this PR makes things worse (as one could, for instance, just restore the backup of other team to your own cluster manually w/o any assistance from the operator)

@coveralls
Copy link

coveralls commented Apr 6, 2018

Coverage Status

Coverage increased (+0.01%) to 11.501% when pulling e14eb54 on remove_clone_name_constraint into c44cd9e on master.

@alexeyklyukin
Copy link
Contributor Author

👍

- check that the normal and clone cluster name complies with the valid
  service name. For clone cluster, only do it if clone timestamp is not
  set; with a clone timestamp set, the clone name points to the S3 bucket

 - add tests and improve existing ones, making sure we don't call Error()
   method for an empty error, as well as that we don't miss cases where
   expected error is not empty, but actual call to be tested does not
   return an error.
@alexeyklyukin
Copy link
Contributor Author

👍

if err == nil {
tmp2.Spec.ClusterName = clusterName
} else {
if clusterName, err := extractClusterName(tmp2.ObjectMeta.Name, tmp2.Spec.TeamID); err != nil {
Copy link
Member

@Jan-M Jan-M Apr 13, 2018

Choose a reason for hiding this comment

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

will this code now support restoring from S3 where the cluster name is basically: "foobar" (spilo ec2 deployments)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That line doesn't validate the clone cluster name, it happens at https://github.com/zalando-incubator/postgres-operator/pull/270/files/04d6a7607508fef669faacfb57ef9ef443b587da#diff-44fe837275fc3b64cc6c85eb90ce74c9R247

There, the name for the cluster clone that comes from S3 is not validated.

@@ -43,14 +43,29 @@ var clusterNames = []struct {
{"acid-test", "acid", "test", nil},
Copy link
Member

Choose a reason for hiding this comment

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

seems like "foobar" is not covered but should work as this is team "foo" and cluster "bar" in ec2 spilo way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jan-M which test do you have in mind? We do test with exactly 'foobar' as a clone cluster name for cloning from basebackup in line 66 of this patch.

Copy link
Member

@sdudoladov sdudoladov left a comment

Choose a reason for hiding this comment

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

👍

return "", fmt.Errorf("name cannot be longer than %d characters", clusterNameMaxLength)
}
if !serviceNameRegex.MatchString(clusterName) {
return "", fmt.Errorf("name must confirm to a valid service name (DNS-1035)")
Copy link
Member

Choose a reason for hiding this comment

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

RFC 1035 is a 50+ pages document. Can you please specify the section that provides overview of the naming conventions and thus the regexp ?

func validateCloneClusterDescription(clone *CloneDescription) error {
// when cloning from the basebackup (no end timestamp) check that the cluster name is a valid service name
if clone.ClusterName != "" && clone.EndTimestamp == "" {
if !serviceNameRegex.MatchString(clone.ClusterName) {
Copy link
Member

Choose a reason for hiding this comment

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

Do existing cluster clones always have names adhering to this format ? that should be enforced by k8s, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

} else if err := validateCloneClusterDescription(&tmp2.Spec.Clone); err != nil {
tmp2.Error = err
tmp2.Status = ClusterStatusInvalid
} else {
Copy link
Member

Choose a reason for hiding this comment

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

i feel the summary of this discussion is worth a comment here:

anyone able to deploy a manifest can clone from any cluster's backups, and thus read all the data in other clusters.

It pretty much depends on how different teams are separated on the infrastructure level;

i.e. it is outside of the operator scope to check this

@@ -76,6 +77,11 @@ const (
ClusterStatusInvalid PostgresStatus = "Invalid"
)

const (
serviceNameMaxLength = 63
Copy link
Member

Choose a reason for hiding this comment

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

is it required by k8s ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

continue
} else if tt.err != nil {
t.Errorf("Expected error: %v", tt.err)
Copy link
Member

Choose a reason for hiding this comment

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

and go no error, right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@alexeyklyukin
Copy link
Contributor Author

👍

1 similar comment
@sdudoladov
Copy link
Member

👍

@alexeyklyukin alexeyklyukin merged commit 4c8dfd7 into master May 3, 2018
@alexeyklyukin alexeyklyukin deleted the remove_clone_name_constraint branch May 3, 2018 08:21
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.

5 participants