Skip to content

Conversation

@dustymabe
Copy link
Member

@dustymabe dustymabe commented Jul 13, 2022

This adds a remote-session subcommand to coreos-assembler. The intent is for us to be able to create remote sessions on remote servers via podman --remote and execute builds there. This is especially attractive when considering that it elegantly enables us to do builds for a different architecture by targeting a remote host.

Convenience subcommands are provided to enable easily execute arbitary remote commands (via cosa remote-session exec shell) and also copying files back and forth via an rsync-like interface with cosa remote-session sync.

Here's what a typical session may look like:

// initialize local dir
mkdir fcos && cd fcos
cosa init https://github.com/coreos/fedora-coreos-config.git
cosa buildfetch

// initialize remote session and sync files
REMOTEHOST=myhost.example.com; REMOTEUSER=builder; REMOTEUID=1001
export CONTAINER_HOST="ssh://${REMOTEUSER}@${REMOTEHOST}/run/user/${REMOTEUID}/podman/podman.sock"
export COREOS_ASSEMBLER_REMOTE_SESSION=$(cosa remote-session create)
cosa remote-session sync ./ :/srv/

// execute build/tests
cosa fetch && cosa build && cosa kola run

// sync back results
cosa remote-session sync :/srv/ ./

// destroy remote session
cosa remote-session destroy
unset COREOS_ASSEMBLER_REMOTE_SESSION

@dustymabe dustymabe force-pushed the dusty-cmd-remote-session branch from 98a6d2a to e6d4dd6 Compare July 13, 2022 20:27
cgwalters
cgwalters previously approved these changes Jul 13, 2022
Copy link
Member

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

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

Overall looks sane to me

Comment on lines +71 to +74
// if the COREOS_ASSEMBLER_REMOTE_SESSION environment variable is
// set then we "intercept" the command here and redirect it to
// `cosa remote-session exec`, which will execute the commands
// via `podman --remote` on a remote machine.
Copy link
Member

Choose a reason for hiding this comment

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

One thing I'm hazy on is how this works with the "context directory"; e.g. is the cosa init and the git clone expected to happen remotely? Or is it local, and then podman syncs it?

Copy link
Member Author

Choose a reason for hiding this comment

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

it should be able to work either way. You can cosa init locally and sync it over first or you can set up the remote session and cosa init on the remote.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds cool and magical; not a blocker for merge but would be nice add this new flow in the docs!

Or, another approach may be to land the fedora-coreos-pipeline changes, and then at least just link to that code. (I tend to learn a lot by reading about how APIs/CLIs are used in the real world and not just docs)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm working on the pipeline changes and I'll post them up shortly (testing them now). Trying to work out all the kinks first.

Copy link
Member Author

Choose a reason for hiding this comment

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

cgwalters
cgwalters previously approved these changes Jul 14, 2022
@dustymabe dustymabe force-pushed the dusty-cmd-remote-session branch 2 times, most recently from 04dd8d8 to 82d6a44 Compare July 15, 2022 19:59
@dustymabe dustymabe force-pushed the dusty-cmd-remote-session branch 2 times, most recently from 21290be to a78163b Compare July 15, 2022 20:03
This adds a `remote-session` subcommand to coreos-assembler. The
intent is for us to be able to create remote sessions on remote
servers via `podman --remote` and execute builds there. This is
especially attractive when considering that it elegantly enables
us to do builds for a different architecture by targeting a remote
host.

Convenience subcommands are provided to enable easily execute arbitary
remote commands (via `cosa remote-session exec shell`) and also copying
files back and forth via an rsync-like interface with
`cosa remote-session sync`.

Here's what a typical session may look like:

