kubernetes: [bug] StorageError: invalid object
Copied from https://github.com/kubernetes-sigs/controller-runtime/issues/1881 where this was originally reported, as it is unlikely this has anything to do with controller-runtime. Unfortunately, the prow transfer plugin doesn’t support cross-org transfer 😦
/kind bug /sig api-machinery /cc @stijndehaes @pier-oliviert Hi All,
We are seeing a lot of error logs when running our operator into production. And we can’t figure out what is happening. The basic flow of what we do goes as follows:
func (r *SparkReconciler) createSparkSubmitterPod(ctx context.Context, spark *runtimev1.Spark) error {
var pod corev1.Pod
err := r.Get(ctx, client.ObjectKey{
Name: submitterPodName(spark),
Namespace: spark.Namespace,
}, &pod)
if apierrors.IsNotFound(err) {
r.Log.V(1).Info("Creating the spark submitter pod")
return r.doCreateSparkSubmitterPod(ctx, spark)
}
return errors.Wrap(err, "Failed getting the pod")
}
As you can see in the code snippet. We create a pod only when it does not exist. Because we read from cache we know that the get call can return not found when the pod exists. We do the following in the doCreateSparkSubmitterPod:
if err := r.Client.Create(ctx, pod); err != nil {
if apierrors.IsAlreadyExists(err) {
return nil
}
return errors.Wrap(err, "Failed creating the pod")
}
So we capture an already exists error. However we tend to see a lot of errors like this when running into production:
"error":"Operation cannot be fulfilled on pods \"255f70af-5699-46c6-8002-a4df45af5209\": StorageError: invalid object, Code: 4, Key: /registry/pods/addatatest2/255f70af-5699-46c6-8002-a4df45af5209, ResourceVersion: 0, AdditionalErrorMsg: Precondition failed: UID in precondition: f8104e60-1a9d-40ca-847e-52bc0f556844, UID in object meta: "
We have no clue on how to proceed on this. I think it might happen when the pod already exists. But not entirely sure. Perhaps someone can shed a light on this?
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 23
- Comments: 16 (7 by maintainers)
Any updates? I encounter this problem as well.
Any updates? I encounter this problem as well. It‘s already 2025 XD
Encountering this problem as well
Our organization is running into this too in our envtest tests. I haven’t really dug into it yet, but I find the UID precondition part interesting:
It looks like it’s coming from https://github.com/kubernetes/kubernetes/blob/v1.30.0/staging/src/k8s.io/apiserver/pkg/storage/interfaces.go#L141-L144 / https://github.com/kubernetes/apiserver/blob/v0.30.0/pkg/storage/interfaces.go#L141-L144
I can take a look at this and see what I can do
/assign @michaelasp