From 350379d43e101428b1a85e3ef50ac2ada405fc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 6 Apr 2021 10:28:34 +0200 Subject: [PATCH 1/2] ci: always run crd gen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Always run crd-gen so we can catch issues even if no go code was modified. Signed-off-by: Sébastien Han --- .github/workflows/crds-gen.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/crds-gen.yml b/.github/workflows/crds-gen.yml index f38345101..2fb7e60d6 100644 --- a/.github/workflows/crds-gen.yml +++ b/.github/workflows/crds-gen.yml @@ -1,8 +1,6 @@ name: CRDs gen on: pull_request: - paths: - - '**.go' jobs: crds-gen: From 5a194af3b1e2ff635df90f59865d05b7fb07dada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 6 Apr 2021 09:36:59 +0200 Subject: [PATCH 2/2] ceph: strip crd description for csv generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CSV file size cannot be bigger than 1MB so let's remove all the description fields make it lighter. With that change the CRDs size went from 692K to 372K so the size was reduced by almost 50%. Signed-off-by: Sébastien Han --- Makefile | 1 + build/crds/build-crds.sh | 9 +++++---- images/ceph/Makefile | 10 +++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 16bc3cea4..f6ad3c8c8 100644 --- a/Makefile +++ b/Makefile @@ -167,6 +167,7 @@ distclean: clean ## Remove all files that are created by building or configuring prune: ## Prune cached artifacts. @$(MAKE) -C images prune +csv-ceph: export MAX_DESC_LEN=0 # sets the description length to 0 since CSV cannot be bigger than 1MB csv-ceph: crds ## Generate a CSV file for OLM. @echo Generating CSV manifests @cluster/olm/ceph/generate-rook-csv.sh $(CSV_VERSION) $(CSV_PLATFORM) $(ROOK_OP_VERSION) diff --git a/build/crds/build-crds.sh b/build/crds/build-crds.sh index d61538c54..4d41cbbb6 100755 --- a/build/crds/build-crds.sh +++ b/build/crds/build-crds.sh @@ -21,8 +21,9 @@ set -o pipefail SCRIPT_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd -P) CONTROLLER_GEN_BIN_PATH=$1 YQ_BIN_PATH=$2 +: "${MAX_DESC_LEN:=-1}" # allowDangerousTypes is used to accept float64 -CRD_OPTIONS="crd:trivialVersions=true,allowDangerousTypes=true" +CRD_OPTIONS="crd:maxDescLen=$MAX_DESC_LEN,trivialVersions=true,allowDangerousTypes=true" OLM_CATALOG_DIR="${SCRIPT_ROOT}/cluster/olm/ceph/deploy/crds" CRDS_FILE_PATH="${SCRIPT_ROOT}/cluster/examples/kubernetes/ceph/crds.yaml" HELM_CRDS_FILE_PATH="${SCRIPT_ROOT}/cluster/charts/rook-ceph/templates/resources.yaml" @@ -72,13 +73,13 @@ build_helm_resources() { # add header echo "{{- if .Values.crds.enabled }}" echo "{{- if semverCompare \">=1.16.0\" .Capabilities.KubeVersion.GitVersion }}" - + # Add helm annotations to all CRDS and skip the first 4 lines of crds.yaml "$YQ_BIN_PATH" w -d'*' "$CRDS_FILE_PATH" "metadata.annotations[helm.sh/resource-policy]" keep | tail -n +5 - + # add else echo "{{- else }}" - + # add footer cat "$CRDS_BEFORE_1_16_FILE_PATH" # DO NOT REMOVE the empty line, it is necessary diff --git a/images/ceph/Makefile b/images/ceph/Makefile index e851412a8..b1689e568 100755 --- a/images/ceph/Makefile +++ b/images/ceph/Makefile @@ -67,7 +67,15 @@ do.build: generate-csv-ceph-templates generate-csv-ceph-templates: $(OPERATOR_SDK) $(YQ) @if [ ! "$(INCLUDE_CSV_TEMPLATES)" = "" ]; then\ - $(MAKE) -C ../.. crds;\ + BEFORE_GEN_CRD_SIZE=$$(wc -l < ../../cluster/examples/kubernetes/ceph/crds.yaml);\ + $(MAKE) -C ../.. MAX_DESC_LEN=0 crds;\ + AFTER_GEN_CRD_SIZE=$$(wc -l < ../../cluster/examples/kubernetes/ceph/crds.yaml);\ + if [ "$$BEFORE_GEN_CRD_SIZE" -le "$$AFTER_GEN_CRD_SIZE" ]; then\ + echo "the new crd file must be smaller since the description fields were stripped!";\ + echo "length before $$BEFORE_GEN_CRD_SIZE";\ + echo "length after $$AFTER_GEN_CRD_SIZE";\ + exit 1;\ + fi;\ OPERATOR_SDK=$(OPERATOR_SDK) YQ_TOOL=$(YQ) ../../cluster/olm/ceph/generate-rook-csv-templates.sh;\ fi