-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Remove the node from dnsmasq config when shutting down #19987
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"path/filepath" | ||
"strings" | ||
"syscall" | ||
"time" | ||
|
||
"github.com/coreos/go-systemd/daemon" | ||
"github.com/golang/glog" | ||
|
@@ -18,11 +19,11 @@ import ( | |
kerrors "k8s.io/apimachinery/pkg/api/errors" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/apimachinery/pkg/util/sets" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
kubeletapp "k8s.io/kubernetes/cmd/kubelet/app" | ||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates" | ||
kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" | ||
"k8s.io/kubernetes/pkg/master/ports" | ||
"k8s.io/kubernetes/pkg/util/interrupt" | ||
|
||
"github.com/openshift/library-go/pkg/crypto" | ||
"github.com/openshift/origin/pkg/cmd/server/admin" | ||
|
@@ -115,14 +116,26 @@ var networkLong = templates.LongDesc(` | |
|
||
// NewCommandStartNetwork provides a CLI handler for 'start network' command | ||
func NewCommandStartNetwork(basename string, out, errout io.Writer) (*cobra.Command, *NodeOptions) { | ||
options := &NodeOptions{Output: out} | ||
options := &NodeOptions{ | ||
ExpireDays: crypto.DefaultCertificateLifetimeInDays, | ||
Output: out, | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "network", | ||
Short: "Launch node network", | ||
Long: fmt.Sprintf(networkLong, basename), | ||
Run: func(c *cobra.Command, args []string) { | ||
options.Run(c, errout, args, wait.NeverStop) | ||
ch := make(chan struct{}) | ||
interrupt.New(func(s os.Signal) { | ||
close(ch) | ||
fmt.Fprintf(errout, "interrupt: Gracefully shutting down ...\n") | ||
time.Sleep(200 * time.Millisecond) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is much better than 1 second? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 5 times better. |
||
os.Exit(1) | ||
}).Run(func() error { | ||
options.Run(c, errout, args, ch) | ||
return nil | ||
}) | ||
}, | ||
} | ||
|
||
|
@@ -209,7 +222,7 @@ func (o NodeOptions) Complete(cmd *cobra.Command) error { | |
|
||
// StartNode calls RunNode and then waits forever | ||
func (o NodeOptions) StartNode(stopCh <-chan struct{}) error { | ||
if err := o.RunNode(); err != nil { | ||
if err := o.RunNode(stopCh); err != nil { | ||
return err | ||
} | ||
|
||
|
@@ -227,7 +240,7 @@ func (o NodeOptions) StartNode(stopCh <-chan struct{}) error { | |
// 2. Reads fully specified node config OR builds a fully specified node config from the args | ||
// 3. Writes the fully specified node config and exits if needed | ||
// 4. Starts the node based on the fully specified config | ||
func (o NodeOptions) RunNode() error { | ||
func (o NodeOptions) RunNode(stopCh <-chan struct{}) error { | ||
nodeConfig, configFile, err := o.resolveNodeConfig() | ||
if err != nil { | ||
return err | ||
|
@@ -277,7 +290,7 @@ func (o NodeOptions) RunNode() error { | |
return originnode.WriteKubeletFlags(*nodeConfig) | ||
} | ||
|
||
return StartNode(*nodeConfig, o.NodeArgs.Components) | ||
return StartNode(*nodeConfig, o.NodeArgs.Components, stopCh) | ||
} | ||
|
||
// resolveNodeConfig creates a new configuration on disk by reading from the master, reads | ||
|
@@ -421,7 +434,7 @@ func execKubelet(kubeletArgs []string) error { | |
} | ||
|
||
// StartNode launches the node processes. | ||
func StartNode(nodeConfig configapi.NodeConfig, components *utilflags.ComponentFlag) error { | ||
func StartNode(nodeConfig configapi.NodeConfig, components *utilflags.ComponentFlag, stopCh <-chan struct{}) error { | ||
kubeletArgs, err := nodeoptions.ComputeKubeletFlags(nodeConfig.KubeletArguments, nodeConfig) | ||
if err != nil { | ||
return fmt.Errorf("cannot create kubelet args: %v", err) | ||
|
@@ -476,12 +489,12 @@ func StartNode(nodeConfig configapi.NodeConfig, components *utilflags.ComponentF | |
networkConfig.RunProxy() | ||
} | ||
if components.Enabled(ComponentDNS) && networkConfig.DNSServer != nil { | ||
networkConfig.RunDNS() | ||
networkConfig.RunDNS(stopCh) | ||
} | ||
|
||
networkConfig.InternalKubeInformers.Start(wait.NeverStop) | ||
networkConfig.InternalKubeInformers.Start(stopCh) | ||
if networkConfig.InternalNetworkInformers != nil { | ||
networkConfig.InternalNetworkInformers.Start(wait.NeverStop) | ||
networkConfig.InternalNetworkInformers.Start(stopCh) | ||
} | ||
|
||
return nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't start openshift start network anymore without args - someone broke it in a refactor at some point in the last month or so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh :-(