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

add support for custom network provider (part A) #172

Merged
merged 10 commits into from
Sep 25, 2023

Conversation

Kuromesi
Copy link
Contributor

Ⅰ. Describe what this PR does

add support for custom network provider

Ⅱ. Does this pull request fix one issue?

Ⅲ. Special notes for reviews

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2023

Codecov Report

Merging #172 (1e53b77) into master (76d33b8) will increase coverage by 0.56%.
The diff coverage is 60.10%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master     #172      +/-   ##
==========================================
+ Coverage   43.87%   44.44%   +0.56%     
==========================================
  Files          50       51       +1     
  Lines        5374     5560     +186     
==========================================
+ Hits         2358     2471     +113     
- Misses       2618     2666      +48     
- Partials      398      423      +25     
Flag Coverage Δ
unittests 44.44% <60.10%> (+0.56%) ⬆️

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

Files Changed Coverage Δ
pkg/trafficrouting/manager.go 50.00% <0.00%> (-2.41%) ⬇️
...ollout/validating/rollout_create_update_handler.go 63.56% <0.00%> (ø)
...k/customNetworkProvider/custom_network_provider.go 63.63% <63.63%> (ø)
...roller/trafficrouting/trafficrouting_controller.go 50.52% <100.00%> (+0.52%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@Kuromesi Kuromesi force-pushed the traffic_1 branch 2 times, most recently from 1726d03 to 0e5bd2d Compare August 31, 2023 10:28
Signed-off-by: Kuromesi <[email protected]>
@@ -149,6 +151,12 @@ type TrafficRoutingList struct {
Items []TrafficRouting `json:"items"`
}

type CustomNetworkRef struct {
APIVersion string `json:"apiVersion,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

remove the omitempty, because apiversion, kind, name always be not empty.

@@ -0,0 +1,306 @@
/*
Copyright 2021.
Copy link
Member

Choose a reason for hiding this comment

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

Copyright 2023 The Kruise Authors.

klog.Errorf("failed to store custom network provider %s/%s", obj.GetKind(), obj.GetName())
return err
}
klog.Infof("store custom network provider %s/%s success", obj.GetKind(), obj.GetName())
Copy link
Member

Choose a reason for hiding this comment

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

store custom network provider(%s/%s) old configuration in annotations(%s) success, xx,xx,xx, OriginalSpecAnnotation.

@Kuromesi Kuromesi force-pushed the traffic_1 branch 3 times, most recently from 7259ecf to 16aacbb Compare September 11, 2023 17:05
Signed-off-by: Kuromesi <[email protected]>
Signed-off-by: Kuromesi <[email protected]>
Signed-off-by: Kuromesi <[email protected]>
return fmt.Errorf("failed to walk path: %s", err.Error())
}
dir := filepath.Dir(path)
if _, err := os.Stat(filepath.Join(dir, "testdata")); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

is testdata directory included in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

testdata and lua scripts are not included in this PR. This function aims to convert testdata into lua objects. When the user wants to debug their lua scripts, they could use this function to generate lua objects and copy the generated objects to their lua scripts for debugging.

@@ -0,0 +1,225 @@
package main
Copy link
Member

Choose a reason for hiding this comment

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

is this source file a UT? can we run it when building the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is more like a plugin to facilitate the development of Lua scripts.

newStatus.Phase = v1alpha1.TrafficRoutingPhaseHealthy
newStatus.Message = "TrafficRouting is Healthy"
newStatus.Phase = v1alpha1.TrafficRoutingPhaseInitial
newStatus.Message = "TrafficRouting is Initializing"
Copy link
Member

Choose a reason for hiding this comment

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

why changing routing to initializing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing the status to Healthy works fine for gateway and ingress since they only check if the resource exists when initializing, however, for custom network providers, the original configuration is stored in annotation in initialization, and the annotation will be removed after finalising, without this annotation, customController can't do EnsureRoutes(). So it is necessary to first initialize after finalising, or next time customController will not work.

@zmberg zmberg closed this Sep 19, 2023
@zmberg zmberg reopened this Sep 19, 2023
@@ -0,0 +1,337 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

mv the custom/custom.go to customNetworkProvider/custom_network_provider.go

@zmberg
Copy link
Member

zmberg commented Sep 25, 2023

/lgtm

@zmberg
Copy link
Member

zmberg commented Sep 25, 2023

/approve

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zmberg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot kruise-bot merged commit 57f9853 into openkruise:master Sep 25, 2023
17 checks passed
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.

5 participants