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

bugfix: device model sync #5065

Merged
merged 1 commit into from Nov 28, 2023
Merged

Conversation

cl2017
Copy link
Contributor

@cl2017 cl2017 commented Oct 10, 2023

What type of PR is this?
/kind bug

What this PR does / why we need it:
bugfix: device model sync.
When added or deleted device, need to determine whether the device model needs to be sync to edgecore.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@kubeedge-bot kubeedge-bot added kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 10, 2023
Copy link
Member

@fisherxu fisherxu left a comment

Choose a reason for hiding this comment

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

/assign @wbc6080

@kubeedge-bot
Copy link
Collaborator

@fisherxu: GitHub didn't allow me to assign the following users: wbc6080.

Note that only kubeedge members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @wbc6080

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@WillardHu
Copy link
Contributor

Please make the pipeline requested checks successful

Signed-off-by: cl2017 <chenlin.liu@daocloud.io>
if deviceItem.Spec.NodeName == "" {
return true
}
if deviceItem.Spec.NodeName == targetNode && deviceItem.Spec.DeviceModelRef.Name == modelName {
Copy link
Member

Choose a reason for hiding this comment

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

Because the device info has been added to deviceMap at L125, so this range will always compare will itself, and set res to true? @cl2017

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Because the device info has been added to deviceMap at L125, so this range will always compare will itself, and set res to true? @cl2017

This logic seems to expect that the same device model will be reused at the same node, right? @cl2017
So the res is not always true, it returns a false value when the device model first binds the node.

Copy link
Contributor

Choose a reason for hiding this comment

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

In L179, If the currently index device in the map is the device just added to the map, we will directly skip the check of this index device. Therefore, this range will not be affected. Is it right? @cl2017

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the device info has been added to deviceMap at L125, so this range will always compare will itself, and set res to true? @cl2017

This logic seems to expect that the same device model will be reused at the same node, right? @cl2017 So the res is not always true, it returns a false value when the device model first binds the node.

Yes, this function is used to find wether the same devicemodel already exists at the targetNode.
At this fuction, we use res variable as a result, rather than the return value in Range method, return true means continue Range function.
@fisherxu @WillardHu @wbc6080

Copy link
Member

Choose a reason for hiding this comment

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

In L179, If the currently index device in the map is the device just added to the map, we will directly skip the check of this index device. Therefore, this range will not be affected. Is it right? @cl2017

Make sense, if device name == k, it means this is itself. Then return. Right? @wbc6080

And another question, only compare name maybe not enough, it can be same with device in another namespace.. ptal @cl2017

Copy link
Contributor

Choose a reason for hiding this comment

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

Well,this is indeed a problem. I also ignored that device instance and device model are namespace level resources.This may also cause another problem. If two namespaces have a model with the same name, the model in namespace B may interfere with the model referenced by the device in namespace A during range. @fisherxu @cl2017

Copy link
Member

@fisherxu fisherxu Nov 28, 2023

Choose a reason for hiding this comment

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

I think we can fix the device namespace in follow-up PRs, and could you please open an issue to track it? @wbc6080 @cl2017

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I will open an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can fix the device name in follow-up PRs, and could you please open an issue to track it? @wbc6080 @cl2017

Yes, most device code has not considered the possible problems caused by different namespaces.
Let's open an issue, tracking and resolve these problems together.

Copy link
Member

@fisherxu fisherxu left a comment

Choose a reason for hiding this comment

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

/approve
Leave final review for @WillardHu @wbc6080

@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fisherxu

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

@kubeedge-bot kubeedge-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 28, 2023
@WillardHu
Copy link
Contributor

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 28, 2023
@kubeedge-bot kubeedge-bot merged commit d4e6644 into kubeedge:master Nov 28, 2023
31 of 33 checks passed
@wbc6080
Copy link
Contributor

wbc6080 commented Nov 28, 2023

I have open an issue with #5220 and cherry pick to release-1.15 with #5221 @cl2017 @WillardHu @fisherxu

kubeedge-bot added a commit that referenced this pull request Nov 28, 2023
…upstream-release-1.15

Automated cherry pick of #5065: bugfix: device model sync
@cl2017 cl2017 deleted the fix_modelsync branch November 30, 2023 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants