Skip to content

Avoid importing k8s.io/kubernetes from pkg/helm - #4499

Merged
bacongobbler merged 5 commits into
helm:masterfrom
databus23:k8s-dep
Sep 4, 2018
Merged

bacongobbler merged 5 commits into
helm:masterfrom
databus23:k8s-dep

Conversation

@databus23

@databus23 databus23 commented Aug 21, 2018 •

Copy link
Copy Markdown
Contributor

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and that blows up resulting binary sizes considerably.

Seems like this happen accidentally within the 2.10 development process.

We had something like this happen accidentally before: #2685

@thomastaylor312 thomastaylor312 added this to the 2.11.0 - Features milestone Aug 24, 2018
mumoshu added a commit to mumoshu/helm-diff that referenced this pull request Aug 27, 2018
Ran `glide update` and `glide install --strip-vendor`.
Added version specifications to k8s.io/apimachienery and k8s.io/apiserver according to helm's glide.lock https://github.com/helm/helm/blob/cc7cc1087f586f64d0b0d08aa516a003ced2d85b/glide.lock#L457 to prevent build errors.

The huge k8s.io/kubernetes dependency is introduced due to the upstream issue, helm/helm#4499.
It should be changed to our own fork, and the removed in the future once the upstream incorporates the fix.

Resolves databus23#81
mumoshu added a commit to mumoshu/helm-diff that referenced this pull request Aug 27, 2018
Ran `glide update` and `glide install --strip-vendor`.
Added version specifications to k8s.io/apimachienery and k8s.io/apiserver according to helm's glide.lock https://github.com/helm/helm/blob/cc7cc1087f586f64d0b0d08aa516a003ced2d85b/glide.lock#L457 to prevent build errors.

The huge k8s.io/kubernetes dependency is introduced due to the upstream issue, helm/helm#4499.
It should be changed to our own fork, and the removed in the future once the upstream incorporates the fix.

Resolves databus23#81
@novas0x2a

Copy link
Copy Markdown

Hm, copying error strings around seems somewhat risky. Perhaps a better fix would be to move the error wrappers to their own package that didn't import the rest of kube? You can leave an alias behind to avoid breaking working code.

@databus23

databus23 commented Aug 29, 2018 •

Copy link
Copy Markdown
Contributor Author

@novas0x2a Hmm, ok we could do that. Keep in mind that this is only used the FakeClient that is used for testing. This code is not used in the resulting helm or tiller binaries.

@bacongobbler

bacongobbler commented Sep 1, 2018 •

Copy link
Copy Markdown
Member

I agree with @novas0x2a's assertion; I don't like the thought of duplicating code to get around a library issue. I sympathize and understand the use case but duplicating code (and maintenance) doesn't sit well with me.

Any way we can move this to a separate package?

@databus23

Copy link
Copy Markdown
Contributor Author

@bacongobbler Sure. I updated the branch as requested.


