Skip to content

🐛 Fix: Handle empty chart directory correctly #289

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added cs-dev/cs-ci.yaml
Empty file.
19 changes: 18 additions & 1 deletion internal/controller/clusterstackrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,20 @@ func (r *ClusterStackReleaseReconciler) Reconcile(ctx context.Context, req recon
return reconcile.Result{Requeue: true}, nil
}

// Check for helm charts in the release assets. If they are not present, then something went wrong.
if err := releaseAssets.CheckHelmCharts(); err != nil {
msg := fmt.Sprintf("failed to validate helm charts: %s", err.Error())
conditions.MarkFalse(
clusterStackRelease,
csov1alpha1.ClusterStackReleaseAssetsReadyCondition,
csov1alpha1.IssueWithReleaseAssetsReason,
clusterv1.ConditionSeverityError,
"%s", msg,
)
record.Warn(clusterStackRelease, "ValidateHelmChartFailed", msg)
return reconcile.Result{}, nil
}

conditions.MarkTrue(clusterStackRelease, csov1alpha1.ClusterStackReleaseAssetsReadyCondition)

kubeClient := r.KubeClientFactory.NewClient(req.Namespace, r.RESTConfig)
Expand Down Expand Up @@ -304,7 +318,10 @@ func (r *ClusterStackReleaseReconciler) templateAndApply(ctx context.Context, re

// templateClusterClassHelmChart templates the clusterClass helm chart.
func (*ClusterStackReleaseReconciler) templateClusterClassHelmChart(releaseAssets *release.Release, name, namespace string) ([]byte, error) {
clusterClassChart := releaseAssets.ClusterClassChartPath()
clusterClassChart, e := releaseAssets.ClusterClassChartPath()
if e != nil {
return nil, fmt.Errorf("failed to template clusterClass helm chart: %w", e)
}

splittedName := strings.Split(name, clusterstack.Separator)
releaseName := strings.Join(splittedName[0:4], clusterstack.Separator)
Expand Down
15 changes: 5 additions & 10 deletions pkg/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func ensureMetadata(downloadPath, metadataFileName string) (Metadata, error) {
func (r *Release) CheckHelmCharts() error {
// check if the cluster class chart is present.
clusterClassChartName := r.clusterClassChartName()

clusterClassChartPath, err := r.helmChartNamePath(clusterClassChartName)
if err != nil {
return fmt.Errorf("failed to get cluster class chart path: %w", err)
Expand All @@ -172,12 +173,6 @@ func (r *Release) CheckHelmCharts() error {
if !os.IsNotExist(err) {
return fmt.Errorf("failed to verify the clusteraddon.yaml path %s with error: %w", clusterAddonPath, err)
}

// check if the cluster addon values file is present.
valuesPath := filepath.Join(r.LocalDownloadPath, ClusterAddonValuesName)
if _, err := os.Stat(valuesPath); err != nil {
return fmt.Errorf("failed to verify the cluster addon values path %s with error: %w", valuesPath, err)
}
}

// check if the cluster addon chart is present.
Expand Down Expand Up @@ -238,11 +233,11 @@ func (r *Release) clusterClassChartName() string {
}

// ClusterClassChartPath returns the absolute helm chart path for cluster class.
func (r *Release) ClusterClassChartPath() string {
func (r *Release) ClusterClassChartPath() (string, error) {
nameFilter := r.clusterClassChartName()
// we ignore the error here, since we already checked for the presence of the chart.
path, _ := r.helmChartNamePath(nameFilter)
return path

path, err := r.helmChartNamePath(nameFilter)
return path, err
}

// helmChartNamePath returns the helm chart name from the given path.
Expand Down
Loading