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

feat: move yurt-device-controller into yurt-manager #1607

Merged
merged 7 commits into from
Aug 9, 2023

Conversation

wangxye
Copy link
Member

@wangxye wangxye commented Jul 11, 2023

What type of PR is this?

/kind feature
/sig iot

What this PR does / why we need it:

This PR integrates the yurt-device-controller for iot into the yurt manager. Users can deploy it using PlatformAdmin.

Which issue(s) this PR fixes:

Fixes #1580

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

@openyurt-bot openyurt-bot added do-not-merge/work-in-progress do-not-merge/work-in-progress kind/feature kind/feature labels Jul 11, 2023
@openyurt-bot openyurt-bot added the sig/iot sig/iot label Jul 11, 2023
@openyurt-bot openyurt-bot requested a review from Fei-Guo July 11, 2023 13:27
@openyurt-bot
Copy link
Collaborator

Welcome @wangxye! It looks like this is your first PR to openyurtio/openyurt 🎉

@wangxye wangxye marked this pull request as ready for review July 12, 2023 02:52
@openyurt-bot openyurt-bot removed the do-not-merge/work-in-progress do-not-merge/work-in-progress label Jul 12, 2023
@LavenderQAQ
Copy link
Member

/assign @LavenderQAQ

Copy link
Member

@LavenderQAQ LavenderQAQ left a comment

Choose a reason for hiding this comment

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

IoT-sig finally decided to change yurt-device-controller to yurt-iot-dock (YurtIoTDock), please revise it.

Namespace: "default",
CoreDataAddr: "edgex-core-data:59880",
CoreMetadataAddr: "edgex-core-metadata:59881",
CoreCommandAddr: "edgex-core-command:59882",
Copy link
Member

Choose a reason for hiding this comment

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

We need to keep these parameters in sync with the configuration in PlatformAdmin in the future, could you open an issue to track this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Of course, I will continue to track and extend the yurt-iot-dock using the ability to customize configurations in PlatformAdmin.

)

const (
DeviceFinalizer = "iot.device.finalizer"
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be better to change this to "iot.openyurt.io/device".

)

const (
DeviceProfileFinalizer = "iot.deviceProfile.finalizer"
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be better to change this to "iot.openyurt.io/deviceprofile".

)

const (
DeviceServiceFinalizer = "iot.deviceService.finalizer"
Copy link
Member

Choose a reason for hiding this comment

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

I think it might be better to change this to "iot.openyurt.io/deviceservice".

return nil, err
}
// YurtIoTCarrier doesn't need a service yet
yurtIoTCarrierConfig := map[string]interface{}{
Copy link
Member

Choose a reason for hiding this comment

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

Here don't use the map[string]interface, please use appsv1.DeploymentSpec and appsv1alpha1.YurtAppSet.

err = json.Unmarshal([]byte(yurtIoTCarrierConfigBytes), &yurtIoTCarrierDeployment)
if err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

The serialization and deserialization here looks a little redundant.

@@ -600,3 +611,111 @@ func annotationToComponent(annotation map[string]string) ([]*config.Component, e

return components, nil
}

func NewYurtIoTCarrierComponent(platformAdmin *iotv1alpha2.PlatformAdmin) (*config.Component, error) {
Copy link
Member

Choose a reason for hiding this comment

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

The build method can be considered as an internal function, and the build Deployment process can be placed in the util package.

Copy link
Member

Choose a reason for hiding this comment

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

This function is still needed, but keep it as simple as possible.


const IotCtrlName = "yurt-iot-carrier"

func DefaultVersion(platformAdmin *iotv1alpha2.PlatformAdmin) (string, string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

You can set it as an internal function to put the component building process into util as well.

package controllers

const (
EdgeXObjectName = "device-controller/edgex-object.name"
Copy link
Member

Choose a reason for hiding this comment

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

Please update this label.

@@ -226,6 +226,12 @@ func (r *ReconcilePlatformAdmin) reconcileDelete(ctx context.Context, platformAd
}
desiredComponents = append(desiredComponents, additionalComponents...)

yurtIotDock, err := util.NewYurtIoTDockComponent(platformAdmin)
Copy link
Member

Choose a reason for hiding this comment

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

Rebase may be required here after #1596 is combined.

Copy link
Member

@LavenderQAQ LavenderQAQ left a comment

Choose a reason for hiding this comment

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

The current code looks fine. There may be some changes here after #1596 is merged, you could wait a while to rebase. I will review and test it again after rebase.

@LavenderQAQ
Copy link
Member

/hold

@openyurt-bot openyurt-bot added the do-not-merge/hold do-not-merge/hold label Jul 14, 2023
@LavenderQAQ
Copy link
Member

@wangxye #1596 has been merged, please use /unhold to unlock this pr after rebase.

wangxye added 6 commits July 17, 2023 20:37
Signed-off-by: wangxye <1031989637@qq.com>
Signed-off-by: wangxye <1031989637@qq.com>
Signed-off-by: wangxye <1031989637@qq.com>
Signed-off-by: wangxye <1031989637@qq.com>
@wangxye
Copy link
Member Author

wangxye commented Jul 17, 2023

/unhold

1 similar comment
@LavenderQAQ
Copy link
Member

/unhold

@openyurt-bot openyurt-bot removed the do-not-merge/hold do-not-merge/hold label Jul 18, 2023
@LavenderQAQ
Copy link
Member

@wangxye #1626 could be resolved after this pr merged.

Containers: []corev1.Container{
{
Name: "yurt-iot-dock",
Image: fmt.Sprintf("leoabyss/yurt-iot-dock:%s", ver),
Copy link
Member

Choose a reason for hiding this comment

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

It would be better to replace "leoabyss" with "openyurt" to make it more appropriate.

return iotv1alpha1.Device{
ObjectMeta: metav1.ObjectMeta{
Name: toKubeName(ed.Name),
Namespace: "default",
Copy link
Member

Choose a reason for hiding this comment

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

Would it be more appropriate to set the namespace here to match that of yurt-iot-dock?

return iotv1alpha1.DeviceService{
ObjectMeta: metav1.ObjectMeta{
Name: toKubeName(ds.Name),
Namespace: "default",
Copy link
Member

Choose a reason for hiding this comment

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

the same

return iotv1alpha1.DeviceProfile{
ObjectMeta: metav1.ObjectMeta{
Name: toKubeName(dp.Name),
Namespace: "default",
Copy link
Member

Choose a reason for hiding this comment

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

the same

Copy link
Member

@Rui-Gan Rui-Gan left a comment

Choose a reason for hiding this comment

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

some suggestions

Signed-off-by: wangxye <1031989637@qq.com>
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 3 Security Hotspots
Code Smell A 25 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

Copy link
Member

@LavenderQAQ LavenderQAQ left a comment

Choose a reason for hiding this comment

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

/lgtm

@openyurt-bot
Copy link
Collaborator

@LavenderQAQ: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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.

@LavenderQAQ
Copy link
Member

@rambohe-ch This pr involves some CI changes (adding a new image build process for YurtIoTDock), needs to test the workflow.

@LavenderQAQ
Copy link
Member

@rambohe-ch We found some problems with YurtIoTDock and have been tracking them in #1626 and #1627. Since these are subsequent enhancements, @wangxye will submit two more pr to address these issues.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #1607 (10835d3) into master (fe46a9d) will increase coverage by 0.70%.
Report is 3 commits behind head on master.
The diff coverage is 63.79%.

@@            Coverage Diff             @@
##           master    #1607      +/-   ##
==========================================
+ Coverage   51.43%   52.13%   +0.70%     
==========================================
  Files         134      142       +8     
  Lines       15947    16911     +964     
==========================================
+ Hits         8202     8817     +615     
- Misses       7000     7273     +273     
- Partials      745      821      +76     
Flag Coverage Δ
unittests 52.13% <63.79%> (+0.70%) ⬆️

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

Files Changed Coverage Δ
pkg/yurtiotdock/controllers/util/conditions.go 0.00% <0.00%> (ø)
pkg/yurtiotdock/controllers/util/fieldindexer.go 0.00% <0.00%> (ø)
pkg/yurtiotdock/controllers/util/tools.go 42.59% <42.59%> (ø)
...dock/clients/edgex-foundry/deviceservice_client.go 56.07% <56.07%> (ø)
...yurtiotdock/clients/edgex-foundry/device_client.go 56.41% <56.41%> (ø)
...dock/clients/edgex-foundry/deviceprofile_client.go 56.81% <56.81%> (ø)
pkg/yurtiotdock/clients/edgex-foundry/util.go 92.19% <92.19%> (ø)
pkg/yurtiotdock/controllers/util/string.go 100.00% <100.00%> (ø)

@openyurt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LavenderQAQ, rambohe-ch, wangxye

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

@openyurt-bot openyurt-bot added the approved approved label Aug 9, 2023
@rambohe-ch
Copy link
Member

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] Move yurt-device-controller into yurt-manager
5 participants