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

aggregate desc status to subscription and workload #360

Merged
merged 1 commit into from
Jul 7, 2022

Conversation

aven-ai
Copy link
Contributor

@aven-ai aven-ai commented May 31, 2022

What type of PR is this?

Kind/feature

What this PR does / why we need it:

aggregate desc status to subscription and workload

Which issue(s) this PR fixes:

Fixes

Special notes for your reviewer:

@aven-ai aven-ai requested review from a team as code owners May 31, 2022 10:19
@aven-ai aven-ai requested a review from dixudx May 31, 2022 10:19
@dixudx dixudx added this to the v0.11.0 milestone May 31, 2022
@dixudx dixudx added the kind/feature New feature or request label May 31, 2022
@aven-ai aven-ai requested a review from a team as a code owner June 11, 2022 10:02
@codecov-commenter
Copy link

codecov-commenter commented Jun 11, 2022

Codecov Report

Merging #360 (b9f502f) into main (d9290af) will increase coverage by 0.12%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #360      +/-   ##
==========================================
+ Coverage   13.49%   13.62%   +0.12%     
==========================================
  Files          60       60              
  Lines        6563     6568       +5     
==========================================
+ Hits          886      895       +9     
+ Misses       5608     5605       -3     
+ Partials       69       68       -1     
Impacted Files Coverage Δ
...rc/github.com/clusternet/clusternet/pkg/hub/hub.go 2.81% <0.00%> (+<0.01%) ⬆️
...clusternet/pkg/registry/shadow/template/trimmer.go 69.23% <0.00%> (+5.59%) ⬆️
...ernet/clusternet/pkg/hub/apiserver/shadow/utils.go 100.00% <0.00%> (+10.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9290af...b9f502f. Read the comment docs.

@aven-ai
Copy link
Contributor Author

aven-ai commented Jun 11, 2022

@dixudx @lmxia please help to review, thanks.

pkg/hub/hub.go Outdated Show resolved Hide resolved
@@ -31,6 +31,8 @@ func trimCommonMetadata(result *unstructured.Unstructured) {
unstructured.RemoveNestedField(result.Object, "metadata", "managedFields")
unstructured.RemoveNestedField(result.Object, "metadata", "resourceVersion")
unstructured.RemoveNestedField(result.Object, "metadata", "selfLink")
unstructured.RemoveNestedField(result.Object, "metadata", "generation")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should modify this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is to remove the generation and observedGeneration fields in the object. Keeping them will cause the manifest to change, and re-ApplyDescription.
Like: manifest change -> description.spec.raw -> ApplyDescription to child -> workload status.observedGeneration -> description.status.observedGeneration -> workload.status changed -> manifest change.

Do you have any other suggestions to this problem?

Copy link
Member

Choose a reason for hiding this comment

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

Please refer to this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Has removed too.

syncHandlerFunc SyncHandlerFunc
}

func NewController(clusternetClient clusternetClientSet.Interface,
Copy link
Member

Choose a reason for hiding this comment

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

We're aggregating status from Description to Subscription, then why not adding this Subscription controller?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're aggregating status from Description to Subscription, then why not adding this Subscription controller?

The logic of subscription-controller is to watch the events of addSubscription, updateSubscription, deleteSubscription, and deleteBase to re-ApplyDescription.

The logic of aggregatestatus-controller is to watch Description.Status update, deleteDescription, and synchronize the status of Description to subs and workload.

I don't think it's a better solution to combine them together, leading to logical intersections and more logical conditional judgments, especially considering more exception scenarios.

@@ -308,6 +334,198 @@ func (deployer *Deployer) handleSubscription(sub *appsapi.Subscription) error {
return nil
}

func (deployer *Deployer) handleAggregateStatus(sub *appsapi.Subscription) error {
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 we could move this to aggregatestatus.go, since we can get all the status from the listers.

The aggregatestatus controller can be invoked in deployer.

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 could move this to aggregatestatus.go, since we can get all the status from the listers.

The aggregatestatus controller can be invoked in deployer.

Yes, it can be done in code implementation. In fact, putting handleAggregateStatus in aggregatestatus.go or deployer.go has the same effect. Considering that there will be more iterations and more code in the subsequent status aggregation, we can try to put it in aggregatestatus.go.

Signed-off-by: aven-ai <as1919@qq.com>
Copy link
Member

@dixudx dixudx left a comment

Choose a reason for hiding this comment

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

Nice work! Thanks for your contribution.

@dixudx dixudx merged commit d89a45c into clusternet:main Jul 7, 2022
@dixudx dixudx deleted the pr_AggregateStatus_hub branch July 7, 2022 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants