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 support for viewing and migrate Tiller releases #330

Merged
merged 11 commits into from
Jun 6, 2018

Conversation

andresmgot
Copy link
Contributor

@andresmgot andresmgot commented May 25, 2018

Add Tiller releases to the Applications view. Since for creating a HelmRelease from a Tiller release it is necessary to add new information (the chart repository URL and name) we have added a new form: MigrateForm.

Delete
</button>
</div>
{this.props.loading === true ? (
Copy link
Contributor Author

@andresmgot andresmgot May 25, 2018

Choose a reason for hiding this comment

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

this is needed to wait until the Tiller release is deleted, if not, after clicking "Delete" it goes directly to the Applications view and the deleted application is still there.


export class App {
public static async waitForDeletion(name: string) {
const timeout = 10000; // 10s
Copy link
Contributor

Choose a reason for hiding this comment

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

10s timeout is too short. Can we make is 30s or higher?

<button className="button button-danger" onClick={this.openModel}>
Delete
<button className="button" onClick={this.handleMigrateClick}>
Migrate
Copy link
Contributor

Choose a reason for hiding this comment

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

should we call this button Import App?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set this back to Migrate since there is now a banner that explains it in detail

@sameersbn
Copy link
Contributor

I encountered a major issue while testing this PR. I deployed the todos chart from /~https://github.com/bitnami-labs/redisdemo using the helm cli and attempted to migrate it to kubeapps. During the migration I selected stable as the repo (chart named todos DOES NOT EXIST in the stable repo). Kubeapps showed me an error and now the Applications tab shows me the Sorry! Something went wrong. message

@andresmgot
Copy link
Contributor Author

Right, I can do a validation to ensure that the chart and version are present in the repository chosen. There is still a chance that for example wordpress-v1.0.0 exists in two different repositories and the migration results in a different chart though. The user should be aware of that.

Copy link
Contributor

@prydonius prydonius left a comment

Choose a reason for hiding this comment

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

Great work on this @andresmgot.

Some thoughts about the UX. A button that just says "Import App"/"Migrate" isn't clear enough. I suggest adding a banner above the button to explain that the app is "unmanaged" and that importing it will allow you to manage (update/delete) it from Kubeapps.

I also suggest adding something to the cards in the AppList screen to indicate that the App is not fully imported. Perhaps an warning triangle icon or something could be useful here.

const roles = RequiredRBACRoles;
roles[0].verbs = ["create"];
switch (error && error.constructor) {
case MissingChart:
Copy link
Contributor

Choose a reason for hiding this comment

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

could we take people back to the migration form to fix this error?

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's the current behavior, if the chart exists the migration form print this error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay, missed that - thanks!

/>
</div>
<div>
<label htmlFor="tillerReleaseName">Release Name (Global)</label>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this will be confusing to users. IMO it would be better to take this opportunity to simplify the naming relationship between HelmRelease CRD and Tiller release name and just assume that both should be globally unique.

We could:

  1. Verify that no Tiller release name exists by checking the configmaps in the kubeapps namespace
  2. Make HelmRelease CRD un-namespaced so that it follows the same global name requirement as Tiller

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I agree it could be confusing. I would do 1. (or any other method that checks if a release already exists) more than 2. since this is something more specific to kubeapps.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I think you're right, it doesn't make sense to impose the restriction onto Helm CRD itself.

<p>
{" "}
* If the repository containing this chart is not in the list add it{" "}
<a href="/config/repos"> here </a>{" "}
Copy link
Contributor

Choose a reason for hiding this comment

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

add a full stop after.

We may want to make this an actual alert, or make this nicer with CSS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's quite visible right now but let me know if you have a specific suggestion

@andresmgot
Copy link
Contributor Author

Thank you for the review.

Some thoughts about the UX. A button that just says "Import App"/"Migrate" isn't clear enough. I suggest adding a banner above the button to explain that the app is "unmanaged" and that importing it will allow you to manage (update/delete) it from Kubeapps.

I can add that.

I also suggest adding something to the cards in the AppList screen to indicate that the App is not fully imported. Perhaps an warning triangle icon or something could be useful here.

I thought about that but I think it is not necessary, a warning would mean that something is wrong with the application or something that needs to be fixed. I don't think that's the case.


// Go through all HelmReleaseConfigMaps and parse as IApp objects
const apps = Object.keys(cms).map(key => this.parseRelease(helmReleaseMap[key], cms[key]));
const apps = Object.keys(cms).map(key => this.parseRelease(cms[key], helmReleaseMap[key]));
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to filter this list of apps by the namespace (if provided) using the namespace in the release data (app.data.namespace). Currently we are always showing all Tiller releases despite what namespace is selected. This also has the strange side-effect that a "migrated" app or one installed from the dashboard looks like an un-migrated app (missing HelmRelease CRD) when in a different namespace.

For example, in the default namespace, Redis looks like it hasn't been migrated (icon is missing).
screen shot 2018-05-30 at 16 48 37

In the "osba" namespace, it is correct:
screen shot 2018-05-30 at 16 49 44

With this fix, "redis" and "osba" should not appear at all when in the default namespace, and likewise "default-catalog" and "modest-shrimp" should not appear in the "osba" namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

<div className="container container-small text-c">
<p className="margin-t-small">
This release is not being managed by Kubeapps. To be able to upgrade or delete this
release <b> click in the button "Migrate" below </b>.
Copy link
Contributor

Choose a reason for hiding this comment

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

please use strong instead of b. Also, there is extra spacing on either side of the text that you should remove.

click in the button "Migrate" below -> click on the "Migrate" button below

<a href="/config/repos"> here </a>.{" "}
</p>
</div>
<div>
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove everything below this point. None of this is configurable (and doesn't need to be for importing an app). Let's keep this form simple.

BTW, a future improvement for this form would be to search for the chart and version across all the repos and display the possible charts from the different repos it could belong too. We should create an issue for this when this gets merged.

@prydonius
Copy link
Contributor

I thought about that but I think it is not necessary, a warning would mean that something is wrong with the application or something that needs to be fixed. I don't think that's the case.

Yes, you're right - we'd need to figure out a way to make it not appear like the app has an error. We can leave this for now and get advice from @Angelmmiguel later.

return Promise.all<IApp>(apps.map(async app => this.getChart(app)));
const apps = await Promise.all<IApp>(releases.map(rel => this.getChart(rel)));

if (namespace) {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's avoid some unnecessary API calls by moving this filter above the this.getChart fetching.

if (namespace) {
// Exclude releases that are not of this namespace
const nsApps = [] as IApp[];
apps.forEach(app => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Array.filter will be easier (no need to instantiate a new array and push) - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

Copy link
Contributor

@prydonius prydonius left a comment

Choose a reason for hiding this comment

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

One thing I noticed is that when migrating, the Tiller release gets updated two times. The controller outputs:

2018/06/05 23:54:03 Downloading repo https://kubernetes-charts.storage.googleapis.com/index.yaml index...
2018/06/05 23:54:04 Downloading https://kubernetes-charts.storage.googleapis.com/redis-3.3.5.tgz ...
2018/06/05 23:54:04 Updating release inky-orangutan
2018/06/05 23:54:04 Installed/updated release inky-orangutan
2018/06/05 23:54:04 Release status: DEPLOYED
2018/06/05 23:54:04 Downloading repo https://kubernetes-charts.storage.googleapis.com/index.yaml index...
2018/06/05 23:54:05 Downloading https://kubernetes-charts.storage.googleapis.com/redis-3.3.5.tgz ...
2018/06/05 23:54:05 Updating release inky-orangutan
2018/06/05 23:54:05 Installed/updated release inky-orangutan
2018/06/05 23:54:05 Release status: DEPLOYED

For whatever reason, it's upgrading the Tiller release twice even though the HelmRelease is only created once. Might be a small bug in the controller, I've created #345 to track this.

This lgtm, please feel free to merge.

@andresmgot
Copy link
Contributor Author

Thanks @sameersbn and @prydonius! I replied in the issue you have opened.

@andresmgot andresmgot merged commit b1c599a into vmware-tanzu:master Jun 6, 2018
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