Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Improve and actualize orchestrator-agent , extract many LVM commands into configuration file #20

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

Slach
Copy link

@Slach Slach commented Mar 21, 2018

  • Сustomize orchestrator-agent config, adding several *Command parameters
  • add handle signal syscall.SIGHUP with config.Reload, and terminate with SIGTERM, SIGKILL
  • Improve init.d script for SIGHUP and reload support
  • extract SeedTransferPort from const to config

Slach added 15 commits March 15, 2018 18:33
Signed-off-by: Slach <bloodjazman@gmail.com>
add sourceHost parameter into /api/post-copy/

Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
… daemon running

Signed-off-by: Slach <bloodjazman@gmail.com>
and commandOutput to DEBUG log

Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
Copy link

@shlomi-noach shlomi-noach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. I thought you were adapting orchestrator-agent to support Xtrabackup?
But I still see LVM terminology everywhere. Since I don't see anything xtrabackup-related, I'm asusming you have your own personal onfiguration where LVM mount command is actually some xtrabackup command. IS that the case?
If so, then I will request a rewrite of this PR ; the LVM flow is not necessarily similar to xtrabackup flow.

"AvailableSnapshotHostsCommand": "echo localhost\n127.0.0.1",
"SnapshotVolumesFilter": "-my-snapshot-",
"MySQLDatadirCommand": "echo '~/tmp'",
"SnapshotMountPoint": "${SnapshotMountPoint:-/mysql-data}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer using conventional shell naming, e.g. ${SNAPSHOT_MOUNT_POINT}. This applies to all of the rest of the variables.

@@ -26,6 +26,11 @@ DESC="orchestrator-agent: MySQL management agent"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# This files can be used to inject pre-service execution
# scripts, such as exporting variables or whatever. It's yours!
[ -f /etc/default/orchestrator-agent ] && . /etc/default/orchestrator-agent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good. If we're down this rabbit hole, let's also add /etc/profile.d/orchestrator-agent to the party.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -60,21 +65,39 @@ case "$1" in
PID=$(cat $PIDFILE)
cd $DAEMON_PATH
if [ -f $PIDFILE ]; then
kill -HUP $PID
printf "%s\n" "Ok"
kill -TERM $PID

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

rm -f $PIDFILE
# Wait for orchestrator to stop otherwise restart may fail.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to "Wait for orchestrator-agent to stop..."

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok fixed

sig := <-c
log.Fatalf("Got signal: %+v", sig)
signal.Notify(c, syscall.SIGHUP, syscall.SIGKILL, syscall.SIGTERM, syscall.SIGTERM)
go func() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't block. Can you please explain the reasoning for changing from blocking to non-blocking?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a just backported your code from here ;)
https://github.com/github/orchestrator/blame/master/go/logic/orchestrator.go#L138
i can restore to blocking behavior

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes please.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. i return blocking behavior

config.Reload()
case syscall.SIGTERM, syscall.SIGKILL, syscall.SIGINT:
log.Infof("Received %s. Shutting down orchestrator-agent", sig.String())
// probably should poke other go routines to stop cleanly here ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you poke goroutines there's nothing to promise they will complete before exiting.

and also fixed some mistypes in init.d script

Signed-off-by: Slach <bloodjazman@gmail.com>
@Slach
Copy link
Author

Slach commented Mar 29, 2018

yes i just work for adoption for current LVM based commands for add oportunity use xtrabackup with LVM similar flow

ok. i rewrite PR header

@Slach Slach changed the title Improve orchestrator-agent for use xtrabackup command for data seeding between nodes Improve and actualize orchestrator-agent , extract many LVM commands into configuration file Mar 29, 2018
@shlomi-noach
Copy link

Then please hold off and let's discuss. IMO all the new

