diff --git a/README.md b/README.md index e1801a4a..3fca03c7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ -![GitHub License](https://img.shields.io/github/license/intertwin-eu/interlink) -![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/intertwin-eu/interlink/total) +[![GitHub License](https://img.shields.io/github/license/intertwin-eu/interlink)](https://img.shields.io/github/license/intertwin-eu/interlink) ![GitHub Repo stars](https://img.shields.io/github/stars/intertwin-eu/interlink) ![GitHub Release](https://img.shields.io/github/v/release/intertwin-eu/interlink) ![Tested with Dagger](https://img.shields.io/badge/tested_with_dagger-v0.13.3-green) +[![Go Report Card](https://goreportcard.com/badge/github.com/intertwin-eu/interlink)](https://goreportcard.com/report/github.com/intertwin-eu/interlink) -![Home Page](https://img.shields.io/badge/home_page-orange?link=https%3A%2F%2Fintertwin-eu.github.io%2Ft%2FinterLink%2F) -![Slack server](https://img.shields.io/badge/slack_server-8A2BE2?link=https%3A%2F%2Fjoin.slack.com%2Ft%2Fintertwin%2Fshared_invite%2Fzt-2cs67h9wz-2DFQ6EiSQGS1vlbbbJHctA) +[![Slack server](https://img.shields.io/badge/slack_server-8A2BE2?link=https%3A%2F%2Fjoin.slack.com%2Ft%2Fintertwin%2Fshared_invite%2Fzt-2cs67h9wz-2DFQ6EiSQGS1vlbbbJHctA)](https://join.slack.com/t/intertwin/shared_invite/zt-2cs67h9wz-2DFQ6EiSQGS1vlbbbJHctA) ![Interlink logo](./docs/static/img/interlink_logo.png) 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/cmd/installer/main.go b/cmd/installer/main.go index d8eb93da..c23a3eb3 100644 --- a/cmd/installer/main.go +++ b/cmd/installer/main.go @@ -62,6 +62,7 @@ type dataStruct struct { Namespace string `yaml:"kubernetes_namespace,omitempty"` VKLimits Resources `yaml:"node_limits"` OAUTH oauthStruct `yaml:"oauth,omitempty"` + HTTPInsecure bool `default:"true" yaml:"insecure_http"` } func evalManifest(path string, dataStruct dataStruct) (string, error) { @@ -128,6 +129,7 @@ func root(cmd *cobra.Command, _ []string) error { GitHUBUser: "myusername", Issuer: "https://github.com/oauth", }, + HTTPInsecure: true, } yamlData, err := yaml.Marshal(dumpConfig) diff --git a/cmd/installer/templates/interlink-install.sh b/cmd/installer/templates/interlink-install.sh index 6c377572..5a5ab735 100644 --- a/cmd/installer/templates/interlink-install.sh +++ b/cmd/installer/templates/interlink-install.sh @@ -3,32 +3,30 @@ OS=$(uname -s) case "$OS" in - Darwin) - OS=MacOS - ;; +Darwin) + OS=MacOS + ;; esac OSARCH=$(uname -m) case "$OSARCH" in - x86_64) - OSARCH=amd64 - ;; - aarch64) - OSARCH=arm64 - ;; +x86_64) + OSARCH=amd64 + ;; +aarch64) + OSARCH=arm64 + ;; esac - #echo $OS -OS_LOWER=$(uname -s | tr '[:upper:]' '[:lower:]') +OS_LOWER=$(uname -s | tr '[:upper:]' '[:lower:]') -install () { +install() { mkdir -p $HOME/.interlink/logs || exit 1 mkdir -p $HOME/.interlink/bin || exit 1 mkdir -p $HOME/.interlink/config || exit 1 - # TODO download also service files for systemd cat <>$HOME/.interlink/config/InterLinkConfig.yaml @@ -42,13 +40,13 @@ ExportPodData: true DataRootFolder: "~/.interlink" EOF -INTERLINK_OS=$(uname -s) -INTERLINK_ARCH=$(uname -m) + INTERLINK_OS=$(uname -s) + INTERLINK_ARCH=$(uname -m) -# aarch64 is arm64 in golang. The goreleaser does not consider aarch64 as a different architecture. -if [ "$INTERLINK_ARCH" = "aarch64" ]; then - INTERLINK_ARCH="arm64" -fi + # aarch64 is arm64 in golang. The goreleaser does not consider aarch64 as a different architecture. + if [ "$INTERLINK_ARCH" = "aarch64" ]; then + INTERLINK_ARCH="arm64" + fi echo "=== Configured to reach sidecar service on unix://${HOME}/.interlink/plugin.sock. You can edit this behavior changing $HOME/.interlink/config/InterLinkConfig.yaml file. ===" @@ -56,33 +54,33 @@ fi echo "curl --fail -L -o ${HOME}/.interlink/bin/interlink https://github.com/interTwin-eu/interLink/releases/download/{{.InterLinkVersion}}/interlink_${INTERLINK_OS}_${INTERLINK_ARCH}" { - { - curl --fail -L -o ${HOME}/.interlink/bin/interlink https://github.com/interTwin-eu/interLink/releases/download/{{.InterLinkVersion}}/interlink_${INTERLINK_OS}_${INTERLINK_ARCH} - chmod +x ${HOME}/.interlink/bin/interlink - } || { - echo "Error downloading InterLink binaries, exiting..." - exit 1 - } - } + { + curl --fail -L -o ${HOME}/.interlink/bin/interlink https://github.com/interTwin-eu/interLink/releases/download/{{.InterLinkVersion}}/interlink_${INTERLINK_OS}_${INTERLINK_ARCH} + chmod +x ${HOME}/.interlink/bin/interlink + } || { + echo "Error downloading InterLink binaries, exiting..." + exit 1 + } + } ## Download oauth2 proxy case "$OS" in Darwin) - go install github.com/oauth2-proxy/oauth2-proxy/v7@latest - ;; + go install github.com/oauth2-proxy/oauth2-proxy/v7@latest + ;; Linux) - echo "https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v7.6.0/oauth2-proxy-v7.6.0.${OS_LOWER}-$OSARCH.tar.gz" + echo "https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v7.6.0/oauth2-proxy-v7.6.0.${OS_LOWER}-$OSARCH.tar.gz" + { { - { - curl --fail -L -o ${HOME}/.interlink/bin/oauth2-proxy https://github.com/dciangot/oauth2-proxy/releases/download/v0.0.3/oauth2-proxy_${OS}_$OSARCH - chmod +x ${HOME}/.interlink/bin/oauth2-proxy - } || { - echo "Error downloading OAuth binaries, exiting..." - exit 1 - } + curl --fail -L -o ${HOME}/.interlink/bin/oauth2-proxy https://github.com/dciangot/oauth2-proxy/releases/download/v0.0.3/oauth2-proxy_${OS}_$OSARCH + chmod +x ${HOME}/.interlink/bin/oauth2-proxy + } || { + echo "Error downloading OAuth binaries, exiting..." + exit 1 } + } - ;; + ;; esac if [[ ! -f ${HOME}/.interlink/config/tls.key || ! -f ${HOME}/.interlink/config/tls.crt ]]; then @@ -90,104 +88,104 @@ fi openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \ -keyout ${HOME}/.interlink/config/tls.key \ -out ${HOME}/.interlink/config/tls.crt \ - -subj "/CN=interlink.demo" -addext "subjectAltName=IP:{{.InterLinkIP}}" + -subj "/CN=interlink.demo" -addext "subjectAltName=IP:{{.InterLinkIP}}" fi } start() { - case "{{.OAUTH.Provider}}" in - oidc) - $HOME/.interlink/bin/oauth2-proxy \ - --client-id "{{.OAUTH.ClientID}}" \ - --client-secret "\"{{.OAUTH.ClientSecret}}\"" \ - --oidc-issuer-url "{{.OAUTH.Issuer}}" \ - --pass-authorization-header true \ - --provider oidc \ - --redirect-url http://localhost:8081 \ - --oidc-extra-audience {{.OAUTH.Audience}} \ - --upstream unix://${HOME}/.interlink/interlink.sock \ - --allowed-group {{.OAUTH.Group}} \ - --validate-url {{.OAUTH.TokenURL}} \ - --oidc-groups-claim {{.OAUTH.GroupClaim}} \ - --email-domain=* \ - --cookie-secret 2ISpxtx19fm7kJlhbgC4qnkuTlkGrshY82L3nfCSKy4= \ - --skip-auth-route="*='*'" \ - --force-https \ - --https-address 0.0.0.0:{{.InterLinkPort}} \ - --tls-cert-file ${HOME}/.interlink/config/tls.crt \ - --tls-key-file ${HOME}/.interlink/config/tls.key \ - --tls-cipher-suite=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384 \ - --skip-jwt-bearer-tokens true > $HOME/.interlink/logs/oauth2-proxy.log 2>&1 & - - echo $! > $HOME/.interlink/oauth2-proxy.pid - ;; - github) - $HOME/.interlink/bin/oauth2-proxy \ - --client-id {{.OAUTH.ClientID}} \ - --client-secret {{.OAUTH.ClientSecret}} \ - --pass-authorization-header true \ - --provider github \ - --redirect-url http://localhost:8081 \ - --upstream unix://$HOME/.interlink/interlink.sock \ - --email-domain="*" \ - --github-user="{{.OAUTH.GitHUBUser}}" \ - --cookie-secret 2ISpxtx19fm7kJlhbgC4qnkuTlkGrshY82L3nfCSKy4= \ - --skip-auth-route="*='*'" \ - --force-https \ - --https-address 0.0.0.0:{{.InterLinkPort}} \ - --tls-cert-file ${HOME}/.interlink/config/tls.crt \ - --tls-key-file ${HOME}/.interlink/config/tls.key \ - --tls-cipher-suite=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384 \ - --skip-jwt-bearer-tokens true > $HOME/.interlink/logs/oauth2-proxy.log 2>&1 & - - echo $! > $HOME/.interlink/oauth2-proxy.pid - ;; + case "{{.OAUTH.Provider}}" in + oidc) + $HOME/.interlink/bin/oauth2-proxy \ + --client-id "{{.OAUTH.ClientID}}" \ + --client-secret "\"{{.OAUTH.ClientSecret}}\"" \ + --oidc-issuer-url "{{.OAUTH.Issuer}}" \ + --pass-authorization-header true \ + --provider oidc \ + --redirect-url http://localhost:8081 \ + --oidc-extra-audience {{.OAUTH.Audience}} \ + --upstream unix://${HOME}/.interlink/interlink.sock \ + --allowed-group {{.OAUTH.Group}} \ + --validate-url {{.OAUTH.TokenURL}} \ + --oidc-groups-claim {{.OAUTH.GroupClaim}} \ + --email-domain=* \ + --cookie-secret 2ISpxtx19fm7kJlhbgC4qnkuTlkGrshY82L3nfCSKy4= \ + --skip-auth-route="*='*'" \ + --force-https \ + --https-address 0.0.0.0:{{.InterLinkPort}} \ + --tls-cert-file ${HOME}/.interlink/config/tls.crt \ + --tls-key-file ${HOME}/.interlink/config/tls.key \ + --tls-cipher-suite=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384 \ + --skip-jwt-bearer-tokens true >$HOME/.interlink/logs/oauth2-proxy.log 2>&1 & + + echo $! >$HOME/.interlink/oauth2-proxy.pid + ;; + github) + $HOME/.interlink/bin/oauth2-proxy \ + --client-id {{.OAUTH.ClientID}} \ + --client-secret {{.OAUTH.ClientSecret}} \ + --pass-authorization-header true \ + --provider github \ + --redirect-url http://localhost:8081 \ + --upstream unix://$HOME/.interlink/interlink.sock \ + --email-domain="*" \ + --github-user="{{.OAUTH.GitHUBUser}}" \ + --cookie-secret 2ISpxtx19fm7kJlhbgC4qnkuTlkGrshY82L3nfCSKy4= \ + --skip-auth-route="*='*'" \ + --force-https \ + --https-address 0.0.0.0:{{.InterLinkPort}} \ + --tls-cert-file ${HOME}/.interlink/config/tls.crt \ + --tls-key-file ${HOME}/.interlink/config/tls.key \ + --tls-cipher-suite=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_256_GCM_SHA384 \ + --skip-jwt-bearer-tokens true >$HOME/.interlink/logs/oauth2-proxy.log 2>&1 & + + echo $! >$HOME/.interlink/oauth2-proxy.pid + ;; esac - ## start interLink + ## start interLink export INTERLINKCONFIGPATH=${HOME}/.interlink/config/InterLinkConfig.yaml - $HOME/.interlink/bin/interlink &> ${HOME}/.interlink/logs/interlink.log & - echo $! > ${HOME}/.interlink/interlink.pid + $HOME/.interlink/bin/interlink &>${HOME}/.interlink/logs/interlink.log & + echo $! >${HOME}/.interlink/interlink.pid ## TODO: if RUN_SLURM=1 then manage also slurm } -stop () { - kill $(cat $HOME/.interlink/oauth2-proxy.pid) - kill $(cat $HOME/.interlink/interlink.pid) +stop() { + kill $(cat $HOME/.interlink/oauth2-proxy.pid) + kill $(cat $HOME/.interlink/interlink.pid) } -help () { - echo -e "\n\ninstall: Downloads InterLink and OAuth binaries, as well as InterLink configuration. Files are stored in $HOME/.interlink\n\n" - echo -e "start: Starts the OAuth proxy, the InterLink API.\n" - echo -e "stop: Kills all the previously started processes\n\n" - echo -e "restart: Kills all started processes and start them again\n\n" - echo -e "help: Shows this command list" +help() { + echo -e "\n\ninstall: Downloads InterLink and OAuth binaries, as well as InterLink configuration. Files are stored in $HOME/.interlink\n\n" + echo -e "start: Starts the OAuth proxy, the InterLink API.\n" + echo -e "stop: Kills all the previously started processes\n\n" + echo -e "restart: Kills all started processes and start them again\n\n" + echo -e "help: Shows this command list" } case "$1" in - install) - install - ;; - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - help) - help - ;; - *) - echo -e "You need to specify one of the following commands:" - help - ;; +install) + install + ;; +start) + start + ;; +stop) + stop + ;; +restart) + stop + start + ;; +help) + help + ;; +*) + echo -e "You need to specify one of the following commands:" + help + ;; esac diff --git a/cmd/installer/templates/values.yaml b/cmd/installer/templates/values.yaml index 1e0f02f9..03c7b90d 100644 --- a/cmd/installer/templates/values.yaml +++ b/cmd/installer/templates/values.yaml @@ -11,6 +11,8 @@ virtualNode: HTTPProxies: HTTP: null HTTPs: null + HTTP: + Insecure: {{.HTTPInsecure}} OAUTH: TokenURL: {{.OAUTH.TokenURL}} diff --git a/cmd/ssh-tunnel/main.go b/cmd/ssh-tunnel/main.go index 5c346174..0880beb5 100644 --- a/cmd/ssh-tunnel/main.go +++ b/cmd/ssh-tunnel/main.go @@ -65,17 +65,26 @@ func main() { hostkeyFile := flag.String("hostkeyfile", "", "file with public key for SSH host check") flag.Parse() - pubkey, err := os.ReadFile(*hostkeyFile) - if err != nil { - log.Fatalf("unable to read private key: %v", err) - } - hostkey, err := ssh.ParsePublicKey(pubkey) - if err != nil { - log.Fatalf("unable to parse private key: %v", err) - } + var hostKeyCallback ssh.HostKeyCallback + + if *hostkeyFile == "" { + log.Print("No hostkey passed, proceeding with insecure hostkey callback mode") + hostKeyCallback = ssh.HostKeyCallback( + func(_ string, _ net.Addr, _ ssh.PublicKey) error { + return nil + }) + } else { + pubkey, err := os.ReadFile(*hostkeyFile) + if err != nil { + log.Fatalf("unable to hostkeyFile: %v", err) + } + hostkey, err := ssh.ParsePublicKey(pubkey) + if err != nil { + log.Fatalf("unable to parse private key: %v", err) + } - hostKeyCallback := trustedHostKeyCallback(hostkey) - // Implement a HostKeyCallback to verify the server's host key + hostKeyCallback = trustedHostKeyCallback(hostkey) + } key, err := os.ReadFile(*keyFile) if err != nil { diff --git a/docs/docs/Cookbook.mdx b/docs/docs/Cookbook.mdx index e9bbc82e..6bc4178e 100644 --- a/docs/docs/Cookbook.mdx +++ b/docs/docs/Cookbook.mdx @@ -364,6 +364,8 @@ In general, starting from the deployment of the remote components is adviced. Si +- Start the plugins passing the configuration that you have just created. + #### Test interLink stack health diff --git a/docs/docs/guides/01-deploy-interlink.mdx b/docs/docs/guides/01-deploy-interlink.mdx index 8ecc2ec3..469b8a05 100644 --- a/docs/docs/guides/01-deploy-interlink.mdx +++ b/docs/docs/guides/01-deploy-interlink.mdx @@ -71,14 +71,14 @@ Login into the machine and and download the interLink **installer CLI** for your ```bash export VERSION=0.2.3-pre6 -wget -O interlink-install https://github.com/interTwin-eu/interLink/releases/download/$VERSION/interlink-install_Linux_x86_64 -chmod +x interlink-install +wget -O interlink-installer https://github.com/interTwin-eu/interLink/releases/download/$VERSION/interlink-installer_Linux_x86_64 +chmod +x interlink-installer ``` The CLI offers a utility option to initiate an empty config file for the installation at `$HOME/.interlink.yaml`: ```bash -./interlink-install --init +./interlink-installer --init ``` You are now ready to go ahead and edit the produced file with all the setup information. @@ -133,7 +133,7 @@ You are ready now to go ahead generating the needed manifests and script for the Login into the machine and generate the manifests and the automatic interlink installation script with: ```bash -./interlink-install +./interlink-installer ``` follow the instruction to authenticate with the device code flow and, if everything went well, you should get an output like the following: diff --git a/docs/docs/intro.mdx b/docs/docs/intro.mdx index d1b7fa36..e68ebdae 100644 --- a/docs/docs/intro.mdx +++ b/docs/docs/intro.mdx @@ -6,15 +6,16 @@ import useBaseUrl from '@docusaurus/useBaseUrl'; # Introduction -![GitHub License](https://img.shields.io/github/license/intertwin-eu/interlink) -![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/intertwin-eu/interlink/total) +[![GitHub License](https://img.shields.io/github/license/intertwin-eu/interlink)](https://img.shields.io/github/license/intertwin-eu/interlink) ![GitHub Repo stars](https://img.shields.io/github/stars/intertwin-eu/interlink) ![GitHub Release](https://img.shields.io/github/v/release/intertwin-eu/interlink) ![Tested with Dagger](https://img.shields.io/badge/tested_with_dagger-v0.13.3-green) +[![Go Report Card](https://goreportcard.com/badge/github.com/intertwin-eu/interlink)](https://goreportcard.com/report/github.com/intertwin-eu/interlink) [![Slack server](https://img.shields.io/badge/slack_server-8A2BE2?link=https%3A%2F%2Fjoin.slack.com%2Ft%2Fintertwin%2Fshared_invite%2Fzt-2cs67h9wz-2DFQ6EiSQGS1vlbbbJHctA)](https://join.slack.com/t/intertwin/shared_invite/zt-2cs67h9wz-2DFQ6EiSQGS1vlbbbJHctA) + :::warning interLink is in early development phase, thus subject to breaking changes with no guarantee of backward compatibility. diff --git a/docs/src/pages/index.tsx b/docs/src/pages/index.tsx index 2825c0fb..5c6df02d 100644 --- a/docs/src/pages/index.tsx +++ b/docs/src/pages/index.tsx @@ -39,9 +39,11 @@ function HomepageHeader() { - Stars + Stars window.location.href='https://github.com/interTwin-eu/interLink'}/>
Slack window.location.href='https://join.slack.com/t/intertwin/shared_invite/zt-2cs67h9wz-2DFQ6EiSQGS1vlbbbJHctA'}/> +
+ GoReport window.location.href='https://goreportcard.com/report/github.com/intertwin-eu/interlink'}/> diff --git a/docs/static/img/interlink_logo-dark.png b/docs/static/img/interlink_logo-dark.png index eceecc94..b00e4207 100644 Binary files a/docs/static/img/interlink_logo-dark.png and b/docs/static/img/interlink_logo-dark.png differ diff --git a/docs/static/img/interlink_logo.png b/docs/static/img/interlink_logo.png index c015c356..b00e4207 100644 Binary files a/docs/static/img/interlink_logo.png and b/docs/static/img/interlink_logo.png differ diff --git a/docs/static/img/scenario-3_dark.svg b/docs/static/img/scenario-3_dark.svg index d0d52c3f..fba76705 100644 --- a/docs/static/img/scenario-3_dark.svg +++ b/docs/static/img/scenario-3_dark.svg @@ -10,4 +10,4 @@ - LOGIN NODE ON RESOURCE PROVIDER3. No INBOUND connectivity to the HPCVirtual KubeletInterlink API ServerProvider pluginPod on virtual nodeVirtual NodeSSH UNIX SOCKETunix socketPodContainersBatchSystemSSH agentunix socketSSHtunnelsocket \ No newline at end of file + LOGIN NODE ON RESOURCE PROVIDER3. No INBOUND connectivity to the HPCVirtual KubeletInterlink API ServerProvider pluginPod on virtual nodeVirtual NodeSSH UNIX SOCKETunix socketPodContainersBatchSystemSSH agentunix socketSSHtunnelsocket diff --git a/docs/static/img/scenario-3_light.svg b/docs/static/img/scenario-3_light.svg index 6c8448e6..f801074f 100644 --- a/docs/static/img/scenario-3_light.svg +++ b/docs/static/img/scenario-3_light.svg @@ -10,4 +10,4 @@ - LOGIN NODE ON RESOURCE PROVIDER3. No INBOUND connectivity to the HPCVirtual KubeletInterlink API ServerProvider pluginPod on virtual nodeVirtual NodeSSH UNIX SOCKETunix socketPodContainersBatchSystemSSH agentunix socketSSHtunnelsocket \ No newline at end of file + LOGIN NODE ON RESOURCE PROVIDER3. No INBOUND connectivity to the HPCVirtual KubeletInterlink API ServerProvider pluginPod on virtual nodeVirtual NodeSSH UNIX SOCKETunix socketPodContainersBatchSystemSSH agentunix socketSSHtunnelsocket diff --git a/pkg/interlink/api/handler.go b/pkg/interlink/api/handler.go index 31ad7125..308ce4ce 100644 --- a/pkg/interlink/api/handler.go +++ b/pkg/interlink/api/handler.go @@ -41,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 cf9c8795..aece8aa4 100644 --- a/pkg/virtualkubelet/execute.go +++ b/pkg/virtualkubelet/execute.go @@ -113,24 +113,23 @@ func PingInterLink(ctx context.Context, config Config) (bool, int, error) { spanHTTP.SetAttributes(attribute.Int("exit.code", http.StatusInternalServerError)) return false, retVal, err } + defer resp.Body.Close() - if resp != nil { - types.SetDurationSpan(startHTTPCall, spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) - retBytes, err := io.ReadAll(resp.Body) - if err != nil { - log.G(ctx).Error(err) - return false, retVal, err - } - retVal, err = strconv.Atoi(string(retBytes)) - if err != nil { - log.G(ctx).Error(err) - return false, retVal, err - } + types.SetDurationSpan(startHTTPCall, spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) + retBytes, err := io.ReadAll(resp.Body) + if err != nil { + log.G(ctx).Error(err) + return false, retVal, err + } + retVal, err = strconv.Atoi(string(retBytes)) + if err != nil { + log.G(ctx).Error(err) + return false, retVal, err + } - if resp.StatusCode != http.StatusOK { - log.G(ctx).Error("server error: " + fmt.Sprint(resp.StatusCode)) - return false, retVal, nil - } + if resp.StatusCode != http.StatusOK { + log.G(ctx).Error("server error: " + fmt.Sprint(resp.StatusCode)) + return false, retVal, nil } return true, retVal, nil @@ -165,11 +164,11 @@ func updateCacheRequest(ctx context.Context, config Config, pod v1.Pod, token st log.L.Error(err) return err } - if resp != nil { - types.SetDurationSpan(startHTTPCall, *spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) - if resp.StatusCode != http.StatusOK { - return errors.New("Unexpected error occured while updating InterLink cache. Status code: " + strconv.Itoa(resp.StatusCode) + ". Check InterLink's logs for further informations") - } + defer resp.Body.Close() + + types.SetDurationSpan(startHTTPCall, *spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) + if resp.StatusCode != http.StatusOK { + return errors.New("Unexpected error occured while updating InterLink cache. Status code: " + strconv.Itoa(resp.StatusCode) + ". Check InterLink's logs for further informations") } return err @@ -180,11 +179,6 @@ func updateCacheRequest(ctx context.Context, config Config, pod v1.Pod, token st func createRequest(ctx context.Context, config Config, pod types.PodCreateRequests, token string) ([]byte, error) { tracer := otel.Tracer("interlink-service") interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport) - returnValue, err := json.Marshal(types.CreateStruct{}) - if err != nil { - log.L.Error(err) - return nil, err - } bodyBytes, err := json.Marshal(pod) if err != nil { @@ -213,18 +207,17 @@ func createRequest(ctx context.Context, config Config, pod types.PodCreateReques log.L.Error(err) return nil, err } + defer resp.Body.Close() - if resp != nil { - types.SetDurationSpan(startHTTPCall, spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) + types.SetDurationSpan(startHTTPCall, spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) - if resp.StatusCode != http.StatusOK { - return nil, errors.New("Unexpected error occured while creating Pods. 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 - } + if resp.StatusCode != http.StatusOK { + return nil, errors.New("Unexpected error occured while creating Pods. 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 returnValue, nil @@ -255,27 +248,26 @@ func deleteRequest(ctx context.Context, config Config, pod *v1.Pod, token string log.G(context.Background()).Error(err) return nil, err } + defer resp.Body.Close() - if resp != nil { - statusCode := resp.StatusCode - types.SetDurationSpan(startHTTPCall, *spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) + statusCode := resp.StatusCode + types.SetDurationSpan(startHTTPCall, *spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) - if statusCode != http.StatusOK { - return nil, errors.New("Unexpected error occured while deleting Pods. Status code: " + strconv.Itoa(resp.StatusCode) + ". Check InterLink's logs for further informations") - } + if statusCode != http.StatusOK { + return nil, errors.New("Unexpected error occured while deleting Pods. Status code: " + strconv.Itoa(resp.StatusCode) + ". Check InterLink's logs for further informations") + } - returnValue, err := io.ReadAll(resp.Body) - if err != nil { - log.G(context.Background()).Error(err) - return nil, err - } - log.G(context.Background()).Info(string(returnValue)) - var response []types.PodStatus - err = json.Unmarshal(returnValue, &response) - if err != nil { - log.G(context.Background()).Error(err) - return nil, err - } + returnValue, err = io.ReadAll(resp.Body) + if err != nil { + log.G(context.Background()).Error(err) + return nil, err + } + log.G(context.Background()).Info(string(returnValue)) + var response []types.PodStatus + err = json.Unmarshal(returnValue, &response) + if err != nil { + log.G(context.Background()).Error(err) + return nil, err } return returnValue, nil @@ -286,11 +278,6 @@ func deleteRequest(ctx context.Context, config Config, pod *v1.Pod, token string // Returns the call response expressed in bytes and/or the first encountered error func statusRequest(ctx context.Context, config Config, podsList []*v1.Pod, token string) ([]byte, error) { tracer := otel.Tracer("interlink-service") - returnValue, err := json.Marshal(types.PodStatus{}) - if err != nil { - log.L.Error(err) - return nil, err - } interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport) @@ -319,17 +306,21 @@ func statusRequest(ctx context.Context, config Config, podsList []*v1.Pod, token if err != nil { return nil, err } + defer resp.Body.Close() - if resp != nil { - 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) + types.SetDurationSpan(startHTTPCall, spanHTTP, types.WithHTTPReturnCode(resp.StatusCode)) + if resp.StatusCode != http.StatusOK { + 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 { + log.L.Error(err) + return nil, err } return returnValue, nil @@ -340,7 +331,6 @@ func statusRequest(ctx context.Context, config Config, podsList []*v1.Pod, token // Returns the call response and/or the first encountered error func LogRetrieval(ctx context.Context, config Config, logsRequest types.LogStruct) (io.ReadCloser, error) { tracer := otel.Tracer("interlink-service") - var returnValue io.ReadCloser interLinkEndpoint := getSidecarEndpoint(ctx, config.InterlinkURL, config.Interlinkport) token := "" @@ -382,17 +372,15 @@ func LogRetrieval(ctx context.Context, config Config, logsRequest types.LogStruc log.G(ctx).Error(err) return nil, err } + // defer resp.Body.Close() - if resp != nil { - 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") - } else { - returnValue = resp.Body - } + 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 returnValue, 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)