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

Send signal to cri-resmgr process (systemd unit) when forced.cfg changes (updates) #53

Open
ppalucki opened this issue Oct 4, 2022 · 0 comments

Comments

@ppalucki
Copy link
Contributor

ppalucki commented Oct 4, 2022

May require to add some watcher over files then send signal to cri-resmgr:

Idea here:
kubernetes/kubernetes#24957 (comment)

cri-resmgr supports it as described here:

  -force-config-signal string
        Signal used to reload forced configuration. (default "SIGHUP")

or code here:

but from above it only works for force-config
https://github.com/intel/cri-resource-manager/blob/master/pkg/cri/resource-manager/resource-manager.go#L363
then

// setupConfigSignal sets up a signal handler for reloading forced configuration.
func (m *resmgr) setupConfigSignal(signame string) error {
	if signame == "" || strings.HasPrefix(strings.ToLower(signame), "disable") {
		return nil
	}

	m.Info("setting up signal %s to reload forced configuration", signame)

	sig := unix.SignalNum(signame)
	if int(sig) == 0 {
		return resmgrError("invalid forced configuration reload signal '%s'", signame)
	}

	m.signals = make(chan os.Signal, 1)
	signal.Notify(m.signals, sig)

	go func(signals <-chan os.Signal) {
		for {
			select {
			case _, ok := <-signals:
				if !ok {
					return
				}
			}

			m.Info("reloading forced configuration %s...", opt.ForceConfig)

			if err := m.setConfigFromFile(opt.ForceConfig); err != nil {
				m.Error("failed to reload forced configuration %s: %v",
					opt.ForceConfig, err)
			}
		}
	}(m.signals)

	return nil
}

WARNING if you do not provide --force-config then SIGHUP will kill and restart process

@ppalucki ppalucki changed the title Send signal to cri-resmgr process (systemd unit) when fallback.cfg or forced.cfg changes (updates) Send signal to cri-resmgr process (systemd unit) when forced.cfg changes (updates) Oct 4, 2022
@ppalucki ppalucki added this to the future/undecided milestone Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant