Skip to content
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

[BUG] yurt-iot-dock concurrent conflicts when exiting reclaim #1887

Closed
wangxye opened this issue Dec 29, 2023 · 1 comment · Fixed by #1889
Closed

[BUG] yurt-iot-dock concurrent conflicts when exiting reclaim #1887

wangxye opened this issue Dec 29, 2023 · 1 comment · Fixed by #1889
Labels
kind/bug kind/bug

Comments

@wangxye
Copy link
Member

wangxye commented Dec 29, 2023

What happened:
Since the reclaim logic uses the same context as the delete reconcile logic, extreme concurrency can occur where yurt-iot-dock exits and deletes the device /device profile/ device service in edgex together.

What you expected to happen:
yurt-iot-dock cannot actively delete resources from an existing edgex in the reclaim logic

Anything else we need to know?:

var onlyOneSignalHandler = make(chan struct{})
var shutdownSignals = []os.Signal{syscall.SIGTERM}

func SetupSignalHandler(client client.Client, opts *options.YurtIoTDockOptions) context.Context {
	close(onlyOneSignalHandler) // panics when called twice

	ctx, cancel := context.WithCancel(context.Background())
	setupLog.Info("[SetupSignalHandler] shutdown controller with crd")
	c := make(chan os.Signal, 2)
	signal.Notify(c, shutdownSignals...)
	go func() {
		<-c
		setupLog.Info("[SetupSignalHandler] shutdown signal concur")
		deleteCRsOnControllerShutdown(ctx, client, opts)
		cancel()
		<-c
		os.Exit(1) // second signal. Exit directly.
	}()

	return ctx
}

Environment:

  • OpenYurt version: v1.4.0

others

/kind bug

@wangxye wangxye added the kind/bug kind/bug label Dec 29, 2023
@wangxye
Copy link
Member Author

wangxye commented Dec 29, 2023

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug kind/bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant