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

Adding HostExec for stages and RestartPolicy #2238

Merged
merged 3 commits into from
Oct 17, 2024
Merged

Conversation

steiler
Copy link
Collaborator

@steiler steiler commented Oct 15, 2024

Adding the RestartPolicy as a knob, also cleaning up the docker runtime from referencing specific node kinds.
Further implements host-exec per stage, which executes commands in the host namespace as part of the stages of a specific node.
Tackling the two topics that surfaced in #2233

name: linuxfrr

topology:
  kinds:
    linux:
      image: alpine
  nodes:
    frr1:
      kind: linux
      stages:
        configure:
          host-exec:
            on-enter:
              - docker update --restart=no clab-linuxfrr-frr1
    frr2:
      kind: linux
    frr3:
      kind: linux
      restart-policy: no

The json schema update is missing so far, as well as docs update.

@hellt
Copy link
Member

hellt commented Oct 17, 2024

thanks @steiler
I have added docs/schema/tests and did one slight modification by putting the host execs target ahead of the container exec.

The idea is that host execs are typically preparation commands, so they would benefit form running first, and then the container stage execs would follow

@steiler
Copy link
Collaborator Author

steiler commented Oct 17, 2024

The idea is that host execs are typically preparation commands, so they would benefit form running first, and then the container stage execs would follow

I've also thought about orders. The other option would be to reorg that part and make it more like

  nodes:
    frr1:
      kind: linux
      stages:
        configure:
          exec:
            on-enter:
              - command: <command>
                target: <host/container>

That would allow to run them in any order ...

@hellt hellt merged commit 6859e39 into main Oct 17, 2024
64 of 65 checks passed
@hellt hellt deleted the hostexecAndRestartPolicy branch October 17, 2024 11:40
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 70.51282% with 23 lines in your changes missing coverage. Please review.

Project coverage is 52.12%. Comparing base (2c249b2) to head (5ea2aa0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
clab/dependency_manager/dependency_node.go 81.25% 5 Missing and 1 partial ⚠️
runtime/docker/docker.go 50.00% 6 Missing ⚠️
types/stages.go 66.66% 4 Missing and 2 partials ⚠️
types/topology.go 42.85% 2 Missing and 2 partials ⚠️
nodes/host/host.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2238      +/-   ##
==========================================
+ Coverage   51.94%   52.12%   +0.18%     
==========================================
  Files         172      172              
  Lines       12658    12714      +56     
==========================================
+ Hits         6575     6627      +52     
+ Misses       5175     5174       -1     
- Partials      908      913       +5     
Files with missing lines Coverage Δ
clab/config.go 68.62% <100.00%> (+0.10%) ⬆️
nodes/linux/linux.go 76.08% <100.00%> (+1.08%) ⬆️
types/node_definition.go 94.17% <100.00%> (+0.12%) ⬆️
types/types.go 60.75% <ø> (ø)
nodes/host/host.go 34.84% <50.00%> (+17.66%) ⬆️
types/topology.go 71.96% <42.85%> (-0.65%) ⬇️
clab/dependency_manager/dependency_node.go 87.65% <81.25%> (+1.08%) ⬆️
runtime/docker/docker.go 71.54% <50.00%> (-0.53%) ⬇️
types/stages.go 69.50% <66.66%> (-1.60%) ⬇️

... and 2 files with indirect coverage changes

@hellt
Copy link
Member

hellt commented Oct 17, 2024

@steiler

The idea is that host execs are typically preparation commands, so they would benefit form running first, and then the container stage execs would follow

I've also thought about orders. The other option would be to reorg that part and make it more like

  nodes:
    frr1:
      kind: linux
      stages:
        configure:
          exec:
            on-enter:
              - command: <command>
                target: <host/container>

That would allow to run them in any order ...

This is way better, I agree
I merged the current version to save the current state, but if you know how to implement this - it would be much cleaner

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.

2 participants