forked from openshift/cluster-node-tuning-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
237 lines (196 loc) · 7.85 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
PACKAGE=github.com/openshift/cluster-node-tuning-operator
PACKAGE_BIN=$(lastword $(subst /, ,$(PACKAGE)))
PACKAGE_MAIN=$(PACKAGE)/cmd/$(PACKAGE_BIN)
# Build-specific variables
OUT_DIR=_output
GOBINDATA_BIN=$(OUT_DIR)/go-bindata
BINDATA=pkg/manifests/bindata.go
ASSETS=$(shell find assets -name \*.yaml)
GO=GOOS=linux GO111MODULE=on GOFLAGS=-mod=vendor go
GO_BUILD_RECIPE=$(GO) build -o $(OUT_DIR)/$(PACKAGE_BIN) -ldflags '-X $(PACKAGE)/version.Version=$(REV)' $(PACKAGE_MAIN)
GOFMT_CHECK=$(shell find . -not \( \( -wholename './.*' -o -wholename '*/vendor/*' \) -prune \) -name '*.go' | sort -u | xargs gofmt -s -l)
REV=$(shell git describe --long --tags --match='v*' --always --dirty)
# Upstream tuned daemon variables
TUNED_REPO:=https://github.com/redhat-performance/tuned.git
TUNED_COMMIT:=ce3d0926289942407cf7bdc717c464e9bf3079df
TUNED_DIR:=daemon
# API-related variables
API_TYPES_DIR:=pkg/apis
API_TYPES:=$(shell find $(API_TYPES_DIR) -name \*_types.go)
API_ZZ_GENERATED:=zz_generated.deepcopy
API_GO_HEADER_FILE:=$(API_TYPES_DIR)/header.go.txt
# Container image-related variables
IMAGE_BUILD_CMD=podman build --no-cache
IMAGE_PUSH_CMD=podman push
DOCKERFILE=Dockerfile
REGISTRY=quay.io
ORG=openshift
TAG=$(shell git rev-parse --abbrev-ref HEAD)
IMAGE=$(REGISTRY)/$(ORG)/origin-cluster-node-tuning-operator:$(TAG)
# PAO variables
CLUSTER ?= "ci"
PAO_CRD_APIS :=$(addprefix ./$(API_TYPES_DIR)/performanceprofile/,v2 v1 v1alpha1)
all: build
# Do not put any includes above the "all" target. We want the default target to build
# the operator.
include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
targets/openshift/operator/profile-manifests.mk \
targets/openshift/crd-schema-gen.mk \
)
clone-tuned:
(cd assets/tuned && \
rm -rf $(TUNED_DIR) && \
git clone -n $(TUNED_REPO) $(TUNED_DIR) && \
cd $(TUNED_DIR) && git checkout $(TUNED_COMMIT) && cd .. && \
rm -rf $(TUNED_DIR)/.git)
build: $(BINDATA) pkg/generated build-performance-profile-creator
$(GO_BUILD_RECIPE)
ln -sf $(PACKAGE_BIN) $(OUT_DIR)/openshift-tuned
$(BINDATA): $(GOBINDATA_BIN) $(ASSETS)
$(GOBINDATA_BIN) -mode 420 -modtime 1 -pkg manifests -o $(BINDATA) assets/...
gofmt -s -w $(BINDATA)
pkg/generated: $(API_TYPES)
$(GO) run k8s.io/code-generator/cmd/deepcopy-gen \
--input-dirs $(PACKAGE)/$(API_TYPES_DIR)/tuned/v1,$(PACKAGE)/$(API_TYPES_DIR)/performanceprofile/v1alpha1,$(PACKAGE)/$(API_TYPES_DIR)/performanceprofile/v1,$(PACKAGE)/$(API_TYPES_DIR)/performanceprofile/v2 \
-O $(API_ZZ_GENERATED) \
--go-header-file $(API_GO_HEADER_FILE) \
--bounding-dirs $(PACKAGE)/$(API_TYPES_DIR) \
--output-base tmp
$(GO) run k8s.io/code-generator/cmd/client-gen \
--clientset-name versioned \
--input-base '' \
--input $(PACKAGE)/$(API_TYPES_DIR)/tuned/v1 \
--go-header-file $(API_GO_HEADER_FILE) \
--output-package $(PACKAGE)/pkg/generated/clientset \
--output-base tmp
$(GO) run k8s.io/code-generator/cmd/lister-gen \
--input-dirs $(PACKAGE)/$(API_TYPES_DIR)/tuned/v1 \
--go-header-file $(API_GO_HEADER_FILE) \
--output-package $(PACKAGE)/pkg/generated/listers \
--output-base tmp
$(GO) run k8s.io/code-generator/cmd/informer-gen \
--input-dirs $(PACKAGE)/$(API_TYPES_DIR)/tuned/v1 \
--versioned-clientset-package $(PACKAGE)/pkg/generated/clientset/versioned \
--listers-package $(PACKAGE)/pkg/generated/listers \
--go-header-file $(API_GO_HEADER_FILE) \
--output-package $(PACKAGE)/pkg/generated/informers \
--output-base tmp
tar c tmp | tar x --strip-components=4
touch $@
$(GOBINDATA_BIN):
$(GO) build -o $(GOBINDATA_BIN) ./vendor/github.com/kevinburke/go-bindata/go-bindata
test-e2e:
for d in core basic reboots reboots/sno; do \
KUBERNETES_CONFIG="$(KUBECONFIG)" $(GO) test -v -timeout 40m ./test/e2e/$$d -ginkgo.v -ginkgo.no-color -ginkgo.fail-fast || exit; \
done
.PHONY: test-e2e-local
test-e2e-local: $(BINDATA) performance-profile-creator-tests
$(GO_BUILD_RECIPE)
for d in performanceprofile/functests-render-command/1_render_command; do \
$(GO) test -v -timeout 40m ./test/e2e/$$d -ginkgo.v -ginkgo.no-color -ginkgo.fail-fast || exit; \
done
update-manifests: update-codegen-crds update-profile-manifests
verify: verify-gofmt
verify-gofmt:
ifeq (, $(GOFMT_CHECK))
@echo "verify-gofmt: OK"
else
@echo "verify-gofmt: ERROR: gofmt failed on the following files:"
@echo "$(GOFMT_CHECK)"
@echo ""
@echo "For details, run: gofmt -d -s $(GOFMT_CHECK)"
@echo ""
@exit 1
endif
vet: $(BINDATA)
$(GO) vet ./...
test-unit: $(BINDATA)
$(GO) test ./cmd/... ./pkg/... -coverprofile cover.out
clean:
$(GO) clean $(PACKAGE_MAIN)
rm -rf $(BINDATA) $(OUT_DIR)
local-image:
$(IMAGE_BUILD_CMD) $(IMAGE_BUILD_EXTRA_OPTS) -t $(IMAGE) -f $(DOCKERFILE) .
local-image-push:
$(IMAGE_PUSH_CMD) $(IMAGE_PUSH_EXTRA_OPTS) $(IMAGE)
# This will generate and patch the CRDs. To update the CRDs, run "make update-codegen-crds".
# $1 - target name
# $2 - apis
# $3 - manifests
# $4 - output
$(call add-crd-gen,tuned,./$(API_TYPES_DIR)/tuned/v1,./manifests,./manifests)
$(call add-crd-gen,performanceprofile,$(PAO_CRD_APIS),./manifests,./manifests)
# This will include additional actions on the update and verify targets to ensure that profile patches are applied.
# To update the manifests, run "make update-profile-manifests".
# to manifest files
# $0 - macro name
# $1 - target name
# $2 - profile patches directory
# $3 - manifests directory
$(call add-profile-manifests,manifests,./profile-patches,./manifests)
.PHONY: all build deepcopy crd-schema-gen test-e2e update-manifests verify verify-gofmt clean local-image local-image-push
# PAO
.PHONY: generate-docs
generate-docs: dist-docs-generator
hack/docs-generate.sh
.PHONY: dist-docs-generator
dist-docs-generator:
@if [ ! -x $(OUT_DIR)/docs-generator ]; then\
echo "Building docs-generator tool";\
$(GO) build -ldflags="-s -w" -mod=vendor -o $(OUT_DIR)/docs-generator ./tools/docs-generator;\
else \
echo "Using pre-built docs-generator tool";\
fi
.PHONY: dist-latency-tests
dist-latency-tests:
./hack/build-latency-test-bin.sh
.PHONY: cluster-label-worker-cnf
cluster-label-worker-cnf:
@echo "Adding worker-cnf label to worker nodes"
hack/label-worker-cnf.sh
.PHONY: cluster-wait-for-pao-mcp
cluster-wait-for-pao-mcp:
# NOTE: for CI this is done in the config suite of the functests!
# Use this when deploying manifests manually with CLUSTER=manual
@echo "Waiting for MCP to be updated"
CLUSTER=$(CLUSTER) hack/wait-for-mcp.sh
.PHONY: cluster-deploy-pao
cluster-deploy-pao:
@echo "Deploying PAO artifacts"
CLUSTER=$(CLUSTER) hack/deploy.sh
.PHONY: pao-functests
pao-functests: cluster-label-worker-cnf pao-functests-only
.PHONY: pao-functests-only
pao-functests-only:
@echo "Cluster Version"
hack/show-cluster-version.sh
hack/run-functests.sh
.PHONY: pao-functests-updating-profile
pao-functests-updating-profile: cluster-label-worker-cnf pao-functests-update-only
.PHONY: pao-functests-update-only
pao-functests-update-only:
@echo "Cluster Version"
hack/show-cluster-version.sh
hack/run-update-testing.sh
.PHONY: pao-functests-latency-testing
pao-functests-latency-testing: dist-latency-tests
@echo "Cluster Version"
hack/show-cluster-version.sh
hack/run-latency-testing.sh
.PHONY: cluster-clean-pao
cluster-clean-pao:
@echo "Cleaning up performance addons artifacts"
hack/clean-deploy.sh
# Performance Profile Creator (PPC)
.PHONY: build-performance-profile-creator
build-performance-profile-creator:
@echo "Building Performance Profile Creator (PPC)"
LDFLAGS="-s -w -X ${PACKAGE}/cmd/performance-profile-creator/version.Version=${REV} "; \
$(GO) build -v $(LDFLAGS) -o $(OUT_DIR)/performance-profile-creator ./cmd/performance-profile-creator
.PHONY: performance-profile-creator-tests
performance-profile-creator-tests: build-performance-profile-creator
@echo "Running Performance Profile Creator Tests"
hack/run-perf-profile-creator-functests.sh
.PHONY: render-sync
render-sync: build
hack/render-sync.sh