Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #391 from SUSE/helm-manifest-parse-warning
Browse files Browse the repository at this point in the history
Workload: Add warning if manifest parse contains errors
  • Loading branch information
richard-cox committed Jun 18, 2020
2 parents 9661690 + 282be2c commit 790a37f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Observable, Subject, Subscription } from 'rxjs';
import makeWebSocketObservable, { GetWebSocketResponses } from 'rxjs-websockets';
import { catchError, map, share, switchMap } from 'rxjs/operators';

import { HideSnackBar, ShowSnackBar } from '../../../../../../../store/src/actions/snackBar.actions';
import { AppState } from '../../../../../../../store/src/app-state';
import { entityCatalog } from '../../../../../../../store/src/entity-catalog/entity-catalog';
import { EntityRequestAction, WrapperRequestActionSuccess } from '../../../../../../../store/src/types/request.types';
Expand Down Expand Up @@ -142,6 +143,12 @@ export class HelmReleaseTabBaseComponent implements OnDestroy {
resources.endpointId,
);
this.addResource(releaseResourceAction, resources);
} else if (messageObj.kind === 'ManifestErrors') {
if (messageObj.data) {
this.store.dispatch(
new ShowSnackBar('Errors were found when parsing this workload. Not all resources may be shown', 'Dismiss')
);
}
}
}
});
Expand Down Expand Up @@ -189,5 +196,6 @@ export class HelmReleaseTabBaseComponent implements OnDestroy {

ngOnDestroy() {
this.sub.unsubscribe();
this.store.dispatch(new HideSnackBar());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export class GetHelmReleases implements MonocularPaginationAction {
};
}


export class GetHelmRelease implements HelmReleaseSingleEntity {
guid: string;
constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { UPDATE_HELM_RELEASE } from './workloads.actions';

const defaultState = {};

export function helmReleaseReducer(state: any = defaultState, action) {
export function helmReleaseReducer(state = defaultState, action) {
switch (action.type) {
case UPDATE_HELM_RELEASE:
return {
...state,
};

}
}
2 changes: 2 additions & 0 deletions src/jetstream/plugins/kubernetes/get_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ func (c *KubernetesSpecification) GetReleaseStatus(ec echo.Context) error {
graph.ParseManifest(rel)
sendResource(ws, "Graph", graph)

sendResource(ws, "ManifestErrors", rel.ManifestErrors)

stopchan := make(chan bool)

go readLoop(ws, stopchan)
Expand Down
13 changes: 8 additions & 5 deletions src/jetstream/plugins/kubernetes/helm/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ var resourcesWithoutStatus = map[string]bool{
// HelmRelease represents a Helm Release deployed via Helm
type HelmRelease struct {
*release.Release
Endpoint string `json:"-"`
User string `json:"-"`
Resources map[string]KubeResource `json:"resources"`
Jobs []KubeResourceJob `json:"-"`
PodJobs map[string]KubeResourceJob `json:"-"`
Endpoint string `json:"-"`
User string `json:"-"`
Resources map[string]KubeResource `json:"resources"`
Jobs []KubeResourceJob `json:"-"`
PodJobs map[string]KubeResourceJob `json:"-"`
ManifestErrors bool `json:"-"`
}

// KubeResource is a simple struct to pull out core common metadata for a Kube resource
Expand Down Expand Up @@ -69,6 +70,7 @@ func NewHelmRelease(info *release.Release, endpoint, user string) *HelmRelease {

// Parse the release manifest from the Helm release
func (r *HelmRelease) parseManifest() {
r.ManifestErrors = false
reader := bytes.NewReader([]byte(r.Manifest))
buffer := bufio.NewReader(reader)
var bufr strings.Builder
Expand All @@ -81,6 +83,7 @@ func (r *HelmRelease) parseManifest() {
obj, _, err := decode([]byte(bufr.String()), nil, nil)
if err != nil {
log.Error(fmt.Sprintf("Helm Manifest Parser: Error while decoding YAML object. Err was: %s", err))
r.ManifestErrors = true
} else {
r.processResource(obj)
}
Expand Down

0 comments on commit 790a37f

Please sign in to comment.