-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
@@ -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 { |
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.
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?
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.
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.
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.
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.
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.
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
.
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.
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
No description provided.