-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[WIP] Auto reload the local operator for code changes #1489
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
Conversation
3e21593
to
3b3c108
Compare
When running the operator using `operator-sdk up local` command, restart the operator whenever there is a change in Go source code in the file-system. Fixes operator-framework#1484
@baijum This looks like a good start. Just a couple of other ideas to think about:
func ExecCmd(cmd *exec.Cmd, opts ...func(*ExecOptions) error) error {
execOptions := ExecOptions{}
for _, opt := range opts {
if err := opt(&execOptions); err != nil {
return err
}
}
...
} Then could export a new func RestartOnChange(rootDir string, ignorePaths []string) func(*ExecOption) error {
return func(opt *ExecOption) error {
opt.RestartOnChange = true
opt.WatchRootDir = rootDir
opt.WatchIgnorePaths = ignorePaths
return nil
}
} With this pattern, existing usages would be unchanged: projutil.ExecCmd(myOneShotCmd) But to restart a command based on a watch, it could look like: projutil.ExecCmd(
myRestartableCmd,
projutil.RestartOnChange(".", []string{".git", "deploy", "build"})
) I think doing something along these lines would make it easy to extend this to other commands (like Thoughts? |
@joelanford Thanks for the idea. I will study that pattern. |
@joelanford Looks like
Line 111 in bd4dc8c
|
@baijum Oh, right. In that case, we probably need an abstraction that handles each case. In fact, the entire It looks like the We might have to have something like the following with a couple of struct implementations (one for type Runnable interface {
Run() error
Stop() error
} |
@baijum Before you get too far with this, I want to make sure this is something we're likely to accept. /cc @hasbro17 @lilic @shawn-hurley @estroz @AlexNPavel @theishshah Thoughts on including this functionality in operator-sdk? Would we be better off documenting how to do this with inotify or fswatch? |
@baijum: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@joelanford I think this is very useful and right now I think users just assume this is already working and run into problems when changes are not applied, thinking the problem is in their code. So this is very much needed 👍 |
@baijum: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
@baijum thanks again for opening this PR. Do you plan on working on this going forward? If not, one of the SDK main contributors can potentially pick it up. |
Stale issues rot after 30d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle rotten |
Rotten issues close after 30d of inactivity. Reopen the issue by commenting /close |
@openshift-bot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
When running the operator using
operator-sdk up local
command,restart the operator whenever there is a change in Go source code
in the file-system.
Fixes #1484
.git,build
)