Set controller reference for both create and update deployment operation in UPF controller.#42
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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| 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.
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.
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.
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.
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.
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.