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 Buildah as an alternative container image build tool #559

Merged
merged 3 commits into from
Jun 12, 2019

Conversation

azatsarynnyy
Copy link

In this PR I propose to add Buildah support as an alternative container image build tool that is used for basic image operations by Kubernetes: Run and Kubernetes: Debug commands.

By default, Docker is used. And if the user prefers using Buildah it can be enabled with preferBuildah configuration.

@msftclas
Copy link

msftclas commented Jun 5, 2019

CLA assistant check
All CLA requirements met.

@azatsarynnyy
Copy link
Author

cc @gorkem

Copy link
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

This is a really nice feature and I like the way you've done it. I'm afraid I do have a few nitpicks - we definitely need to address the config design, and it would be great if we could have a think about how we detect whether to fall back to Docker, but that's not so crucial. Thanks for the PR!

package.json Outdated
@@ -231,6 +231,10 @@
"resource-commands-on-files": {
"type": "boolean",
"description": "If true, show Kubernetes resource commands on file context menu for all YAML files"
},
"preferBuildah": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: suggest adding a default for this in the defaults section

}

/** Currently used image build tool. */
export let currentBuildTool: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Prefer not to export a mutable variable. If other modules need it then maybe export a function that returns it?

export let currentBuildTool: string;

/** Starts listening changing the preferred build tool. */
export function start(): vscode.Disposable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What would be the cost of just looking up the config entry each time, instead of having a mutable variable and an event listener? We do this throughout the extension and it feels simpler and doesn't seem to cause performance problems (he said cautiously, acutely aware that we do have performance problems).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, it's because it's not just looking in config, it's also checking if buildah is present. And we definitely don't want to do that every time!

Copy link
Collaborator

Choose a reason for hiding this comment

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

For most tools we defer detection until the user tries to use the tool. I think we check for kubectl on startup but that is just to warn - we don't rely on it for a setting. We also have existing mechanisms for checking if a binary is present (see e.g. binutil.ts) which might be faster than calling the executable.


/** Starts listening changing the preferred build tool. */
export function start(): vscode.Disposable {
detectCurrentBuildTool();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes me anxious... in practice it should never be an issue, but in theory detectCurrentBuildTool could take a long time to run on extension startup, and so currentBuildTool could be accessed before it had been set.

package.json Outdated
@@ -231,6 +231,10 @@
"resource-commands-on-files": {
"type": "boolean",
"description": "If true, show Kubernetes resource commands on file context menu for all YAML files"
},
"preferBuildah": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure this is the right design here - what if someone comes along with a PR to support another build tool, say img? How would we manage the interaction between preferBuildah and a hypothetical preferImg?

Suggest instead a preferredImageBuildTool with an enum that restricts it to be Docker or Buildah (cf. the kubectlVersioning config setting).

import { getPreferBuildah } from '../components/config/config';
import { shell } from '../shell';

interface ContainerImageBuildTool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like the way you've done this - should make it easy if people want to add other build tools in future.

@azatsarynnyy
Copy link
Author

Hello @itowlson, thank you for your review!
I've addressed all your notes and updated the PR:

  • reworked the config design to the list of the possible tools;
  • replaced a tool detection on the extension start with the existing mechanisms provided by binutil.ts.

Copy link
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

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

Looks good - thanks @azatsarynnyy!

@itowlson
Copy link
Collaborator

Could you check the status of your CLA and sign if you haven't already done so please? Unfortunately we can't take this PR without a CLA.

#559 (comment)

@itowlson itowlson merged commit fbd9005 into vscode-kubernetes-tools:master Jun 12, 2019
@azatsarynnyy azatsarynnyy deleted the buildah branch June 12, 2019 21:15
@itowlson
Copy link
Collaborator

Thank you @azatsarynnyy for the CLA sign-off - we have lift-off!

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.

3 participants