qbec icon indicating copy to clipboard operation
qbec copied to clipboard

Diff sometimes errors out with the message "both left and right were nil for diff"

Open gotwarlost opened this issue 4 years ago • 4 comments

Race condition where an object is deleted between the time it is LIST-ed versus the time it is GET-ted

gotwarlost avatar Mar 02 '21 20:03 gotwarlost

@sherman-grewal something easy to start with

gotwarlost avatar Jun 25 '21 22:06 gotwarlost

I can't seem to reproduce this error, would you happen to have any ideas on how I can reproduce it?

This is what I've done so far (in an attempt to reproduce the error).

  1. Start with the demo project: qbec init demo --with-example
  2. Run qbec apply default to create the objects
  3. Add the following code somewhere between the time it is LIST-ed versus the time it is GET-ted when we run qbec diff default

internal/commands/diff.go:diff()

if ob.GetName() == "demo-deploy" {
	cmd := exec.Command("./test.sh")
	err := cmd.Run()
	if err != nil {
		return err
	}
}

test.sh

#!/bin/bash

kubectl delete deployments/demo-deploy
  1. Run qbec diff default

I thought by deleting the deployment object between the time it is LIST-ed versus the time it is GET-ted would reproduce the issue, but it does not seem to be the case. Let me know if I am missing something!

@gotwarlost

sherman-grewal avatar Jul 06 '21 03:07 sherman-grewal

kubectl delete deploy probably doesn't wait for the deployment object to be removed - the pod has to go away first etc. Try sleeping for 30s or smth after running the delete

gotwarlost avatar Jul 07 '21 00:07 gotwarlost

use kubectl delete deployments/demo-deploy --wait=true in the script. Also remove the demo-deploy deployment from components.

harsimranmaan avatar Jul 07 '21 22:07 harsimranmaan