-
Notifications
You must be signed in to change notification settings - Fork 462
daemon: Add a m-c-d-firstboot.service that handles encapsulated MC #904
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
Changes from all commits
625376c
05ee3ae
40d8225
a465088
aa2e045
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "fmt" | ||
| "os" | ||
|
|
||
| daemon "github.com/openshift/machine-config-operator/pkg/daemon" | ||
| "github.com/spf13/cobra" | ||
| "github.com/spf13/pflag" | ||
| ) | ||
|
|
||
| var firstbootCompleteMachineconfig = &cobra.Command{ | ||
| Use: "firstboot-complete-machineconfig", | ||
| DisableFlagsInUseLine: true, | ||
| Short: "Complete the host's initial boot into a MachineConfig", | ||
| Args: cobra.MaximumNArgs(0), | ||
| Run: executeFirstbootCompleteMachineConfig, | ||
| } | ||
|
|
||
| // init executes upon import | ||
| func init() { | ||
| rootCmd.AddCommand(firstbootCompleteMachineconfig) | ||
| pflag.CommandLine.AddGoFlagSet(flag.CommandLine) | ||
| } | ||
|
|
||
| func runFirstBootCompleteMachineConfig(_ *cobra.Command, _ []string) error { | ||
| flag.Set("logtostderr", "true") | ||
| flag.Parse() | ||
|
|
||
| exitCh := make(chan error) | ||
| defer close(exitCh) | ||
|
|
||
| dn, err := daemon.New(daemon.NewNodeUpdaterClient(), exitCh) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return dn.RunFirstbootCompleteMachineconfig() | ||
| } | ||
|
|
||
| func executeFirstbootCompleteMachineConfig(cmd *cobra.Command, args []string) { | ||
| err := runFirstBootCompleteMachineConfig(cmd, args) | ||
| if err != nil { | ||
| fmt.Printf("error: %v\n", err) | ||
| os.Exit(1) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| name: "machine-config-daemon-firstboot.service" | ||
| enabled: true | ||
| contents: | | ||
| [Unit] | ||
| Description=Machine Config Daemon Firstboot | ||
| # Make sure it runs only on OSTree booted system | ||
| ConditionPathExists=/run/ostree-booted | ||
| # This effectively disables this unit unitl we get latest | ||
| # machine-config-daemon package into bootimage | ||
| ConditionPathExists=!/etc/pivot/image-pullspec | ||
| ConditionPathExists=/etc/ignition-machine-config-encapsulated.json | ||
| BindsTo=ignition-firstboot-complete.service | ||
| After=ignition-firstboot-complete.service | ||
|
Contributor
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. While I was testing this locally, noticed that
Member
Author
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. Hmm...we should be deleting
Contributor
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. yes, we delete
Member
Author
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. OK, I see, though I think we should probably be deleting the |
||
| Before=kubelet.service | ||
|
|
||
| [Service] | ||
| # Need oneshot to delay kubelet | ||
| Type=oneshot | ||
| ExecStart=/usr/libexec/machine-config-daemon firstboot-complete-machineconfig | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
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.
yes perf! simple and clean.