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

Improve readiness diagnotics messages #680

Merged
merged 1 commit into from
May 2, 2024
Merged
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
14 changes: 9 additions & 5 deletions internal/provider/resource_bootstrap_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,10 @@ func (r *bootstrapGitResource) Read(ctx context.Context, req resource.ReadReques
if err != nil {
warnDetails = err.Error()
}
resp.Diagnostics.AddWarning("Flux controllers are not healthy and will be redeployed", warnDetails)
resp.Diagnostics.AddWarning(
fmt.Sprintf("Flux resources GitRepository and Kustomization in %s namespace are not ready and Flux will be redeployed", data.Namespace.ValueString()),
warnDetails,
)
}

mapValue, diags := types.MapValueFrom(ctx, types.StringType, repositoryFiles)
Expand Down Expand Up @@ -1168,17 +1171,18 @@ func isKubernetesReady(ctx context.Context, kubeClient client.Client) error {

// isFluxReady checks if the Flux sync objects are present and ready.
func isFluxReady(ctx context.Context, kubeClient client.Client, data bootstrapGitResourceData) (bool, error) {
ns := data.Namespace.ValueString()
syncName := apitypes.NamespacedName{
Namespace: data.Namespace.ValueString(),
Name: data.Namespace.ValueString(),
Namespace: ns,
Name: ns,
}

rootSource := &sourcev1.GitRepository{}
if err := kubeClient.Get(ctx, syncName, rootSource); err != nil {
return false, err
}
if conditions.IsFalse(rootSource, meta.ReadyCondition) {
return false, errors.New(conditions.GetMessage(rootSource, meta.ReadyCondition))
return false, fmt.Errorf("GitRepository/%s: %s", ns, conditions.GetMessage(rootSource, meta.ReadyCondition))
}

rootSync := &kustomizev1.Kustomization{}
Expand All @@ -1187,7 +1191,7 @@ func isFluxReady(ctx context.Context, kubeClient client.Client, data bootstrapGi
}
if conditions.IsFalse(rootSync, meta.ReadyCondition) {
conditions.GetMessage(rootSync, meta.ReadyCondition)
return false, errors.New(conditions.GetMessage(rootSync, meta.ReadyCondition))
return false, fmt.Errorf("Kustomization/%s: %s", ns, conditions.GetMessage(rootSync, meta.ReadyCondition))
}

return true, nil
Expand Down
Loading