```
// initialize local dir
mkdir fcos && cd fcos
cosa init https://github.com/coreos/fedora-coreos-config.git
cosa buildfetch

// initialize remote session and sync files
REMOTEHOST=myhost.example.com; REMOTEUSER=builder; REMOTEUID=1001
export CONTAINER_HOST="ssh://${REMOTEUSER}@${REMOTEHOST}/run/user/${REMOTEUID}/podman/podman.sock"
export COREOS_ASSEMBLER_REMOTE_SESSION=$(cosa remote-session create)
cosa remote-session sync ./ :/srv/

// execute build/tests
cosa fetch && cosa build && cosa kola run

// sync back results
cosa remote-session sync :/srv/ ./

// destroy remote session
cosa remote-session destroy
unset COREOS_ASSEMBLER_REMOTE_SESSION
```
@dustymabe dustymabe force-pushed the dusty-cmd-remote-session branch from a78163b to 5908faf Compare July 15, 2022 20:31
@dustymabe
Copy link
Member Author

I think I've done sufficient testing on this now. I have a ton of changes to the pipeline that I need to separate into individual commits, which is going to take some time. For now here is a view of what this looks like:

https://github.com/dustymabe/fedora-coreos-pipeline/blob/dusty-pipeline-refactor-persistent/jobs/build-arch.Jenkinsfile#L198-L207

I think this can merge in the meantime.

Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Nice work!

@dustymabe dustymabe enabled auto-merge (rebase) July 15, 2022 21:44
@dustymabe dustymabe merged commit e31e7f5 into coreos:main Jul 15, 2022
@dustymabe dustymabe deleted the dusty-cmd-remote-session branch July 15, 2022 23:05
@cgwalters
Copy link
Member

Followup thought from a demo related to this:

I think the pipeline at least should have cosa remote-session create be "owner" the container's lifecycle, instead of a timeout 4h.

Take the example of a pipeline build that is aborted due to a test error. AIUI in the current flow, the remote container will "leak" until it times out.

In this suggestion, there is an "active binding" between a process in the container on the pipeline and the remote container. When the pipeline container dies, it would break a TCP connection with the remote container and cause it to also die.

@dustymabe
Copy link
Member Author

I think the pipeline at least should have cosa remote-session create be "owner" the container's lifecycle, instead of a timeout 4h.

This is easy to do by just putting the cosa remote-session destroy in a finally block. If somehow it doesn't get run for whatever reason (Jenkins barfed or got shut down) the container still will kill itself.

dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Jul 18, 2022
This is a huge change for this file. It is no mostly similar
to the jobs/build.Jenkinsfile job. It now takes advantage of
the `cosa remote-session` work [1] and no longer uses gangplank.

[1] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Jul 19, 2022
This is a huge change for this file. It is no mostly similar
to the jobs/build.Jenkinsfile job. It now takes advantage of
the `cosa remote-session` work [1] and no longer uses gangplank.

[1] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Jul 20, 2022
This is a huge change for this file. It is now mostly similar
to the jobs/build.Jenkinsfile job. It now takes advantage of
the `cosa remote-session` work [1] and no longer uses gangplank.

[1] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Jul 20, 2022
This is a huge change for this file. It is now mostly similar
to the jobs/build.Jenkinsfile job. It now takes advantage of
the `cosa remote-session` work [1] and no longer uses gangplank.

[1] coreos/coreos-assembler#2979
dustymabe added a commit to coreos/fedora-coreos-pipeline that referenced this pull request Jul 20, 2022
This is a huge change for this file. It is now mostly similar
to the jobs/build.Jenkinsfile job. It now takes advantage of
the `cosa remote-session` work [1] and no longer uses gangplank.

[1] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Sep 15, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to ther branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Sep 15, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to ther branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Sep 15, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to ther branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Sep 15, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to ther branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Sep 16, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to ther branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Sep 16, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to ther branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
dustymabe added a commit to dustymabe/fedora-coreos-pipeline that referenced this pull request Sep 16, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to other branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
dustymabe added a commit to coreos/fedora-coreos-pipeline that referenced this pull request Sep 16, 2022
We recently did some golang migration [1] and happened to add the
`cosa remote-session` pieces [2] after that migration. This makes
it not easy to backport to other branches. For a period of time
let's use the latest COSA for our COSA pod for multi-arch builds
instead of the versioned COSA. We will still use the versioned COSA
on the remote so the actual building will happened with the correctly
versioned COSA (substituted below and passed as an argument to
`cosa remote-session create --image=`).

[1] coreos/coreos-assembler#2919
[2] coreos/coreos-assembler#2979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants