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

Simplify the golang dependencies #77

Merged
merged 1 commit into from
Jun 30, 2023

Conversation

MarSik
Copy link
Member

@MarSik MarSik commented Jun 28, 2023

This removes the dependency on kubernetes/kubernetes repository and replaces it with:

  • bundled cpuset
  • kubernetes/kubelet (APIs only)

@openshift-ci openshift-ci bot requested review from ffromani and swatisehgal June 28, 2023 11:38
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 28, 2023
Copy link
Member

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

I'm OK with this direction in general. It's a (very very minimal) reimplementation of vendoring.
Can we:

  • isolate the copied deps in their own subtree? (pkg-k8s? imported? ) both cpuset and the podresources minimal client should sit in their own package (pkg-k8s/cpuset, pkg-k8s/podresources?)
  • clearly record (pkg-k8s/README.md? comment at the beginning of each file) which commit are we importing?

@@ -4,6 +4,13 @@ Copyright 2017 The Kubernetes Authors.
This was copied out of kubernetes source to avoid pulling too
many dependencies with the full kubernetes source code.

This is based on the following kubernetes file:

https://github.com/kubernetes/kubernetes/blob/release-1.26/pkg/kubelet/cm/cpuset/cpuset.go
Copy link
Member

@ffromani ffromani Jun 29, 2023

Choose a reason for hiding this comment

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

please comment (GH or better here) which sha1 was used (release-1.26 will always point to the tip of that branch)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point.

Copy link
Member

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

not what I thought but good enough it seems.
Please let's record the exact (sha1) imported version of cpuset and I think we can merge

Copy link
Member

@ffromani ffromani left a comment

Choose a reason for hiding this comment

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

/lgtm

/hold
to give time to @swatisehgal to review

@openshift-ci openshift-ci bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jun 29, 2023
Copy link
Contributor

@swatisehgal swatisehgal left a comment

Choose a reason for hiding this comment

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

Content wise looks good. Left a couple of comments (/questions).

In general, I think we can do better in organizing the commits here. Also, we should include the links to source in the commit messages.

I would suggest one of the following:

  1. Squash the two commits and add the links to the source code in the commit message in addition to reference in code comment (like we have currently).
  2. Split it into two separate commits one for cpuset and another one for podresources and add the corresponding links to original source code in the receptive commit message.

I tend to prefer the latter as it would provide more granularity.

// GetV1Client returns a client for the PodResourcesLister grpc service
// This was copied from kubelet sources as per the comment there:
//
// Quote:
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 add a reference to this quote?

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.

}

// GetAddressAndDialer returns the address parsed from the given endpoint and a context dialer.
func GetAddressAndDialer(endpoint string) (string, func(ctx context.Context, addr string) (net.Conn, error), error) {
Copy link
Contributor

@swatisehgal swatisehgal Jun 29, 2023

Choose a reason for hiding this comment

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

Why do we need this to be public? In case of kubelet source code this function was in util package so made sense to have it public but since in our case the consumer (GetV1Client) is in the same package making it private would make more sense to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

This removes the dependency on kubernetes/kubernetes
repository and replaces it with:

- bundled cpuset
  from https://github.com/kubernetes/kubernetes/blob/759e043136b249f9e19355d3b2c9261b3ac82a70/pkg/kubelet/cm/cpuset/cpuset.go
- bundled pod resources api client
  from https://github.com/kubernetes/kubernetes/blob/52457842d155743f0e3fc57ade87251cca37d375/pkg/kubelet/apis/podresources/client.go#L56
- kubernetes/kubelet (APIs only)

The bundled code is placed into the pkg/k8s_imported directory to
make it obvious where it is coming from.

The effect is a significant reduction of indirect dependencies
allowing easier consumption by other projects (like must gather).

Signed-off-by: Martin Sivak <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2023
@MarSik
Copy link
Member Author

MarSik commented Jun 29, 2023

@swatisehgal I decided to squash it into a single commit, because the justification is the same. I added both links to the original source code to the commit message though.

@ffromani
Copy link
Member

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 30, 2023
@MarSik
Copy link
Member Author

MarSik commented Jun 30, 2023

@ffromani @swatisehgal Thanks for the reviews, lgtm would be nice :)

Copy link
Contributor

@swatisehgal swatisehgal left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 30, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MarSik, swatisehgal

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:

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

@openshift-merge-robot openshift-merge-robot merged commit 034afde into openshift-kni:main Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants