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

Implement DetermineStrategy with SDK #5671

Merged
merged 3 commits into from
Mar 17, 2025

Conversation

ffjlabo
Copy link
Member

@ffjlabo ffjlabo commented Mar 17, 2025

What this PR does:

I implemented k8s DetermineStrategy by using SDK.

Why we need it:

We want to implement plugins with SDK.

Which issue(s) this PR fixes:

Part of #4980 #5006

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):

ffjlabo added 2 commits March 17, 2025 11:31
Signed-off-by: Yoshiki Fujikane <[email protected]>
@ffjlabo ffjlabo changed the title Implement determine strategy with SDK Implement DetermineStrategy with SDK Mar 17, 2025
// FIXME
func (p *Plugin) DetermineStrategy(context.Context, *sdk.ConfigNone, *sdk.Client, *sdk.DetermineStrategyInput) (*sdk.DetermineStrategyResponse, error) {
return &sdk.DetermineStrategyResponse{}, nil
func (p *Plugin) DetermineStrategy(ctx context.Context, _ *sdk.ConfigNone, _ *sdk.Client, input *sdk.DetermineStrategyInput) (*sdk.DetermineStrategyResponse, error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

reference implementation:

func (a *DeploymentService) DetermineStrategy(ctx context.Context, request *deployment.DetermineStrategyRequest) (*deployment.DetermineStrategyResponse, error) {
cfg, err := config.DecodeYAML[*kubeconfig.KubernetesApplicationSpec](request.GetInput().GetTargetDeploymentSource().GetApplicationConfig())
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
runnings, err := a.loadManifests(ctx, request.GetInput().GetDeployment(), cfg.Spec, request.GetInput().GetRunningDeploymentSource())
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
targets, err := a.loadManifests(ctx, request.GetInput().GetDeployment(), cfg.Spec, request.GetInput().GetTargetDeploymentSource())
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
strategy, summary := determineStrategy(runnings, targets, cfg.Spec.Workloads, a.logger)
return &deployment.DetermineStrategyResponse{
SyncStrategy: strategy,
Summary: summary,
}, nil
}

Signed-off-by: Yoshiki Fujikane <[email protected]>
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

Attention: Patch coverage is 0% with 37 lines in your changes missing coverage. Please review.

Project coverage is 25.56%. Comparing base (5ce218d) to head (297642b).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...app/pipedv1/plugin/kubernetes/deployment/plugin.go 0.00% 27 Missing ⚠️
.../pipedv1/plugin/kubernetes/deployment/determine.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5671      +/-   ##
==========================================
- Coverage   25.57%   25.56%   -0.02%     
==========================================
  Files         478      478              
  Lines       51240    51277      +37     
==========================================
+ Hits        13105    13107       +2     
- Misses      37130    37165      +35     
  Partials     1005     1005              

☔ 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.

@ffjlabo ffjlabo marked this pull request as ready for review March 17, 2025 02:50
Copy link
Contributor

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

Let's try!
After merging this, let's refactor determineStrategy with no use of types from the model package.

@ffjlabo ffjlabo merged commit 38a0086 into master Mar 17, 2025
16 of 18 checks passed
@ffjlabo ffjlabo deleted the implement-DetermineStrategy-with-SDK branch March 17, 2025 03:15
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