Skip to content

Commit

Permalink
Drop sudo from system agent install command (#780)
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev authored Oct 11, 2024
1 parent 9f6a4bf commit 7b670d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion exp/etcdrestore/webhooks/rke2config.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ preserveWorkDirectory: true`,

// addPostInstallCommands adds the post install command to the RKE2Config.
func (r *RKE2ConfigWebhook) AddPostInstallCommands(rke2Config *bootstrapv1.RKE2Config) {
postInstallCommand := "sudo sh /opt/system-agent-install.sh"
postInstallCommand := "sh /opt/system-agent-install.sh"

for _, cmd := range rke2Config.Spec.PostRKE2Commands {
if cmd == postInstallCommand {
Expand Down
4 changes: 2 additions & 2 deletions exp/etcdrestore/webhooks/rke2config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ preserveWorkDirectory: true`,
It("Should add post-install command when it's not present", func() {
r.AddPostInstallCommands(rke2Config)

Expect(rke2Config.Spec.PostRKE2Commands).To(ContainElement("sudo sh /opt/system-agent-install.sh"))
Expect(rke2Config.Spec.PostRKE2Commands).To(ContainElement("sh /opt/system-agent-install.sh"))
})

It("Should not add post-install command when it's already present", func() {
rke2Config.Spec.PostRKE2Commands = append(rke2Config.Spec.PostRKE2Commands, "sudo sh /opt/system-agent-install.sh")
rke2Config.Spec.PostRKE2Commands = append(rke2Config.Spec.PostRKE2Commands, "sh /opt/system-agent-install.sh")

r.AddPostInstallCommands(rke2Config)

Expand Down

0 comments on commit 7b670d2

Please sign in to comment.