* `LogicalVolumesCommand`              (string), command which list logical volumes, default implementation used lvs
+* `GetMountCommand`                    (string), command which get mount point parameters by mount point name, default implementation over cat /etc/mtab
+* `UnmountCommand`                     (string), command which unmount current mount point, default implementation just execute umount
+* `MountLVCommand`                     (string), command which mount selected snapshot, default implementation execute mount selected LVM snapshot 
+* `RemoveLVCommand`                    (string), command which remove selected snapshot, default implementation execute lvremove selected LVM snapshot
+* `MySQLTailErrorLogCommand`           (string), command which return last 20 lines from MySQL @@log_error file
+* `GetLogicalVolumeFSTypeCommand`      (string), command which return logical volume filesystem type
 * `CreateSnapshotCommand`              (string), command which creates new LVM snapshot of MySQL data

commands should be unfortunately removed. And you should add specialized Xtrabackup commands, and then design a Xtrabackup flow. Which takes this PR to a very different place.

Slach added 2 commits March 29, 2018 15:33
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
@Slach
Copy link
Author

Slach commented Mar 29, 2018

hm, but i'm not broke current functionality
and in my xtrabackup flow is really similar with current lvm based implementation
you can see it here
https://bitbucket.org/production_databases/mysql_live_upgrade/src

Slach added 2 commits March 31, 2018 13:54
Signed-off-by: Slach <bloodjazman@gmail.com>
Signed-off-by: Slach <bloodjazman@gmail.com>
go/http/api.go Outdated
@@ -363,6 +363,10 @@ func (this *HttpAPI) PostCopy(params martini.Params, r render.Render, req *http.
if err := this.validateToken(r, req); err != nil {
return
}
qs := req.URL.Query()
if sourceHost, exists := params["sourceHost"]; !exists || sourceHost=="" {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In golang, if the value does not exist in the map, then the returned value is "" anyway. So you can rewrite as:

if sourceHost := params["sourceHost"]; sourceHost == "" {

@shlomi-noach
Copy link

shlomi-noach commented Apr 8, 2018

hm, but i'm not broke current functionality

True!

(and I'm returned from vacation, sorry for the late response)

But still I do not feel comfortable that a command named MountLVCommand would issue a, say, xtrabackup prepare.
There may be similar mapping right now, but the result code & configuration is confusing IMO. If I were a user of this product, I wouldn't feel good about configuring Xtrabackup commands under LVM based configuration.

This obviously does not reflect on your excellent job (!) in making orchestrator-agent run Xtrabackup, for which I'm grateful :)

Let's try and think what would be an elegant solution to this. Do we:

  • abstract away those commands?
  • Define some meta-flow?
  • Copy+paste to indicate Xtrabackup specific command & flow?

@MaxFedotov
Copy link

MaxFedotov commented Apr 11, 2018

Hello @shlomi-noach . Sorry for bursting into the conversation, but seems like I’m working right now on the same problem, as it is in this PR - adding different backup methods (xtrabackup, xtrabackup-stream, mydumper, mysqldump) for orchestrator-agent in order to automate provisioning of new slave hosts.
I’ve made a small research of code in orchestrator and orchestrator agent code and I want to share and discuss my ideas about adding xtrabackup\mydumper\mysqlbackup seed capabilities to orchestrator-agent. I also created a draft with necessary API calls and overall process, which will be needed in order to implement this functionality.
Maybe it is possible to create a new issue, where we can discuss this?

@Slach
Copy link
Author

Slach commented Apr 12, 2018

@MaxFedotov great ;) if you send new PR and new issue, maybe i don't need finalize my branch, or you can share your ideas on this PR, and we will discuss together

@shlomi-noach
Copy link

@MaxFedotov hi! And this reminds me I got an email from you, 5 days ago, to which I haven't responded. Sorry about that -- I was on vacation and the email got lost.

Yes, please open a new issue and we can discuss.

Just FYI that I haven't been working on orchestrator-agent for ages now, and am not using it myself.

Thank you!

@MaxFedotov
Copy link

MaxFedotov commented Apr 12, 2018

@shlomi-noach No problem, vacations are a good time to relax from everything :)
And it seems like issues are disabled for this repo. Can you please enable them?
@Slach Will be glad to share my ideas with you! I think I will be able to complete everything in a couple of weeks

@shlomi-noach
Copy link

Issues now enabled.

@timhughes
Copy link

My two cents: I am looking at doing something similar but using ZFS or BTRFS snapshots rather than the LVM ones. Somehow making this plug-able would be excellent

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants