viniciusbds / navio Goto Github PK
View Code? Open in Web Editor NEWNavio is a program to create and manage linux containers. This project exists only for study purposes, so feel free to contribute :)
License: MIT License
Navio is a program to create and manage linux containers. This project exists only for study purposes, so feel free to contribute :)
License: MIT License
What would you like to be added:
Once we are inside the shell (via navio run ubuntu /bin/bash, for example), there should be some way to get out without killing the process
Document all the source code that contains the [TODO]: Document. Doesn't need document the unexported functions
e.x:
// Execute executes the root command.
// [TODO]: Document this function
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
What happened:
When we move the navio
bin to a new directory, a error on navio get images appears: the directory doesn't exists
vinicius_barbosa_silva@experiments:/usr/local/bin$ ./navio get images
[ERROR] 12:33AM --> open ./images: no such file or directory
[ERROR] 12:33AM --> invalid argument
What you expected to happen:
Check if the dir exists and if not is the case, create it
What would you like to be added:
Configure Cgroups to allow the user to limit resources using parameters
Memory
CPU
I/O
Process numbers
And others ...
run golangci-lint
Running [/home/runner/golangci-lint-1.32.2-linux-amd64/golangci-lint run --out-format=github-actions --enable goimports] in [] ...
Error: `naiveSelf` is unused (deadcode)
Error: `imgTag` is unused (deadcode)
Error: Error return value of `insForm.Exec` is not checked (errcheck)
Error: Error return value of `insForm.Exec` is not checked (errcheck)
Error: Error return value of `insForm.Exec` is not checked (errcheck)
Error: Error return value of `delForm.Exec` is not checked (errcheck)
Error: Error return value of `Insert` is not checked (errcheck)
Error: Error return value of `Remove` is not checked (errcheck)
Error: Error return value of `Pull` is not checked (errcheck)
Error: Error return value of `Pull` is not checked (errcheck)
Error: Error return value of `Pull` is not checked (errcheck)
Error: Error return value of `RemoveAll` is not checked (errcheck)
Error: Error return value of `removeContainer` is not checked (errcheck)
Error: Error return value of `removeContainerDB` is not checked (errcheck)
Error: Error return value of `CreateContainer` is not checked (errcheck)
Error: Error return value of `Remove` is not checked (errcheck)
Error: Error return value of `CreateContainer` is not checked (errcheck)
Error: Error return value of `CreateContainer` is not checked (errcheck)
Error: Error return value of `images.PrepareRootFS` is not checked (errcheck)
Error: Error return value of `updateStatus` is not checked (errcheck)
Error: Error return value of `updateStatus` is not checked (errcheck)
Error: Error return value of `os.Mkdir` is not checked (errcheck)
Error: Error return value of `os.Mkdir` is not checked (errcheck)
Error: Error return value of `os.Mkdir` is not checked (errcheck)
Error: Error return value of `Remove` is not checked (errcheck)
Error: Error return value of `rootCmd.MarkFlagRequired` is not checked (errcheck)
Error: Error return value of `images.Untar` is not checked (errcheck)
Error: Error return value of `io.Copy` is not checked (errcheck)
Error: Error return value of `containers.CreateContainer` is not checked (errcheck)
Error: Error return value of `containers.Exec` is not checked (errcheck)
Error: Error return value of `io.Tar` is not checked (errcheck)
Error: Error return value of `images.Insert` is not checked (errcheck)
Error: Error return value of `rootCmd.MarkFlagRequired` is not checked (errcheck)
Error: Error return value of `containers.CreateContainer` is not checked (errcheck)
Error: Error return value of `containers.Exec` is not checked (errcheck)
Error: Error return value of `containers.UpdateName` is not checked (errcheck)
Error: File is not `goimports`-ed (goimports)
Error: S1008: should use 'return len(strings.TrimSpace(imageName)) == 0' instead of 'if len(strings.TrimSpace(imageName)) == 0 { return true }; return false' (gosimple)
Error: SA9003: empty branch (staticcheck)
Error: SA9003: empty branch (staticcheck)
Error: SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
Error: SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
Error: issues found
Ran golangci-lint in 8253ms
Problem on the directory to download images
What happened:
The navio pull command download the image in the directory where we run the navio
binary.
What you expected to happen:
Is better define a default directory to put these images
golangci-lint
is a fast Go linters runner. It runs linters in parallel, uses caching, supports yaml
config, has integrations with all major IDE, and has dozens of linters included.
Escolher qual é a melhor opção
What happened
When we interrupt the create
command (with a CTRL + C) while the Navio is downloading a new image, we enter a state of inconsistency. Only a part of the image is downloaded and the system breaks when execute a new container that use the inconsistent image.
What you expected to happen:
The command should remove the inconsistent image and download it again
What would you like to be added:
we need use the progressbar in all I/O operations.
Develop a command that list all available images in the /images directory
This command is util after we use the pull command, to see that we have downloaded the image
Refactore it.
l.Log("INFO", fmt.Sprintf("Downloading %s from %s ...", file, url))
wgetCmd := exec.Command("wget", url)
mkdirCmd := exec.Command("mkdir", "-p", imagePath)
tarCmd := exec.Command("tar", "-C", imagePath, "-xf", file)
rmFileCmd := exec.Command("rm", file)
util.Must(wgetCmd.Run())
util.Must(mkdirCmd.Run())
util.Must(tarCmd.Run())
util.Must(rmFileCmd.Run())
Maybe is better use the os package directly ex.:
os.Mkdir(imagePath)
instead of
exec.Command("mkdir", "-p", imagePath)
What is happing:
Currently, if the user doesn't insert the --name containerName
flag we use XPTO as the containerName
see https://github.com/viniciusbds/navio/blob/master/cmd/run.go#L43
if containerName == "" {
// TODO: generate a random container name
containerName = "XPTO"
}
What you expected to happen:
The cmd run commannd must generate a random name. ex: container1928327421, instead XPTO
O vscode não consegue testar o seguinte código de teste go.
package logger
import (
"testing"
"github.com/viniciusbds/navio/src/container"
)
func TestLog(t *testing.T) {
result := container.CreateContainer([]string{"run", "ls", ""})
expected := "oi"
if result != expected {
t.Errorf("[ERROR] expected %s, result %s", expected, result)
}
}
O motivo é que para executar o código do pacote github.com/viniciusbds/navio/src/container
é necessário que o usuário tenha permissões de super usuário.
Running tool: /usr/local/go/bin/go test -timeout 30s -coverprofile=/tmp/vscode-go9DQZ83/go-code-cover github.com/viniciusbds/navio/src/logger
ERROR fork/exec ./navio: operation not permitted
FAIL github.com/viniciusbds/navio/src/logger 0.001s
FAIL
Error: Tests failed.
What would you like to be added:
Why is this needed:
When we run navio run ubuntu /bin/bash the container is create perfectly
But there is some bug on the process, because this error appears when we type: apt-get update
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
navio ps : mostra todos os containeres, indicando id, nome, status ...
navio build . --t [image-name] : gera uma imagem com base no arquivo Naviofile
navio run [image-name] [command] [args...]
navio pull image [image-name]
navio get images #10
navio remove image [image-name] #10
navio describe image [image-name]
O registro nivelado é um meio de categorizar seus registros para que você possa procurar seus registros para tipos específicos de eventos. Os níveis que vamos colocar no nosso agente de log são:
O nível info
, que representa eventos do tipo informação que informam o usuário de uma ação, como Program started
ou Email sent
. Isso nos ajuda a depurar e rastrear partes do nosso programa para ver se o comportamento esperado está acontecendo.
O nível warning
. Esses tipos de eventos identificam quando algo inesperado está acontecendo e que não é um erro, como Email failed to send, retrying
. Eles nos ajudam a ver partes do nosso programa que não estão rodando tão bem quanto esperávamos que estivessem.
O nível error
, que significa que o programa encontrou um problema, como File not found
. Frequentemente, isso resultará na falha da operação do programa.
What happened:
The build command is not calulating the size of a image
What you expected to happen:
The image size must be calulated
Aprender e usar os go modules da maneira mais eficiente para o projeto
What would you like to be added:
Adicionar um diagrama com todas as entidades do sistema. Ex.: Container, Imagem, etc ...
Why is this needed:
Fará com que novos contribuidores entendam melhor a organização do projeto, para que possam contribuir com o mesmo
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.