Skip to content

Commit 6d5d21c

Browse files
authored
Merge pull request #12238 from kahirokunn/improve-err-message
✨ clusterctl: clearer diagnostics when provider metadata is missing or repo URL is stale
2 parents 21b5516 + 2d11fe9 commit 6d5d21c

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

cmd/clusterctl/client/cluster/installer.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package cluster
1818

1919
import (
2020
"context"
21+
"fmt"
2122
"sort"
2223
"strings"
2324
"time"
@@ -307,9 +308,16 @@ func (i *providerInstaller) getProviderContract(ctx context.Context, providerIns
307308
return "", err
308309
}
309310

311+
// Fetch metadata for the requested provider version.
312+
// If we hit a 404 or similar error (e.g., the repository moved or the tag
313+
// lacks metadata), wrap the error with additional context so users can
314+
// quickly pinpoint the root cause.
310315
latestMetadata, err := providerRepository.Metadata(provider.Version).Get(ctx)
311316
if err != nil {
312-
return "", err
317+
return "", errors.Wrapf(err,
318+
"failed to fetch metadata for provider %q (version %s). "+
319+
"Check that the release tag exists and the repository URL is correct — the project may have moved or the tag may be missing metadata.yaml",
320+
provider.ManifestLabel(), provider.Version)
313321
}
314322

315323
// Gets the contract for the current release.
@@ -320,7 +328,23 @@ func (i *providerInstaller) getProviderContract(ctx context.Context, providerIns
320328

321329
releaseSeries := latestMetadata.GetReleaseSeriesForVersion(currentVersion)
322330
if releaseSeries == nil {
323-
return "", errors.Errorf("invalid provider metadata: version %s for the provider %s does not match any release series", provider.Version, provider.InstanceName())
331+
availableSeries := make([]string, 0, len(latestMetadata.ReleaseSeries))
332+
for _, series := range latestMetadata.ReleaseSeries {
333+
availableSeries = append(availableSeries, fmt.Sprintf("%d.%d", series.Major, series.Minor))
334+
}
335+
336+
var errorMsg string
337+
if len(availableSeries) > 0 {
338+
errorMsg = fmt.Sprintf("invalid provider metadata: version %s for the provider %s does not match any release series. "+
339+
"Available series: [%s]. This usually means the release tag lacks an updated metadata.yaml or the repository URL is stale.",
340+
provider.Version, provider.InstanceName(), strings.Join(availableSeries, ", "))
341+
} else {
342+
errorMsg = fmt.Sprintf("invalid provider metadata: version %s for the provider %s does not match any release series. No release series found in metadata. "+
343+
"The metadata.yaml file may be missing or the provider repository may be incorrect.",
344+
provider.Version, provider.InstanceName())
345+
}
346+
347+
return "", errors.New(errorMsg)
324348
}
325349

326350
compatibleContracts := i.getCompatibleContractVersions(i.currentContractVersion)

0 commit comments

Comments
 (0)