Skip to content

Commit

Permalink
run/runc: Provide interfaces for RUNC
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <a.jung@lancs.ac.uk>
  • Loading branch information
nderjung committed Dec 23, 2020
1 parent 9c5fec7 commit 0c36d31
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.14

require (
github.com/muesli/termenv v0.7.4
github.com/opencontainers/runc v1.0.0-rc92
github.com/spf13/cobra v1.1.1
gopkg.in/yaml.v2 v2.2.8
)
4 changes: 4 additions & 0 deletions run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func NewRunner(image string, cfg *RunnerConfig) (Runner, error) {

var runner Runner
switch runtime := ref.Runtime; runtime {
case "runc":
runner = RuncRunner{
Config: cfg,
}
default:
return nil, fmt.Errorf("Unsupported container runtime: %s", runtime)
}
Expand Down
64 changes: 64 additions & 0 deletions run/runc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package run
// SPDX-License-Identifier: BSD-3-Clause
//
// Authors: Alexander Jung <a.jung@lancs.ac.uk>
//
// Copyright (c) 2020, Lancaster University. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

import (
"github.com/opencontainers/runc/libcontainer"

"github.com/lancs-net/ukbench/log"
)

type RuncRunner struct {
log *log.Logger
Config *RunnerConfig
factory libcontainer.Factory
}

func (r RuncRunner) Init() error {
// Set the logger
r.log = r.Config.Log

r.log.Debug("Initializing runc...")

return nil
}

func (r RuncRunner) Start() error {
return nil
}

func (r RuncRunner) Wait() (int, error) {
return 0, nil
}

func (r RuncRunner) Destroy() error {
return nil
}

0 comments on commit 0c36d31

Please sign in to comment.