Skip to content

Commit

Permalink
Make verbosity configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Sluiter <[email protected]>
  • Loading branch information
slintes committed Dec 20, 2018
1 parent 7183914 commit 5fae6f1
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 19 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ all:
hack/dockerized "./hack/check.sh && KUBEVIRT_VERSION=${KUBEVIRT_VERSION} ./hack/build-go.sh install ${WHAT} && ./hack/build-copy-artifacts.sh ${WHAT} && DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} ./hack/build-manifests.sh"

generate:
hack/dockerized "KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} ./hack/generate.sh"
hack/dockerized "./hack/generate.sh"

apidocs:
hack/dockerized "./hack/generate.sh && ./hack/gen-swagger-doc/gen-swagger-docs.sh v1 html"
Expand Down Expand Up @@ -63,7 +63,7 @@ verify-build:
hack/verify-build.sh

manifests:
hack/dockerized "KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER} DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} ./hack/build-manifests.sh"
hack/dockerized "DOCKER_PREFIX=${DOCKER_PREFIX} DOCKER_TAG=${DOCKER_TAG} IMAGE_PULL_POLICY=${IMAGE_PULL_POLICY} VERBOSITY=${VERBOSITY} ./hack/build-manifests.sh"

.release-functest:
make functest > .release-functest 2>&1
Expand Down
2 changes: 2 additions & 0 deletions hack/build-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ for arg in $args; do
--container-prefix=${manifest_docker_prefix} \
--container-tag=${docker_tag} \
--image-pull-policy=${image_pull_policy} \
--verbosity=${verbosity} \
--input-file=${KUBEVIRT_DIR}/manifests/$arg >${outfile}

${KUBEVIRT_DIR}/tools/manifest-templator/manifest-templator \
Expand All @@ -68,6 +69,7 @@ for arg in $args; do
--container-prefix="{{ docker_prefix }}" \
--container-tag="{{ docker_tag }}" \
--image-pull-policy="{{ image_pull_policy }}" \
--verbosity=${verbosity} \
--input-file=${KUBEVIRT_DIR}/manifests/$arg >${template_outfile}
done

Expand Down
1 change: 1 addition & 0 deletions hack/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ network_provider=flannel
namespace=kubevirt
cdi_namespace=kube-system
image_pull_policy=${IMAGE_PULL_POLICY:-IfNotPresent}
verbosity=${VERBOSITY:-2}
4 changes: 2 additions & 2 deletions hack/config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
unset binaries docker_images docker_prefix docker_tag manifest_templates \
master_ip network_provider kubeconfig manifest_docker_prefix namespace image_pull_policy
master_ip network_provider kubeconfig manifest_docker_prefix namespace image_pull_policy verbosity

KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-${PROVIDER}}

Expand All @@ -13,4 +13,4 @@ test -f "hack/config-provider-${KUBEVIRT_PROVIDER}.sh" && source hack/config-pro
test -f "hack/config-local.sh" && source hack/config-local.sh

