diff --git a/ci/main.go b/ci/main.go index 0ec391d3..e3024229 100644 --- a/ci/main.go +++ b/ci/main.go @@ -56,6 +56,7 @@ type Interlink struct { KubeConfigHost *dagger.File InterlinkContainer *dagger.Container VKContainer *dagger.Container + PluginContainer *dagger.Container } // New initializes the Dagger module at each call @@ -67,7 +68,7 @@ func New(name string, // +default="ghcr.io/intertwin-eu/interlink/interlink:0.3.1-rc1" InterlinkRef string, // +optional - // +default="ghcr.io/intertwin-eu/interlink-sidecar-slurm/interlink-sidecar-slurm:0.3.2" + // +default="ghcr.io/intertwin-eu/interlink-sidecar-slurm/interlink-sidecar-slurm:0.3.6" pluginRef string, ) *Interlink { @@ -112,14 +113,14 @@ func (m *Interlink) NewInterlink( var err error if pluginEndpoint == nil { - plugin := dag.Container().From(m.PluginRef). + m.PluginContainer = dag.Container().From(m.PluginRef). WithFile("/etc/interlink/InterLinkConfig.yaml", pluginConfig). WithEnvVariable("SLURMCONFIGPATH", "/etc/interlink/InterLinkConfig.yaml"). WithEnvVariable("SHARED_FS", "true"). WithExposedPort(4000). WithExec([]string{}, dagger.ContainerWithExecOpts{UseEntrypoint: true, InsecureRootCapabilities: true}) - pluginEndpoint, err = plugin.AsService().Start(ctx) + pluginEndpoint, err = m.PluginContainer.AsService().Start(ctx) if err != nil { return nil, err } @@ -400,7 +401,9 @@ func (m *Interlink) Test( return nil, err } - result := c.WithExec([]string{"bash", "-c", "source .venv/bin/activate && export KUBECONFIG=/.kube/config && pytest -vk 'not rclone and not limits'"}) + // result := c.WithExec([]string{"bash", "-c", "source .venv/bin/activate && export KUBECONFIG=/.kube/config && pytest -vk 'not rclone and not limits'"}) + //_ = c.WithExec([]string{"bash", "-c", "source .venv/bin/activate && export KUBECONFIG=/.kube/config && pytest -vk 'hello'"}) + result := c.WithExec([]string{"bash", "-c", "source .venv/bin/activate && export KUBECONFIG=/.kube/config && pytest -vk 'hello'"}) return result, nil diff --git a/ci/manifests/interlink-config-local.yaml b/ci/manifests/interlink-config-local.yaml new file mode 100644 index 00000000..712cd96f --- /dev/null +++ b/ci/manifests/interlink-config-local.yaml @@ -0,0 +1,17 @@ +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: "interlink-config" +# namespace: interlink +# data: +# InterLinkConfig.yaml: | + #InterlinkAddress: "unix:///var/run/interlink.socket" +InterlinkAddress: "http://0.0.0.0" +InterlinkPort: "3000" +#SidecarURL: "http://plugin" +SidecarURL: "http://0.0.0.0" +SidecarPort: "4000" +VerboseLogging: true +ErrorsOnlyLogging: false +ExportPodData: true +DataRootFolder: "~/.interlink" diff --git a/pkg/interlink/api/handler.go b/pkg/interlink/api/handler.go index 38981558..308ce4ce 100644 --- a/pkg/interlink/api/handler.go +++ b/pkg/interlink/api/handler.go @@ -26,7 +26,6 @@ func DoReq(req *http.Request) (*http.Response, error) { if err != nil { return nil, err } - defer resp.Body.Close() return resp, nil } @@ -42,13 +41,13 @@ func ReqWithError( req.Header.Set("Content-Type", "application/json") resp, err := DoReq(req) - if err != nil { statusCode := http.StatusInternalServerError w.WriteHeader(statusCode) log.G(ctx).Error(err) return nil, err } + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { statusCode := http.StatusInternalServerError diff --git a/pkg/virtualkubelet/execute.go b/pkg/virtualkubelet/execute.go index 5a0fee54..aece8aa4 100644 --- a/pkg/virtualkubelet/execute.go +++ b/pkg/virtualkubelet/execute.go @@ -1,7 +1,6 @@ package virtualkubelet import ( - "bufio" "bytes" "context" "encoding/json" @@ -311,7 +310,12 @@ func statusRequest(ctx context.Context, config Config, podsList []*v1.Pod, token types.SetDurationSpan(startHTTPCall, spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) if resp.StatusCode != http.StatusOK { - return nil, errors.New("Unexpected error occured while getting status. Status code: " + strconv.Itoa(resp.StatusCode) + ". Check InterLink's logs for further informations") + returnValue, err := io.ReadAll(resp.Body) + if err != nil { + log.L.Error(err) + return nil, err + } + return nil, errors.New("Unexpected error occured while getting status. Status code: " + strconv.Itoa(resp.StatusCode) + ". Check InterLink's logs for further informations\n" + string(returnValue)) } returnValue, err := io.ReadAll(resp.Body) if err != nil { @@ -368,14 +372,15 @@ func LogRetrieval(ctx context.Context, config Config, logsRequest types.LogStruc log.G(ctx).Error(err) return nil, err } - defer resp.Body.Close() + // defer resp.Body.Close() types.SetDurationSpan(startHTTPCall, spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) if resp.StatusCode != http.StatusOK { err = errors.New("Unexpected error occured while getting logs. Status code: " + strconv.Itoa(resp.StatusCode) + ". Check InterLink's logs for further informations") } - return io.NopCloser(bufio.NewReader(resp.Body)), err + // return io.NopCloser(bufio.NewReader(resp.Body)), err + return resp.Body, err } // RemoteExecution is called by the VK everytime a Pod is being registered or deleted to/from the VK. diff --git a/pkg/virtualkubelet/virtualkubelet.go b/pkg/virtualkubelet/virtualkubelet.go index c7114232..4d92056a 100644 --- a/pkg/virtualkubelet/virtualkubelet.go +++ b/pkg/virtualkubelet/virtualkubelet.go @@ -381,6 +381,7 @@ func (p *Provider) nodeUpdate(ctx context.Context) { p.node.Status.Conditions = NodeCondition(false) p.onNodeChangeCallback(p.node) log.G(ctx).Error("Ping Failed with exit code: ", code) + log.G(ctx).Error("Error: ", err) } else { p.node.Status.Conditions = NodeCondition(true)