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

add transport package with server implementation #4

Merged
merged 9 commits into from
Nov 19, 2021

Conversation

alaypatel07
Copy link
Contributor

@alaypatel07 alaypatel07 commented Nov 8, 2021

Describe what this PR does
This PR adds a transport interface along with the server implementation. This will be followed by accompanying client implementation.

Signed-off-by: Alay Patel <alay1431@gmail.com>
Signed-off-by: Alay Patel <alay1431@gmail.com>
Signed-off-by: Alay Patel <alay1431@gmail.com>
Signed-off-by: Alay Patel <alay1431@gmail.com>
transport/stunnel/server.go Show resolved Hide resolved
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
debug = 7
sslVersion = TLSv1.2
Copy link
Member

Choose a reason for hiding this comment

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

Why are we specifying 1.2 instead of 1.3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will update

socket = r:TCP_NODELAY=1
debug = 7
sslVersion = TLSv1.2
[rsync]
Copy link
Member

Choose a reason for hiding this comment

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

We should probably use a generic name here. The tunnel itself doesn't really have anything to do w/ rsync (even that's going to be its primary use).

transport/stunnel/server.go Outdated Show resolved Hide resolved
transport/stunnel/server.go Outdated Show resolved Hide resolved
transport/transport.go Show resolved Hide resolved

type Type string

func GenerateSSLCert() (*bytes.Buffer, *bytes.Buffer, *bytes.Buffer, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This function could use some docs or perhaps named return values. 3 different *bytes.Buffer is a bit unwieldy.

}

subj := pkix.Name{
CommonName: "backube.dev",
Copy link
Member

Choose a reason for hiding this comment

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

Does this require a domain name or can we just leave it at "backube"?


type Options struct {
Labels map[string]string
Owners []metav1.OwnerReference
Copy link
Member

Choose a reason for hiding this comment

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

I notice when this gets used, it is directly assigned to the object's field instead of going through something like https://github.com/kubernetes-sigs/controller-runtime/blob/5f8befe79888a4a8529cda7a82797bd57e188158/pkg/controller/controllerutil/controllerutil.go#L96 that validates the reference (i.e., owner scoping, same namespace, etc). Does this get validated elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#10

MarkForCleanup(ctx context.Context, c client.Client, key, value string) error
}

type Options struct {
Copy link
Member

Choose a reason for hiding this comment

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

If consumers are going to use this directly, the fields need docs

Copy link
Contributor Author

@alaypatel07 alaypatel07 left a comment

Choose a reason for hiding this comment

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

Responded to most of the comments. There are a few outstanding ones will work on addressing them as soon as possible. Thanks for the in-depth review.

transport/stunnel/server.go Show resolved Hide resolved
Comment on lines +31 to +32
key = /etc/stunnel/certs/tls.key
cert = /etc/stunnel/certs/tls.crt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will try PSK and let you know

}

func (s *server) prefixedName(name string) string {
return s.namespacedName.Name + "-server-" + name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

create an issue for tracking this across all the packages

transport/transport.go Show resolved Hide resolved
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed in the call, this is required because we'll have a client type soon, we agreed to keep it as of now.

Note: I am not a big fan of this either, but we agreed we have bigger fishes to fry :)

}

func (s *server) prefixedName(name string) string {
return s.namespacedName.Name + "-server-" + name
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#9


type Options struct {
Labels map[string]string
Owners []metav1.OwnerReference
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#10

@alaypatel07 alaypatel07 force-pushed the transport branch 2 times, most recently from a4275c4 to 2addf39 Compare November 13, 2021 00:55
alaypatel07 and others added 2 commits November 12, 2021 19:57
Signed-off-by: Alay Patel <alay1431@gmail.com>
Co-authored-by: John Strunk <jstrunk@redhat.com>
Signed-off-by: Alay Patel <alay1431@gmail.com>
Signed-off-by: Alay Patel <alay1431@gmail.com>
Signed-off-by: Alay Patel <alay1431@gmail.com>
…te MarkForCleanup

Signed-off-by: Alay Patel <alay1431@gmail.com>
Copy link
Member

@JohnStrunk JohnStrunk left a comment

Choose a reason for hiding this comment

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

/lgtm

Comment on lines +59 to +64
switch {
case k8serrors.IsNotFound(err):
return false, nil
case err != nil:
return false, err
}
Copy link
Member

Choose a reason for hiding this comment

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

I learned something today 🤓

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 19, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alaypatel07, JohnStrunk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JohnStrunk,alaypatel07]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the lgtm label Nov 19, 2021
@openshift-merge-robot openshift-merge-robot merged commit 25abd17 into backube:main Nov 19, 2021
@alaypatel07 alaypatel07 mentioned this pull request Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants