Skip to content

[planpreview] Fix to avoid nil panic when executing plan preview#6224

Merged
khanhtc1202 merged 1 commit into
masterfrom
fix-plan-preview-piped-side
Sep 12, 2025
Merged

[planpreview] Fix to avoid nil panic when executing plan preview#6224
khanhtc1202 merged 1 commit into
masterfrom
fix-plan-preview-piped-side

Conversation

@ffjlabo
Copy link
Copy Markdown
Member

@ffjlabo ffjlabo commented Sep 12, 2025

What this PR does:

as title.

Fixed four points

  • set the value for named return variable result
  • abort nil runningDS when execting determineStrategy
  • pass runningDS as nil to plugin side
  • init PlanPreviewServiceClient

Why we need it:

We want to make plan preview work in pipedv1.

Which issue(s) this PR fixes:

Follow #6221

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
@ffjlabo ffjlabo requested a review from a team as a code owner September 12, 2025 10:59
Copy link
Copy Markdown
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

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

👌

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 12, 2025

Codecov Report

❌ Patch coverage is 0% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.77%. Comparing base (8ef80a6) to head (442906b).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
pkg/app/pipedv1/planpreview/builder.go 0.00% 46 Missing ⚠️
pkg/plugin/api/v1alpha1/client.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6224      +/-   ##
==========================================
- Coverage   28.77%   28.77%   -0.01%     
==========================================
  Files         559      559              
  Lines       59553    59565      +12     
==========================================
  Hits        17138    17138              
- Misses      41100    41112      +12     
  Partials     1315     1315              
Flag Coverage Δ
. 23.23% <0.00%> (-0.01%) ⬇️
.-pkg-app-pipedv1-plugin-analysis 32.64% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes 60.24% <ø> (ø)
.-pkg-app-pipedv1-plugin-kubernetes_multicluster 67.48% <ø> (ø)
.-pkg-app-pipedv1-plugin-scriptrun 54.83% <ø> (ø)
.-pkg-app-pipedv1-plugin-terraform 39.49% <ø> (ø)
.-pkg-app-pipedv1-plugin-wait 35.51% <ø> (ø)
.-pkg-app-pipedv1-plugin-waitapproval 55.73% <ø> (ø)
.-pkg-plugin-sdk 50.47% <ø> (ø)
.-tool-actions-gh-release 19.23% <ø> (ø)
.-tool-actions-plan-preview 25.51% <ø> (ø)
.-tool-codegen-protoc-gen-auth 0.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

logger.Info("will decide sync strategy for an application")

r := model.MakeApplicationPlanPreviewResult(*app)
result = model.MakeApplicationPlanPreviewResult(*app)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

set the value for named return variable result

Comment on lines +382 to +398
var (
runningDS *deploysource.DeploySource
err error
)
runningDS, err := runningDSP.Get(ctx, io.Discard)
if err != nil {
return model.SyncStrategy_PIPELINE, fmt.Sprintf("failed to get the running deploy source, %v", err)

if preCommit != "" {
runningDSP := deploysource.NewProvider(
b.workingDir,
deploysource.NewLocalSourceCloner(repo, "running", preCommit),
app.GitPath,
b.secretDecrypter,
)
runningDS, err = runningDSP.Get(ctx, io.Discard)
if err != nil {
return model.SyncStrategy_PIPELINE, fmt.Sprintf("failed to get the running deploy source, %v", err)
}
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

abort nil runningDS when execting determineStrategy

Comment on lines +402 to +404
var pRds *common.DeploymentSource
if runningDS != nil {
pRds = runningDS.ToPluginDeploySource()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

pass runningDS as nil to plugin side

name: name,
DeploymentServiceClient: deployment.NewDeploymentServiceClient(conn),
LivestateServiceClient: livestate.NewLivestateServiceClient(conn),
PlanPreviewServiceClient: planpreview.NewPlanPreviewServiceClient(conn),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

init PlanPreviewServiceClient

@khanhtc1202 khanhtc1202 merged commit 22d2c79 into master Sep 12, 2025
43 of 45 checks passed
@khanhtc1202 khanhtc1202 deleted the fix-plan-preview-piped-side branch September 12, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants