Commit Graph

35 Commits (faa13c51adae311e187380972837d81ca60d3e54)

Author SHA1 Message Date
Ruslan Aliev d1abe6e1ea Decouple implementations and unit tests in container module
Unit test should follow black-box approach.

Change-Id: I98c46c613a73b539f79d8dfe99cd73592792536d
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #561
2 years ago
Kostiantyn Kalynovskyi a121a88a97 Add airship container cleanup
Closes: #546

Change-Id: I623694327bd6cc7dea616c109a7dcb7d97420be9
2 years ago
Kostiantyn Kalynovskyi 7c9dd85eeb Fix docker stdin write.
Without this commit airship can hang endlessly waiting for stdin
to be open. Apparently it depends on the containerd and docker
server version. This commit adds asnyc writing to stdin, this way
we don't have to wait for write to complete before starting docker
container. The code uses similar approach to upstream docker cli
implementation.

Related-To: #513

Change-Id: I2e6d4cbe37df1f8cba356af79c1c2cf18438e86c
2 years ago
Kostiantyn Kalynovskyi c17246b006 Pass HostNetwork value to docker container
This fixes a bug when in host value is specified in api object,
but it is ignored by docker

Closes: #512
Related-To: #512

Change-Id: I57e66a19124d1d0a295396491dbd22e2e2193d31
2 years ago
Ruslan Aliev e9041a2a22 Reduce the number of unnecessary document.NewBundleByPath() calls
Since document.NewBundleByPath() is pretty resource and time
consuming call (because it invokes kustomize under the hood),
we should avoid unnecessary calls of this function. There are
lots of the same constructor calls of new bundle from phase
bundle root path, mostly in helper, which slows airshipctl
and makes no sense. This patch fixes this problem by storing
phase root bundle variable in helper, which creates only once
during airshipctl execution.

Change-Id: I6b59d440f7ab7a68dc613091dafcc9e82df10eb7
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Closes: #488
2 years ago
Ruslan Aliev 92ce88fc29 Allow relative and ~ path for container mount
This patch allow to specify relative and home (~/) path for container
mounts.src field. In case if specified path is not absolute, it will be
created by following pattern: 'targetPath+mounts.src'; in case if path
contains ~/ - it will be properly expanded (it will allow us to mount
~/.airship working directory).

Change-Id: I878094371a2bc4e48216b1d076e466e3d29a86f6
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #484
Closes: #484
2 years ago
Vladislav Kuzmin 63e6012133 Mount kubeconfig to GenericContainer executor
Change-Id: Ide647fc0cfd9d281d57eeeaf8b3f9c33f59e7fdf
2 years ago
Kostiantyn Kalynovskyi 14026aadfd Allow to get container logs asynchronously
This will make sure that stderr of the generic container in gathered
in a go routine, this way we won't have to wait to see debug messages
from the container until it finishes.

Change-Id: I929719c3369f4f5796d452b5f990bf5f28a4c0d5
2 years ago
Kostiantyn Kalynovskyi 769e164b59 Implement airship container type
This will enable airship to run containers in privileged mode
as well and to specify commands to be executed.

Change-Id: I663eb55547bb821f26a9071c24d08166a3b3d56b
2 years ago
Kostiantyn Kalynovskyi d78cbe96a1 Extend Generic Container interface
This also moves KRM related logic from executors package to
container package, and creates ClientV1Alpha1 interface that
would allow us to have versioned clients for generic container
executor.

Change-Id: I4b32fd8dd089b9ccea2ed64a805702e6a8705706
2 years ago
Kostiantyn Kalynovskyi 971c81acdb Extend container interface with mounts get log opts
This commit allows to specify options to get container logs, such
as stderr, stdout and if logs should be followed.

Also extends RunCommandOptions with ability to add mounts in addtion
to binds

Relates-To: #458
Change-Id: I83507f2f7ca6ea596f52f5d3e9f868467458b6a3
2 years ago
Kostiantyn Kalynovskyi 4671ea7f74 Allow privileged mode in docker interface
Change-Id: I12e7a895c5ccd228a3bb1a2ef3588be96893ae36
2 years ago
Kostiantyn Kalynovskyi 3ae387e9f2 Change container RunMethod to allow extending
This will make sure that when we add new features to how the
docker container is run, we don't need to change interface
method signature everywhere we use it.

Relates-To: #458

Change-Id: I12273264c1a8061300017246a1a4a17125ca8ae2
2 years ago
Ruslan Aliev 01266f036e Move container phase executor to a separate package
Having an executor within container package creates
potential import cycling. This patch moves it to a separate
package which can be used to conveniently store all the executors
at one place.

Change-Id: Ibd07c2ba46d1971604bdbd9e5e360759bb68a659
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #432
3 years ago
Dmitry Ukov aa46185975 Uplift kustomize api and kyaml versions
Change-Id: Id8334a74efb7f1004a36f2bfc0c6eca81380ef4d
Relates-to: #369
3 years ago
Vladislav Kuzmin 258b81122e Add generic container executor
This executor based on kyaml.RunFns[1].
It allows to execute arbitrary container as RunFns function
and handle any input data as ExecutorBundle.
Be aware that runtimeutils.FunctionSpec used for version 0.4.1[2]
and it can be changed in the future. It means that yaml scheme
of executor can be changed during kyaml uplift.
This executor transforms executor yaml to RunFns function acceptable format.

[1] https://github.com/kubernetes-sigs/kustomize/blob/master/kyaml/runfn/runfn.go
[2] https://github.com/kubernetes-sigs/kustomize/blob/kyaml/v0.4.1/kyaml/fn/runtime/runtimeutil/functiontypes.go#L22

Change-Id: I9eb648783f1ed462d2b8359d9dc86320c4db2a83
Closes: #202
Closes: #369
3 years ago
Sidney Shiba f4e532e91a Extending Container interface and package
Adding the following method to the interface and implementation for
docker container:
- InspectContainer() - used to determine container status

Change-Id: I4a8096f4f5addad31daa5038a30b1ffcf1d424e9
3 years ago
Kostiantyn Kalynovskyi ac6e8d1194 Remove not needed context pointers in container interface
Container interface is being extended right now, because we
build new things on top of it, such as bootstrap containers.

Current version of it, was delivered as MVP and is used only
in ISOGEN. During MVP stage we didn't bother too much about
the pointers and readability. However now when we built something
new on top of it, we want to make sure that it we dont make
matters worse, and building on solid foundation.

The pointers are not needed in any way, and they are dereferenced
on top of that, context.Context is an interface, and there is
very limited theoretical use of pointers to interfaces.

Change-Id: Iee1eeb89f058aa8e994cba685b49085707362ee1
3 years ago
Ruslan Aliev ec51a71181 Add progress bar and improve cmd output for image build command
This patch provides the ability to show progress bar using
container logs (ubuntu/debian based only).

Change-Id: I86eebe4d368d81c4685fb27ca31b86cbb3dea08d
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
Relates-To: #278
3 years ago
Ruslan Aliev 09ffae277b Fix printing docker container logs
Currently, we observe non-readable artefacts in the beginning of each
log line from docker container because log stream prints logs in
multiplexed way and first 8 bytes is actually a header by default. This
patch fixes this issue by using TTY mode (in this case output data
is copied directly from the container output stream, no extra
multiplexing or headers)[1].

[1] https://godoc.org/github.com/docker/docker/client#Client.ContainerLogs

Change-Id: I26f1588936be736a124b9c77ed712ac4376f03a2
Signed-off-by: Ruslan Aliev <raliev@mirantis.com>
3 years ago
Yasin, Siraj (SY495P) 07f8a5e311 Fix for Lint warnings
* Adding comments for missing exported functions

Change-Id: I40c5861a5c076b654e5a3fc660c3c9c6d7b80c8f
Relates-To: #148
3 years ago
Stanislav Egorov 611d73a2ee Added error handler for empty runtime entry
If there is no container runtime defined in the airshipctl
config then the error message is not clear. New handler shows
specific error description

Change-Id: Ib5b735ddaa1556a8a88fdb15c4b3942cd010db9b
3 years ago
Alexander Hughes c70f4a2742 Refactor of codebase addressing IDE errors
Goland is complaining of a number of bad practices, and unused code.
This patchset addresses some of those complaints, such as:
- struct initialization without field names
- error string should not be capitalized or end with punctuation
- name starts with package name
- duplicate yaml keys
- snake case
- redundant parentheses

For the http.Transport redundant parentheses, the lint target fails
without the use of //nolint:errcheck so it has been added as
(currently) there is no potential for there to be an error returned
see [0] for example.

[0] https://golang.org/src/net/http/transport.go#L42

Change-Id: Ib1b20639c9b6e9be097ef1f158ecd7472f578488
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
3 years ago
Yasin, Siraj (SY495P) c25d223c7b Add copyright for missing files
* added license templates for go, bash & yaml in tools dir
* added a script that will add license information for all
    missing files. Type:  go, yaml, yml, sh
* skip adding license for all files within testdata
* Syntax:
   > ./tools/add_license.sh

* Skip license for manifests folder
* Added one extra line after licene for yaml files
* Added License after Hashbang for bash.
* Add an extra line after hashbang and before license
* Updated the go template to use multiline comments

New Files:
  1. tools/add_license.sh
  2. tools/license_go.txt
  3. tools/license_yaml.txt
  4. tools/license_bash.txt

Change-Id: Ia4da5b261e7cd518d446896b72c810421877472a
Realtes-To:#147
3 years ago
Dmitry Ukov e57b3ce4c0 Show isogen container logs if debug is enabled
Change-Id: I92c82eecdb35de22cc4da2326632b8af3aadd4cd
3 years ago
Zuul 6f0657be25 Merge "[#26] - Skip Image download if already downloaded" 3 years ago
Yasin, Siraj (SY495P) 0ba6748020 [#26] - Skip Image download if already downloaded
* Before performing Image Pull check if image already exists in local
* Added ImageInpspect to check if Image exists locally
* Updated Test cases

Change-Id: I9f2927325f3b86124f9d2637ba3391af33b95c71
3 years ago
Alexander Hughes 7549fdbeb0 [#86] remove unused code
A number of items were identified by GoLand's code inspection as
being unused.  These are being removed in this change.

Change-Id: I0c8c0b5f5c33f2e715f991a02ddd63174758c533
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
3 years ago
Alexander Hughes cc90889dd0 [#58] Update methods for golint
This patch addresses golint failures such as:
pkg/bootstrap/isogen/command_test.go:43:26: method GetId should be GetID
pkg/container/container_docker.go:171:27: method getImageId should be
getImageID
pkg/container/container_docker.go:193:27: method GetId should be GetID

Relates-To: #58

Change-Id: I7eb461387524f23a89bc2ae7ce59dac066c12281
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
3 years ago
Alexander Hughes 0a4764e93a [#58] Make structs golint compliant
This patch addresses golint failures such as:
pkg/bootstrap/isogen/command_test.go:24:2: struct field getId should be
getID
pkg/config/types.go:83:2: don't use leading k in Go names; struct field
kCluster should be cluster
pkg/config/types.go:108:2: don't use leading k in Go names; struct field
kContext should be context
pkg/config/types.go:113:2: don't use leading k in Go names; struct field
kAuthInfo should be authInfo
pkg/container/container_docker.go:79:2: struct field imageUrl should be
imageURL
pkg/container/container_docker_test.go:427:3: struct field imageUrl
should be imageURL
pkg/remote/redfish/redfish.go:23:2: struct field EphemeralNodeId should
be EphemeralNodeID
pkg/remote/redfish/redfish.go:29:2: struct field Api should be API

Relates-To: #58

Change-Id: Ie8d1c49c9d392f10be0f38224c98b588a9e2a544
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
3 years ago
Alexander Hughes dd1dba6eb3 [#58] Update var names to be golint compliant
This patch resolves complaints from golint such as:

cmd/config/set_authinfo_test.go:84:3: don't use leading k in Go names;
pkg/remote/redfish/redfish.go:39:2: var systemId should be systemID
pkg/remote/redfish/redfish.go:47:2: var managerId should be managerID
pkg/remote/redfish/redfish.go:51:2: var vMediaId should be vMediaID
pkg/remote/redfish/redfish.go:115:2: var parsedUrl should be parsedURL
pkg/remote/redfish/utils.go:29:2: var trimmedUrl should be trimmedURL
pkg/remote/redfish/utils.go:39:3: var rId should be rID

Relates-To: #58

Change-Id: I758565c84b44aac118d5f1cbf714224ab1ff82c5
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
3 years ago
Alexander Hughes f66f94dc80 [#58] Update error strings to be golint compliant
Error strings by convention should not end in punctuation, or contain
uppercase letters.

Relates-To: #58

Change-Id: I027fb21a20f08fdd24cf654f3ae1cbceb3e5a6c6
Signed-off-by: Alexander Hughes <Alexander.Hughes@pm.me>
3 years ago
Ian H. Pittwood 8a3950d238 Fix typos in variable names and comments
Change-Id: I361916cc18c67e72fbfdbb4b6547f80a5d098327
3 years ago
Ian Howell 49027f4151 Tighten the restrictions of the linter
This change causes the linter to be a bit more complainy. The hope is
that this will cut down on some of the more pedantic issues being caught
in code reviews, and thus reduce the overall time a change spends in the
review process.

This change includes various changes to the codebase to bring it up to
the new standards.

Change-Id: I570d304bca5554404354f972d8a2743279a0171b
3 years ago
Dmitry Ukov b37b6f3703 [AIR-137] Add logic to isogen subcommand
* Add add default values for isogen subcommand keys
* Introduce container interface
* Implement docker driver
* Add stdin support to container interface
* Implement volume mount for container

Change-Id: Ide0ecd474b1ccce358bdc9c85ef0006f230490b5
4 years ago