-
Notifications
You must be signed in to change notification settings - Fork 81
Fix for final inventory update #319
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
Fix for final inventory update #319
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: seans3 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
Overall looks good to me.
} | ||
}) | ||
} | ||
} | ||
} | ||
|
||
// unionObjects returns the union of sliceA and sliceB as a slice of unstructured objects. |
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.
If both sliceA and sliceB contains the unstructured object with the same ObjMeta, the one from sliceB is taken.
localIds = append(localIds, clusterObj) | ||
klog.V(4).Infof("skip prune for lifecycle directive %s/%s", pruneObj.Namespace, pruneObj.Name) | ||
taskContext.EventChannel() <- createPruneEvent(pruneObj, obj, event.PruneSkipped) | ||
pruneFailures = append(pruneFailures, pruneObj) |
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.
Maybe add a comment here for why adding it to pruneFailures
. It's actually not a failure, we want to use pruneFailures
to keep it in the final inventory list.
continue | ||
} | ||
err = namespacedClient.Delete(context.TODO(), pruneObj.Name, metav1.DeleteOptions{}) | ||
if 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.
The error handling here is the same as the one after namespacedClient, err := po.namespacedClient(pruneObj)
. We can combine the getting client and deleting the object into one function, like what you have done for getObject
. The new function can be deleteObject
.
So overall looks good, but I want to understand how we decide whether a resource that we failed to apply should be included in the inventory or not. I want to make sure that a situation where a resource already exists in the cluster and apply (which in this case would be an update/patch) fails, we don't end up orphaning the resource. I don't think this were among the testcases. |
We had an informative discussion about this corner case, and we believe we know a way forward to make the final inventory storage step even more error tolerant. This PR is strictly better than before, so we will merge this current PR. The improvements to the algorithm will be instituted in a future PR. The following is documentation of our discussion to further improve the final inventory calculation. The apply operation currently does a
Implementing this decision tree (in a future PR) would have two prerequisites:
Implementing this decision tree would allow us to remove the final |
/lgtm |
Prune
function to correctly store the final inventory items. These items are:Prune
unit test to validate the final inventory stored is correct.TaskContext
inapply_task
to ensure only successfully applied objects are added to context.