Skip to content

Commit

Permalink
Clean up updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lbeckman314 committed Oct 7, 2024
1 parent a74a05e commit 48e607b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 937 deletions.
19 changes: 1 addition & 18 deletions .github/workflows/nextflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,8 @@ on:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: 1.21
uses: ./.github/workflows/build.yml

- name: Check out code
uses: actions/checkout@v2

- name: Build Funnel (if cache does not exist)
run: make build

- name: Store Funnel
uses: actions/upload-artifact@v4
with:
name: funnelBin
path: funnel

nextflow:
needs: build
runs-on: ubuntu-latest
Expand Down
61 changes: 1 addition & 60 deletions compute/kubernetes/backend_test.go
Original file line number Diff line number Diff line change
@@ -1,62 +1,15 @@
package kubernetes

import (
"context"
"fmt"
"os"
"testing"

"path/filepath"

"github.com/ohsu-comp-bio/funnel/config"
"github.com/ohsu-comp-bio/funnel/logger"
"github.com/ohsu-comp-bio/funnel/tes"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/util/homedir"
)

// getKubernetesClient creates a Kubernetes clientset for communication with the Kubernetes API
func getKubernetesClient() (*kubernetes.Clientset, error) {
var config *rest.Config
var err error
var contextName string

// Try to create an in-cluster client
config, err = rest.InClusterConfig()
if err != nil {
// If in-cluster config fails, fallback to kubeconfig file for out-of-cluster
kubeconfig := filepath.Join(homedir.HomeDir(), ".kube", "config")
kubeConfig, err := clientcmd.LoadFromFile(kubeconfig)
if err != nil {
return nil, fmt.Errorf("failed to load kubeconfig: %v", err)
}

// Get the current context name
contextName = kubeConfig.CurrentContext

// Build config from flags or kubeconfig
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
if err != nil {
return nil, fmt.Errorf("failed to create kubernetes config: %v", err)
}
} else {
contextName = "in-cluster"
}

// Create the clientset
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, fmt.Errorf("failed to create kubernetes clientset: %v", err)
}

// Log or print the current context being used
fmt.Printf("Using Kubernetes context: %s\n", contextName)

return clientset, nil
}

func TestCreateJobc(t *testing.T) {
conf := config.DefaultConfig().Kubernetes
content, err := os.ReadFile("../../config/kubernetes-template.yaml")
Expand All @@ -65,15 +18,8 @@ func TestCreateJobc(t *testing.T) {
}
conf.Template = string(content)
log := logger.NewLogger("test", logger.DefaultConfig())

// Create Kubernetes client
clientset, err := getKubernetesClient()
if err != nil {
t.Fatal(fmt.Errorf("creating kubernetes client: %v", err))
}

b := &Backend{
client: clientset.BatchV1().Jobs(conf.Namespace),
client: nil,
namespace: conf.Namespace,
template: conf.Template,
event: nil,
Expand All @@ -96,9 +42,4 @@ func TestCreateJobc(t *testing.T) {
t.Fatal(err)
}
t.Logf("%+v", job)

err = b.Submit(context.Background(), task)
if err != nil {
t.Fatal(err)
}
}
2 changes: 1 addition & 1 deletion compute/scheduler/testutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package scheduler
import (
"context"
"fmt"
"io/ioutil"
"os"
"testing"
"time"

Expand Down
Loading

0 comments on commit 48e607b

Please sign in to comment.