Skip to content

Commit

Permalink
Merge pull request #211 from alexander-demicev/cherry-pick-fixboostra…
Browse files Browse the repository at this point in the history
…psuccess

[release-0.2] Create bootstrap-success before setting selinux to enforcing mode
  • Loading branch information
richardcase authored Nov 29, 2023
2 parents 0663c43 + a504fff commit c4b2125
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion bootstrap/internal/ignition/butane/butane.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ storage:
{{ . | Indent 10 }}
{{- end }}
mkdir -p /run/cluster-api && echo success > /run/cluster-api/bootstrap-success.complete
{{range .PostRKE2Commands }}
{{ . | Indent 10 }}
{{- end }}
Expand Down
10 changes: 6 additions & 4 deletions bootstrap/internal/ignition/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@ const (
)

var (
serverSystemdServices = []string{
serverDeployCommands = []string{
"semanage fcontext -a -t systemd_unit_file_t /usr/lib/systemd/system/rke2-server.service",
"setenforce 0",
"systemctl enable rke2-server.service",
"systemctl start rke2-server.service",
"restorecon /etc/systemd/system/rke2-server.service",
"mkdir -p /run/cluster-api && echo success > /run/cluster-api/bootstrap-success.complete",
"setenforce 1",
}

workerSystemdServices = []string{
workerDeployCommands = []string{
"semanage fcontext -a -t systemd_unit_file_t /usr/lib/systemd/system/rke2-agent.service",
"setenforce 0",
"systemctl enable rke2-agent.service",
"systemctl start rke2-agent.service",
"restorecon /etc/systemd/system/rke2-agent.service",
"mkdir -p /run/cluster-api && echo success > /run/cluster-api/bootstrap-success.complete",
"setenforce 1",
}
)
Expand Down Expand Up @@ -136,11 +138,11 @@ func render(input *cloudinit.BaseUserData, ignitionConfig *bootstrapv1.Additiona
}

func getControlPlaneRKE2Commands(baseUserData *cloudinit.BaseUserData) ([]string, error) {
return getRKE2Commands(baseUserData, controlPlaneCommand, airGappedControlPlaneCommand, serverSystemdServices)
return getRKE2Commands(baseUserData, controlPlaneCommand, airGappedControlPlaneCommand, serverDeployCommands)
}

func getWorkerRKE2Commands(baseUserData *cloudinit.BaseUserData) ([]string, error) {
return getRKE2Commands(baseUserData, workerCommand, airGappedWorkerCommand, workerSystemdServices)
return getRKE2Commands(baseUserData, workerCommand, airGappedWorkerCommand, workerDeployCommands)
}

func getRKE2Commands(baseUserData *cloudinit.BaseUserData, command, airgappedCommand string, systemdServices []string) ([]string, error) {
Expand Down
16 changes: 8 additions & 8 deletions bootstrap/internal/ignition/ignition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,16 @@ var _ = Describe("getControlPlaneRKE2Commands", func() {
It("should return slice of control plane commands", func() {
commands, err := getControlPlaneRKE2Commands(baseUserData)
Expect(err).ToNot(HaveOccurred())
Expect(commands).To(HaveLen(7))
Expect(commands).To(ContainElements(fmt.Sprintf(controlPlaneCommand, baseUserData.RKE2Version), serverSystemdServices[0], serverSystemdServices[1]))
Expect(commands).To(HaveLen(8))
Expect(commands).To(ContainElements(fmt.Sprintf(controlPlaneCommand, baseUserData.RKE2Version), serverDeployCommands[0], serverDeployCommands[1]))
})

It("should return slice of control plane commands with air gapped", func() {
baseUserData.AirGapped = true
commands, err := getControlPlaneRKE2Commands(baseUserData)
Expect(err).ToNot(HaveOccurred())
Expect(commands).To(HaveLen(7))
Expect(commands).To(ContainElements(airGappedControlPlaneCommand, serverSystemdServices[0], serverSystemdServices[1]))
Expect(commands).To(HaveLen(8))
Expect(commands).To(ContainElements(airGappedControlPlaneCommand, serverDeployCommands[0], serverDeployCommands[1]))
})

It("should return error if base userdata is nil", func() {
Expand Down Expand Up @@ -247,16 +247,16 @@ var _ = Describe("getWorkerRKE2Commands", func() {
It("should return slice of worker commands", func() {
commands, err := getWorkerRKE2Commands(baseUserData)
Expect(err).ToNot(HaveOccurred())
Expect(commands).To(HaveLen(7))
Expect(commands).To(ContainElements(fmt.Sprintf(workerCommand, baseUserData.RKE2Version), workerSystemdServices[0], workerSystemdServices[1]))
Expect(commands).To(HaveLen(8))
Expect(commands).To(ContainElements(fmt.Sprintf(workerCommand, baseUserData.RKE2Version), workerDeployCommands[0], workerDeployCommands[1]))
})

It("should return slice of worker commands with air gapped", func() {
baseUserData.AirGapped = true
commands, err := getWorkerRKE2Commands(baseUserData)
Expect(err).ToNot(HaveOccurred())
Expect(commands).To(HaveLen(7))
Expect(commands).To(ContainElements(airGappedWorkerCommand, workerSystemdServices[0], workerSystemdServices[1]))
Expect(commands).To(HaveLen(8))
Expect(commands).To(ContainElements(airGappedWorkerCommand, workerDeployCommands[0], workerDeployCommands[1]))
})

It("should return error if base userdata is nil", func() {
Expand Down

0 comments on commit c4b2125

Please sign in to comment.