export binaries docker_images docker_prefix docker_tag manifest_templates \
master_ip network_provider kubeconfig namespace image_pull_policy
master_ip network_provider kubeconfig namespace image_pull_policy verbosity
6 changes: 3 additions & 3 deletions hack/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ ${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=vm >${KUBEVIR
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=vmim >${KUBEVIRT_DIR}/manifests/generated/vmim-resource.yaml
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=rbac --namespace={{.Namespace}} >${KUBEVIRT_DIR}/manifests/generated/rbac.authorization.k8s.yaml.in
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=prometheus --namespace={{.Namespace}} >${KUBEVIRT_DIR}/manifests/generated/prometheus.yaml.in
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=virt-api --namespace={{.Namespace}} --repository={{.DockerPrefix}} --version={{.DockerTag}} --pullPolicy={{.ImagePullPolicy}} >${KUBEVIRT_DIR}/manifests/generated/virt-api.yaml.in
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=virt-controller --namespace={{.Namespace}} --repository={{.DockerPrefix}} --version={{.DockerTag}} --pullPolicy={{.ImagePullPolicy}} >${KUBEVIRT_DIR}/manifests/generated/virt-controller.yaml.in
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=virt-handler --namespace={{.Namespace}} --repository={{.DockerPrefix}} --version={{.DockerTag}} --pullPolicy={{.ImagePullPolicy}} >${KUBEVIRT_DIR}/manifests/generated/virt-handler.yaml.in
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=virt-api --namespace={{.Namespace}} --repository={{.DockerPrefix}} --version={{.DockerTag}} --pullPolicy={{.ImagePullPolicy}} --verbosity={{.Verbosity}} >${KUBEVIRT_DIR}/manifests/generated/virt-api.yaml.in
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=virt-controller --namespace={{.Namespace}} --repository={{.DockerPrefix}} --version={{.DockerTag}} --pullPolicy={{.ImagePullPolicy}} --verbosity={{.Verbosity}} >${KUBEVIRT_DIR}/manifests/generated/virt-controller.yaml.in
${KUBEVIRT_DIR}/tools/resource-generator/resource-generator --type=virt-handler --namespace={{.Namespace}} --repository={{.DockerPrefix}} --version={{.DockerTag}} --pullPolicy={{.ImagePullPolicy}} --verbosity={{.Verbosity}} >${KUBEVIRT_DIR}/manifests/generated/virt-handler.yaml.in

(cd ${KUBEVIRT_DIR}/tools/vms-generator/ && go build)
${KUBEVIRT_DIR}/tools/vms-generator/vms-generator --generated-vms-dir=${KUBEVIRT_DIR}/cluster/examples
Expand Down
2 changes: 2 additions & 0 deletions manifests/generated/virt-api.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ spec:
- --port
- "8443"
- --subresources-only
- -v
- {{.Verbosity}}
image: {{.DockerPrefix}}/virt-api:{{.DockerTag}}
imagePullPolicy: {{.ImagePullPolicy}}
name: virt-api
Expand Down
2 changes: 2 additions & 0 deletions manifests/generated/virt-controller.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ spec:
- {{.DockerPrefix}}/virt-launcher:{{.DockerTag}}
- --port
- "8443"
- -v
- {{.Verbosity}}
image: {{.DockerPrefix}}/virt-controller:{{.DockerTag}}
imagePullPolicy: {{.ImagePullPolicy}}
livenessProbe:
Expand Down
4 changes: 2 additions & 2 deletions manifests/generated/virt-handler.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ spec:
containers:
- command:
- virt-handler
- -v
- "3"
- --port
- "8443"
- --hostname-override
- $(NODE_NAME)
- --pod-ip-address
- $(MY_POD_IP)
- -v
- {{.Verbosity}}
env:
- name: NODE_NAME
valueFrom:
Expand Down
19 changes: 13 additions & 6 deletions pkg/virt-operator/creation/components/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func newBaseDeployment(name string, namespace string, repository string, version
}, nil
}

func NewApiServerDeployment(namespace string, repository string, version string, pullPolicy corev1.PullPolicy) (*appsv1.Deployment, error) {
func NewApiServerDeployment(namespace string, repository string, version string, pullPolicy corev1.PullPolicy, verbosity string) (*appsv1.Deployment, error) {
deployment, err := newBaseDeployment("virt-api", namespace, repository, version, pullPolicy)
if err != nil {
return nil, err
Expand All @@ -174,7 +174,12 @@ func NewApiServerDeployment(namespace string, repository string, version string,

container := &deployment.Spec.Template.Spec.Containers[0]
container.Command = []string{
"virt-api", "--port", "8443", "--subresources-only",
"virt-api",
"--port",
"8443",
"--subresources-only",
"-v",
verbosity,
}
container.Ports = []corev1.ContainerPort{
{
Expand Down Expand Up @@ -205,7 +210,7 @@ func NewApiServerDeployment(namespace string, repository string, version string,
return deployment, nil
}

func NewControllerDeployment(namespace string, repository string, version string, pullPolicy corev1.PullPolicy) (*appsv1.Deployment, error) {
func NewControllerDeployment(namespace string, repository string, version string, pullPolicy corev1.PullPolicy, verbosity string) (*appsv1.Deployment, error) {
deployment, err := newBaseDeployment("virt-controller", namespace, repository, version, pullPolicy)
if err != nil {
return nil, err
Expand All @@ -224,6 +229,8 @@ func NewControllerDeployment(namespace string, repository string, version string
fmt.Sprintf("%s/%s:%s", repository, "virt-launcher", version),
"--port",
"8443",
"-v",
verbosity,
}
container.Ports = []corev1.ContainerPort{
{
Expand Down Expand Up @@ -264,7 +271,7 @@ func NewControllerDeployment(namespace string, repository string, version string
return deployment, nil
}

func NewHandlerDeamonSet(namespace string, repository string, version string, pullPolicy corev1.PullPolicy) (*appsv1.DaemonSet, error) {
func NewHandlerDeamonSet(namespace string, repository string, version string, pullPolicy corev1.PullPolicy, verbosity string) (*appsv1.DaemonSet, error) {

podTemplateSpec, err := newPodTemplateSpec("virt-handler", repository, version, pullPolicy)
if err != nil {
Expand Down Expand Up @@ -303,14 +310,14 @@ func NewHandlerDeamonSet(namespace string, repository string, version string, pu
container := &pod.Containers[0]
container.Command = []string{
"virt-handler",
"-v",
"3",
"--port",
"8443",
"--hostname-override",
"$(NODE_NAME)",
"--pod-ip-address",
"$(MY_POD_IP)",
"-v",
verbosity,
}
container.Ports = []corev1.ContainerPort{
{
Expand Down
5 changes: 5 additions & 0 deletions tools/manifest-templator/manifest-templator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package main

import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
Expand All @@ -35,6 +36,7 @@ type templateData struct {
DockerTag string
DockerPrefix string
ImagePullPolicy string
Verbosity string
GeneratedManifests map[string]string
DevManifests map[string]string
}
Expand All @@ -45,6 +47,7 @@ func main() {
dockerPrefix := flag.String("container-prefix", "", "")
dockerTag := flag.String("container-tag", "", "")
imagePullPolicy := flag.String("image-pull-policy", "IfNotPresent", "")
verbosity := flag.String("verbosity", "2", "")
genDir := flag.String("generated-manifests-dir", "", "")
devDir := flag.String("dev-manifests-dir", "", "")
inputFile := flag.String("input-file", "", "")
Expand All @@ -69,13 +72,15 @@ func main() {
data.DockerTag = *dockerTag
data.DockerPrefix = *dockerPrefix
data.ImagePullPolicy = *imagePullPolicy
data.Verbosity = fmt.Sprintf("\"%s\"", *verbosity)
} else {
// keep templates
data.Namespace = "{{.Namespace}}"
data.CDINamespace = "{{.CDINamespace}}"
data.DockerTag = "{{.DockerTag}}"
data.DockerPrefix = "{{.DockerPrefix}}"
data.ImagePullPolicy = "{{.ImagePullPolicy}}"
data.Verbosity = "{{.Verbosity}}"
}

if *processFiles {
Expand Down
7 changes: 4 additions & 3 deletions tools/resource-generator/resource-generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {
repository := flag.String("repository", "kubevirt", "Image Repository to use.")
version := flag.String("version", "latest", "version to use.")
pullPolicy := flag.String("pullPolicy", "IfNotPresent", "ImagePullPolicy to use.")
verbosity := flag.String("verbosity", "2", "Verbosity level to use.")

flag.Parse()

Expand Down Expand Up @@ -65,7 +66,7 @@ func main() {
util.MarshallObject(components.NewPrometheusService(*namespace), os.Stdout)
case "virt-api":
apisService := components.NewApiServerService(*namespace)
apiDeployment, err := components.NewApiServerDeployment(*namespace, *repository, *version, imagePullPolicy)
apiDeployment, err := components.NewApiServerDeployment(*namespace, *repository, *version, imagePullPolicy, *verbosity)
if err != nil {
panic(fmt.Errorf("error generating virt-apiserver deployment %v", err))

Expand All @@ -75,14 +76,14 @@ func main() {
util.MarshallObject(r, os.Stdout)
}
case "virt-controller":
controller, err := components.NewControllerDeployment(*namespace, *repository, *version, imagePullPolicy)
controller, err := components.NewControllerDeployment(*namespace, *repository, *version, imagePullPolicy, *verbosity)
if err != nil {
panic(fmt.Errorf("error generating virt-controller deployment %v", err))

}
util.MarshallObject(controller, os.Stdout)
case "virt-handler":
handler, err := components.NewHandlerDeamonSet(*namespace, *repository, *version, imagePullPolicy)
handler, err := components.NewHandlerDeamonSet(*namespace, *repository, *version, imagePullPolicy, *verbosity)
if err != nil {
panic(fmt.Errorf("error generating virt-handler deployment %v", err))
}
Expand Down
2 changes: 1 addition & 1 deletion tools/util/marshaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

func TestMarshallObject(t *testing.T) {

handler, err := components.NewHandlerDeamonSet("{{.Namespace}}", "{{.DockerPrefix}}", "{{.DockerTag}}", v1.PullIfNotPresent)
handler, err := components.NewHandlerDeamonSet("{{.Namespace}}", "{{.DockerPrefix}}", "{{.DockerTag}}", v1.PullIfNotPresent, "2")
if err != nil {
t.Fatalf("error generating virt-handler deployment for marshall test %v", err)
}
Expand Down

0 comments on commit 5fae6f1

Please sign in to comment.