-
Notifications
You must be signed in to change notification settings - Fork 370
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
[ExternalNode] Implement SupportbundleCollection status on Controller #4249
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4249 +/- ##
==========================================
+ Coverage 64.53% 65.10% +0.57%
==========================================
Files 397 398 +1
Lines 56239 56484 +245
==========================================
+ Hits 36292 36775 +483
+ Misses 17287 17051 -236
+ Partials 2660 2658 -2
|
19313fc
to
f5ff083
Compare
f5ff083
to
c9ed12e
Compare
c9ed12e
to
96f6bd8
Compare
"antrea.io/antrea/pkg/apis/controlplane" | ||
) | ||
|
||
// StatusREST implements the REST endpoint for getting NetworkPolicy's obj. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
@@ -169,6 +173,8 @@ func (c *Controller) Run(stopCh <-chan struct{}) { | |||
|
|||
go wait.Until(c.worker, time.Second, stopCh) | |||
|
|||
go c.StatusController.Run(stopCh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit strange. If we decouple supportBundleController and statusBundleStatusController, it doesn't make sense to inject the latter to the former and let the former to start both. As seen from the change, the only purpose of this injection is to start the status controller.
But here I feel there is no need to have a separate statusController, as the existing controller would also update status. If we just add some logic to the existing controller, many repeated code could be saved and no need to worry about race conditions between the two controllers.
e0a7989
to
5ef40c9
Compare
"antrea.io/antrea/pkg/apis/controlplane" | ||
) | ||
|
||
// StatusREST implements the REST endpoint for getting NetworkPolicy's obj. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reminder
// Update internal SupportBundleCollection status. This is triggered when Agent reports status. | ||
// The event that SupportBundleCollection CR status update will not trigger this logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comments are not accurate and maybe unnecessary.
It could be also triggered by the scheduling for expiry handling, and it seems now the expiry handling would never be executed as it's in createInternalSupportBundleCollection. I think the function name createInternalSupportBundleCollection
is not accurate and some logic should be moved to updateStatus
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the comments, and move the call of updateStatus
out of createInternalSupportBundleCollection
, and call updateStatus
only in syncSupportBundleCollection
} | ||
|
||
func conditionSliceEqualsIgnoreLastTransitionTime(as, bs []v1alpha1.SupportBundleCollectionCondition) bool { | ||
sort.Slice(as, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A way to simplify this is to always set full condition list whenever updating status, instead of only setting Completed to True but never False, and always using the same order to store status in slice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is difficult to provide a full condition list any time when updating the status, for example, if the Started is false, it is meaningless to set a condition that CollectionFailure is false, and completed is false. Besides, we expect to leverage CollectionFailure=False as part of the identifier for all Nodes have uploaded the files to server. So I think the condition status is set as false when all Nodes are succeeded to upload. But if it is set in advance ( because no failure was found at that time, but maybe happens in future), it is easier to introduce misunderstanding.
I change the logic to sort the conditions before executing update operation to reduce the complexity, and set condition status of CollectionComplete and bundleCollected whenever updating the status, but for CollectionFailure, the status is set when a failure is reported from any Node or no failure is reported from all Nodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the condition is there regardless of the stage of the realization, it seems you want to use "unset" to represent another state in addition to True and False. The condition value doesn't have to mean the final state, it could change based on the actual state. For example, when Started is false, it doesn't seem wrong that CollectionFailure is False and Completed is False as it just means there is no collection failure yet and the collection is not completed yet, they are obvious and redundant but not wrong and not ambiguous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, updated.
5ef40c9
to
7f1a078
Compare
pkg/apiserver/registry/controlplane/supportbundlecollection/subresources.go
Outdated
Show resolved
Hide resolved
_, oldInternalBundleExists, _ := c.supportBundleCollectionStore.Get(bundle.Name) | ||
if oldInternalBundleExists { | ||
klog.InfoS("Internal SupportBundleCollection already exists", "name", bundle.Name) | ||
return nil | ||
return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can never happen since you have checked the object doesn't exist before calling create method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thanks for catching it, removed.
} | ||
|
||
func conditionSliceEqualsIgnoreLastTransitionTime(as, bs []v1alpha1.SupportBundleCollectionCondition) bool { | ||
sort.Slice(as, func(i, j int) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the condition is there regardless of the stage of the realization, it seems you want to use "unset" to represent another state in addition to True and False. The condition value doesn't have to mean the final state, it could change based on the actual state. For example, when Started is false, it doesn't seem wrong that CollectionFailure is False and Completed is False as it just means there is no collection failure yet and the collection is not completed yet, they are obvious and redundant but not wrong and not ambiguous.
7f1a078
to
c66ed1d
Compare
return nil | ||
} | ||
toUpdate.Status = *updatedStatus | ||
klog.V(2).InfoS("Updating SupportBundleCollection", "supportBundleCollection", name, "status", klog.KObj(toUpdate)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
klog.KObj
will just print the object name, just like the existing name, instead of the status part of the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
c66ed1d
to
bae291c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
updateStatusFunc := func(currentNodes, desiredNodes int, updatedConditions []v1alpha1.SupportBundleCollectionCondition) error { | ||
status := &v1alpha1.SupportBundleCollectionStatus{ | ||
SucceededNodes: int32(currentNodes), | ||
DesiredNodes: int32(desiredNodes), | ||
Conditions: updatedConditions, | ||
} | ||
klog.V(2).InfoS("Updating SupportBundleCollection status", "supportBundleCollection", internalBundleCollection.Name, "status", status) | ||
return c.updateSupportBundleCollectionStatus(internalBundleCollection.Name, status) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it seems no benefit gained from having this as a function now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, removed.
bae291c
to
3bb4e40
Compare
/test-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@jianjuns @mengdie-song please let me know if you will take another look or if this looks good to you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to confirm a RBAC question. For now, it seems that controller only has update privilege for supportbundlecollections/status. Then if agent side calls UpdateStatus function, it should use create privilege?
Controller needs |
Signed-off-by: wenyingd <[email protected]>
3bb4e40
to
9e1da34
Compare
Thanks for proposing it, the failure catches one issue in Controller apiserver in my code. Resolved in my latest change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wenyingd I see controller.go is updated, any change in it I need to recheck?
No logic change happens in controller.go. The change is about the Field name ( SucceededNodes -> CollectedNodes ) in SupportBundleCollectionStatus, which was not matching the name defined in the CRD. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/test-all |
/skip-conformance which failed on an irrelevant case (and was env issue) |
…er (antrea-io#4249) Signed-off-by: wenyingd <[email protected]>
…er (antrea-io#4249) Signed-off-by: wenyingd <[email protected]>
Manage support bundle collection status on Controller side.
Signed-off-by: wenyingd [email protected]