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

feat: podman attempt 2 #2517

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,8 @@ lerna-debug.log
# contains several libraries that get shipped
yarn.lock
package.json
package-lock.json
package-lock.json

# Nix
# ignores the default result symlink created when building with nix
result
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package host_machine_directories

import (
"io/ioutil"
"path"
"path/filepath"

"github.com/adrg/xdg"
"github.com/kurtosis-tech/stacktrace"
"path"
"github.com/sirupsen/logrus"
)

const (
Expand Down Expand Up @@ -107,9 +111,19 @@ func GetLastPesteredUserAboutOldVersionsFilepath() (string, error) {

func GetKurtosisCliLogsFileDirPath(fileName string) (string, error) {
xdgRelDirPath := getRelativeFilePathForKurtosisCliLogs()
kurtosisCliLogFilePath, err := xdg.DataFile(path.Join(xdgRelDirPath, fileName))
if err != nil {
return "", stacktrace.Propagate(err, "An error occurred getting the kurtosis cli logs file path using '%v'", kurtosisCliLogFilePath)
// kurtosisCliLogFilePath, err := xdg.DataFile(path.Join(xdgRelDirPath, fileName))
// if err != nil {
// return "", stacktrace.Propagate(err, "An error occurred getting the kurtosis cli logs file path using '%v'", kurtosisCliLogFilePath)
// }
kurtosisCliLogFilePath, errXdg := xdg.DataFile(path.Join(xdgRelDirPath, fileName))
if errXdg != nil {
// Fallback to temp folder if XDG fails to find a suitable location. For instance XDG will fail when testing inside Nix sandbox.
logrus.WithError(errXdg).Warnf("Couldn't create kurtosis cli logs file path in the user space '%v'. Trying on temp folder.", kurtosisCliLogFilePath)
kurtosisCliLogDir, errTemp := ioutil.TempDir("", applicationDirname)
if errTemp != nil {
return "", stacktrace.Propagate(errTemp, "An error occurred creating kurtosis cli logs file path using '%v'", kurtosisCliLogDir)
}
kurtosisCliLogFilePath = filepath.Join(kurtosisCliLogDir, fileName)
}
return kurtosisCliLogFilePath, nil
}
Expand Down
9 changes: 5 additions & 4 deletions cli/cli/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ fi
exit 1
fi
# Executing goreleaser v1.26.2 without needing to install it
if ! curl -sfL https://goreleaser.com/static/run | VERSION=v1.26.2 DISTRIBUTION=oss bash -s -- ${goreleaser_verb_and_flags}; then
echo "Error: Couldn't build the CLI binary for the current OS/arch" >&2
exit 1
fi
# if ! curl -sfL https://goreleaser.com/static/run | VERSION=v1.26.2 DISTRIBUTION=oss bash -s -- ${goreleaser_verb_and_flags}; then
if ! GORELEASER_CURRENT_TAG=$(cat $root_dirpath/version.txt) goreleaser ${goreleaser_verb_and_flags}; then
echo "Error: Couldn't build the CLI binary for the current OS/arch" >&2
exit 1
fi
)

# Final verification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package backend_creator
import (
"context"
"fmt"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db"
"net"
"os"
"path"

"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/database_accessors/enclave_db"

"github.com/docker/docker/client"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_collector_functions"
Expand All @@ -27,7 +28,7 @@ import (

const (
unixSocketPrefix = "unix://"
systemDaemonSocket = "/var/run/docker.sock"
systemDaemonSocket = "/var/run/podman/podman.sock"
userOwnDaemonSocket = "/.docker/run/docker.sock"

noTempDirPrefix = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ const (
EngineTransportProtocol = port_spec.TransportProtocol_TCP

// This needs to be bind-mounted into the engine & API containers so they can manipulate Docker
DockerSocketFilepath = "/var/run/docker.sock"
DockerSocketFilepath = "/var/run/podman/podman.sock"

// The host engine config directory to mount and its local mapping
HostEngineConfigDirToMount = "/root/engine_config"
EngineConfigLocalDir = "/run/engine"

//The Docker network name where all the containers in the engine and logs service context will be added
NameOfNetworkToStartEngineAndLogServiceContainersIn = "bridge"
// NameOfNetworkToStartEngineAndLogServiceContainersIn = "bridge"
// HttpApplicationProtocol = "http"
// The Docker network name where all the containers in the engine and logs service context will be added
NameOfNetworkToStartEngineAndLogServiceContainersIn = "podman"
HttpApplicationProtocol = "http"

GitHubAuthStorageDirPath = "/kurtosis-data/github-auth/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ entryPoints:

providers:
docker:
endpoint: "unix:///var/run/docker.sock"
endpoint: "unix:///var/run/podman/podman.sock"
exposedByDefault: false
network: "{{ .NetworkId }}"
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,15 +669,15 @@ func createStartServiceOperation(
}
}

if logsCollectorAddress == "" {
return nil, stacktrace.NewError("Expected to have a logs collector server address value to send the user service logs, but it is empty")
}
// if logsCollectorAddress == "" {
// return nil, stacktrace.NewError("Expected to have a logs collector server address value to send the user service logs, but it is empty")
// }

// The container will be configured to send the logs to the Fluentbit logs collector server
fluentdLoggingDriverCnfg := docker_manager.NewFluentdLoggingDriver(
logsCollectorAddress,
logsCollectorLabels,
)
// // The container will be configured to send the logs to the Fluentbit logs collector server
// fluentdLoggingDriverCnfg := docker_manager.NewFluentdLoggingDriver(
// logsCollectorAddress,
// logsCollectorLabels,
// )

createAndStartArgsBuilder := docker_manager.NewCreateAndStartContainerArgsBuilder(
containerImageName,
Expand All @@ -703,8 +703,8 @@ func createStartServiceOperation(
tiniEnabled,
).WithVolumeMounts(
volumeMounts,
).WithLoggingDriver(
fluentdLoggingDriverCnfg,
// ).WithLoggingDriver(
// fluentdLoggingDriverCnfg,
).WithRestartPolicy(
restartPolicy,
).WithUser(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,21 @@

result := []*volume.Volume{}
if resp.Volumes != nil {
// Podman API inconsistency - filter out the union matches that podman returns while docker only returns the intersect matches when filtering by label
for _, vol := range resp.Volumes {
allLabelsMatch := true

for label, val := range labels {
if volValue, exists := vol.Labels[label]; !exists || volValue != val {
allLabelsMatch = false
break
}
}

if allLabelsMatch {
result = append(result, vol)
}
}
result = resp.Volumes
}

Expand Down Expand Up @@ -804,8 +819,17 @@
return nil, stacktrace.Propagate(err, "An error occurred inspecting container with ID '%v'", containerId)
}
allNetworkInfo := resp.NetworkSettings.Networks
for _, networkInfo := range allNetworkInfo {
containerIps[networkInfo.NetworkID] = networkInfo.IPAddress
// for _, networkInfo := range allNetworkInfo {
// containerIps[networkInfo.NetworkID] = networkInfo.IPAddress
// }
for networkKey, networkInfo := range allNetworkInfo {
// podman does not return the networkID properly and as such we need to make sure we get it.
network, err := manager.dockerClient.NetworkInspect(ctx, networkInfo.NetworkID, types.NetworkInspectOptions{})

Check failure on line 827 in container-engine-lib/lib/backend_impls/docker/docker_manager/docker_manager.go

View workflow job for this annotation

GitHub Actions / golang-lint (container-engine-lib)

Scope, Verbose are missing in NetworkInspectOptions (exhaustruct)
if err != nil {
return nil, stacktrace.Propagate(err, "An error occurred inspecting network: '%v'", networkKey)
}

containerIps[network.ID] = networkInfo.IPAddress
}
return containerIps, nil
}
Expand Down Expand Up @@ -1738,7 +1762,7 @@
portMap[containerPort] = []nat.PortBinding{
// Leaving this struct empty will cause Docker to automatically choose an interface IP & port on the host machine
{
HostIP: "",
HostIP: "0.0.0.0",
HostPort: "",
},
}
Expand Down
15 changes: 15 additions & 0 deletions enclave-manager/local/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/kurtosis-tech/kurtosis/enclave-manager/local

go 1.20
replace (
github.com/kurtosis-tech/kurtosis/enclave-manager => ../server
github.com/kurtosis-tech/kurtosis/contexts-config-store => ../../contexts-config-store
github.com/kurtosis-tech/kurtosis/kurtosis_version => ../../kurtosis_version
)

require (
github.com/kurtosis-tech/kurtosis/enclave-manager v0.0.0-20230828153722-32770ca96513
github.com/sirupsen/logrus v1.9.3
)

require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
15 changes: 15 additions & 0 deletions enclave-manager/local/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { nixpkgs, unstable, flake-utils, ... }:
outputs = { self, nixpkgs, unstable, flake-utils, ... }:
let utils = flake-utils;
in utils.lib.eachDefaultSystem (system:
let
Expand All @@ -17,17 +17,24 @@
inherit pkgs system;
nodejs = pkgs.nodejs_20;
};
in {
in
{
formatter = pkgs.nixpkgs-fmt;

packages = rec {
default = kurtosis;
kurtosis = unstable_pkgs.callPackage ./package.nix { };
};

devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs;
let
openapi-codegen-go =
import ./nix-pkgs/openapi-codegen.nix { inherit pkgs; };
grpc-tools-node =
import ./nix-pkgs/grpc-tools-node.nix { inherit pkgs; };
in [
in
[
goreleaser
go_1_20
gopls
Expand Down
1 change: 1 addition & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use (
./core/launcher
./core/server
./enclave-manager/api/golang
./enclave-manager/local
./enclave-manager/server
./engine/launcher
./engine/server
Expand Down
54 changes: 54 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{ lib
, buildGoModule
, writeTextFile
}:

buildGoModule rec {
pname = "kurtosis";
version = "0.89.11";

src = ./.;

proxyVendor = true;
vendorHash = "sha256-GaEIitoRiuYxtS7cDKobFyIlraDNQjcvbRvzG3nUKFU=";

postPatch =
let
kurtosisVersion = writeTextFile {
name = "kurtosis_verion.go";
text = ''
package kurtosis_version
const (
KurtosisVersion = "${version}"
)
'';
};
in
''
ln -s ${kurtosisVersion} kurtosis_version/kurtosis_version.go
'';

# disable checks temporarily since they connect to the internet
# namely user_support_constants_test.go
doCheck = false;

# keep this for future reference
preCheck = ''
# some tests in commands use XDG home related environment variables
export HOME=/tmp
'';

postInstall = ''
mv $out/bin/cli $out/bin/kurtosis
mv $out/bin/files_artifacts_expander $out/bin/files-artifacts-expander
mv $out/bin/api_container $out/bin/api-container

'';

meta = with lib; {
description = "A platform for launching an ephemeral Ethereum backend";
mainProgram = "kurtosis";
homepage = "https://github.com/kurtosis-tech/kurtosis";
license = licenses.asl20;
};
}
Loading