Skip to content
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

fix: failed to create the systemd experiment #147

Merged
merged 1 commit into from
May 10, 2023

Conversation

Yuaninga
Copy link
Contributor

@Yuaninga Yuaninga commented Dec 26, 2022

Signed-off-by: Yuaninga 1846225041@qq.com

Describe what this PR does / why we need it

This PR will fix the bug: failed to create the systemd experiment.

Does this pull request fix one issue?

bug report: the systemd stop experiment cannot be created #815

Describe how you did it

TheStopSystemdBin will be no longer used in the code, but systemctl stop service that realized the StopSystemdBin will be used directly.

Describe how to verify it

1.Build a new chaos_os in the chaosblade-exec-os

cd chaosblade-exec-os
make build_linux (on the Mac operating system)
cd target/chaosblade-1.7.0/bin

2.Move the new chaos_os to the chaosblade-1.7.0 from the chaosblade-exec-os

scp chaos_os root@x.x.x.x:/root/chaosblade-1.7.0

3.Replace the old chaos_os

ssh root@x.x.x.x
cd chaosblade-1.7.0/bin
mv chaos_os chaos_os_old
cd ..
mv chaos_os bin/chaos_os

4.Create the systemd experiment

systemctl start test
systemctl status test
cd chaosblade-1.7.0
./blade create systemd stop --service test

Special notes for reviews

Create the test service managed by the systemd:

1.test.go

package main
import (
        "time"
        "os"
)
func main(){

        f,err := os.OpenFile("./out.log",os.O_CREATE| os.O_APPEND|os.O_WRONLY,0600)
        if err != nil {
                        return
        }
        for i := 0; i < 10000; i++{
                str := string(time.Now().String())  +string("I am ok\n")
                _,err := f.WriteString(str )
                if err != nil {
                        return
                }
                time.Sleep(time.Second * 5)
        }
}

2.test.service

[Unit]
Description=test
After=network.target

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/root/deamon/test

[Install]
WantedBy=multi-user.target

3.move test.service

mv test.service /usr/lib/systemd/system

Signed-off-by: Yuaninga <1846225041@qq.com>
@tiny-x tiny-x added the type/bug Something isn't working label May 10, 2023
@tiny-x tiny-x added this to the v1.7.2 milestone May 10, 2023
@tiny-x tiny-x merged commit c18136a into chaosblade-io:master May 10, 2023
@Yuaninga Yuaninga deleted the dev branch June 28, 2023 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants