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

Set controller reference for both create and update deployment operation in UPF controller. #42

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

denysaleksandrov
Copy link
Member

No description provided.

@nephio-prow
Copy link
Contributor

nephio-prow bot commented Jun 29, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign henderiw for approval by writing /assign @henderiw in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@@ -164,6 +164,10 @@ func (r *UPFDeploymentReconciler) Reconcile(ctx context.Context, req ctrl.Reques
log.Info("Not all NetworkAttachDefinitions available in current namespace, requeuing")
return reconcile.Result{RequeueAfter: time.Duration(10) * time.Second}, nil
}
} else {
if err = r.Client.Update(ctx, deployment); 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.

Does this actually work? Because since deployment came out of createDeployment, I don't think it will have resourceVersion set, so API server will reject the Update, won't it?

Copy link
Member

Choose a reason for hiding this comment

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

That is, before this call, deployment is either the current deployment, or an empty deployment. After this call, deployment is the new object created in createDeployment. Instead, you should set the namespace and name when you create the "empty" deployment, and pass that pointer into createDeployment, which should just set the Spec in the passed in object.

Copy link
Member

Choose a reason for hiding this comment

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

To be clear, we shouldn't be touching the metadata of an existing deployment, so we need to reuse that deployment object in the Update. Otherwise api server will reject the Update - this is how optimistic concurrency happens.

Copy link
Member Author

Choose a reason for hiding this comment

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

Then I can use the currentDeployment object in the update

currentDeployment := new(appsv1.Deployment)
if err := r.Client.Get(ctx, types.NamespacedName{Name: deploymentName, Namespace: namespace}, currentDeployment); err == nil {
		deploymentFound = true
}
...
     if !deploymentFound {
...
     } else {
         if err = r.Client.Update(ctx, currentDeployment); err != nil {
....

Before the update call, I check if Spec.Capacity.MaxDownlinkTroughput changed. If true then call createResourceRequirements and update currentDeployment.spec.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@denysaleksandrov

Last night when I tried it (as you know, I found that the deletion of UPFDeployment does not remove the corresponding Deployment while doing Client.Update), what I found was that the reconciliation loop went crazy (keeps on reconciling)... I will need to do a test on your fix to ensure that doesn't happen

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

Successfully merging this pull request may close these issues.

3 participants