var (
// ErrReleaseNotFound indicates that a release is not found.
ErrReleaseNotFound = func(release string) error { return fmt.Errorf("release: %q not found", release) }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we do a ErrReleaseNotFound = storageerrors.ErrReleaseNotFound? That way we won't break other users relying on this API.

diff --git a/pkg/storage/driver/driver.go b/pkg/storage/driver/driver.go
index 7ad28770..017468d6 100644
--- a/pkg/storage/driver/driver.go
+++ b/pkg/storage/driver/driver.go
@@ -17,9 +17,20 @@ limitations under the License.
 package driver // import "k8s.io/helm/pkg/storage/driver"

 import (
+       storageerrors "k8s.io/helm/pkg/storage/errors"
+
        rspb "k8s.io/helm/pkg/proto/hapi/release"
 )

+var (
+       // ErrReleaseNotFound has been deprecated; please use storageerrors.ErrReleaseNotFound instead.
+       ErrReleaseNotFound = storageerrors.ErrReleaseNotFound
+       // ErrReleaseExists has been deprecated; please use storageerrors.ErrReleaseExists instead.
+       ErrReleaseExists = storageerrors.ErrReleaseExists
+       // ErrInvalidKey has been deprecated; please use storageerrors.ErrInvalidKey instead.
+       ErrInvalidKey = storageerrors.ErrInvalidKey
+)
+
 // Creator is the interface that wraps the Create method.
 //
 // Create stores the release or returns ErrReleaseExists

@bacongobbler

Copy link
Copy Markdown
Member

Thanks @databus23! One last change and it looks good to go.

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to the k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and blow up binary sizes.

Signed-off-by: Fabian Ruff <[email protected]>
@databus23

Copy link
Copy Markdown
Contributor Author

@bacongobbler done

@bacongobbler bacongobbler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks!

@bacongobbler
bacongobbler merged commit 37a731d into helm:master Sep 4, 2018
databus23 added a commit to databus23/helm that referenced this pull request Sep 4, 2018
* Avoid importing k8s.io/kubernetes from pkg/helm

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to the k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and blow up binary sizes.

Signed-off-by: Fabian Ruff <[email protected]>

* Add references to pull request in errors message

Signed-off-by: Fabian Ruff <[email protected]>

* copy helper function from pkg/storage/driver

Signed-off-by: Fabian Ruff <[email protected]>

* Move storage errors to seperate package

Signed-off-by: Fabian Ruff <[email protected]>

* Keep old  error variables for backward compatibility

Signed-off-by: Fabian Ruff <[email protected]>

# Conflicts:
#	cmd/helm/upgrade.go
#	pkg/helm/fake.go
splisson pushed a commit to splisson/helm that referenced this pull request Dec 6, 2018
* Avoid importing k8s.io/kubernetes from pkg/helm

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to the k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and blow up binary sizes.

Signed-off-by: Fabian Ruff <[email protected]>

* Add references to pull request in errors message

Signed-off-by: Fabian Ruff <[email protected]>

* copy helper function from pkg/storage/driver

Signed-off-by: Fabian Ruff <[email protected]>

* Move storage errors to seperate package

Signed-off-by: Fabian Ruff <[email protected]>

* Keep old  error variables for backward compatibility

Signed-off-by: Fabian Ruff <[email protected]>
Signed-off-by: Sebastien Plisson <[email protected]>
splisson pushed a commit to splisson/helm that referenced this pull request Dec 6, 2018
* Avoid importing k8s.io/kubernetes from pkg/helm

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to the k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and blow up binary sizes.

Signed-off-by: Fabian Ruff <[email protected]>

* Add references to pull request in errors message

Signed-off-by: Fabian Ruff <[email protected]>

* copy helper function from pkg/storage/driver

Signed-off-by: Fabian Ruff <[email protected]>

* Move storage errors to seperate package

Signed-off-by: Fabian Ruff <[email protected]>

* Keep old  error variables for backward compatibility

Signed-off-by: Fabian Ruff <[email protected]>
Signed-off-by: Sebastien Plisson <[email protected]>
splisson pushed a commit to splisson/helm that referenced this pull request Dec 6, 2018
* Avoid importing k8s.io/kubernetes from pkg/helm

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to the k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and blow up binary sizes.

Signed-off-by: Fabian Ruff <[email protected]>

* Add references to pull request in errors message

Signed-off-by: Fabian Ruff <[email protected]>

* copy helper function from pkg/storage/driver

Signed-off-by: Fabian Ruff <[email protected]>

* Move storage errors to seperate package

Signed-off-by: Fabian Ruff <[email protected]>

* Keep old  error variables for backward compatibility

Signed-off-by: Fabian Ruff <[email protected]>
splisson pushed a commit to splisson/helm that referenced this pull request Dec 6, 2018
* Avoid importing k8s.io/kubernetes from pkg/helm

When writing a helm client (e.g. a helm plugin) that talks to tiller importing k8s.io/helm/pkg/helm to get the grpc client is key.
This pkg should not have a dependency to the k8s.io/kubernetes to avoid pulling in a lot of code that is only used within tiller and blow up binary sizes.

Signed-off-by: Fabian Ruff <[email protected]>

* Add references to pull request in errors message

Signed-off-by: Fabian Ruff <[email protected]>

* copy helper function from pkg/storage/driver

Signed-off-by: Fabian Ruff <[email protected]>

* Move storage errors to seperate package

Signed-off-by: Fabian Ruff <[email protected]>

* Keep old  error variables for backward compatibility

Signed-off-by: Fabian Ruff <[email protected]>
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.

4 participants