Skip to content

Commit

Permalink
Fix tests and concurrency for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
dciangot committed Nov 19, 2024
1 parent 495442f commit c07e657
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
11 changes: 7 additions & 4 deletions ci/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions ci/manifests/interlink-config-local.yaml
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 1 addition & 2 deletions pkg/interlink/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
13 changes: 9 additions & 4 deletions pkg/virtualkubelet/execute.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package virtualkubelet

import (
"bufio"
"bytes"
"context"
"encoding/json"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions pkg/virtualkubelet/virtualkubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c07e657

Please sign in to comment.