kdevops: embrace kconfig selective yaml output
cover kdevops: embrace kconfig selective yaml output
13 days ago I posted an RFC for Linux upstream to support selective yaml output on kconfig [0]. What this does is it lets you annnotate "output yaml" on kconfig symbols and if you do that you also get an additional yaml output of only those symbols. Long ago I theorized we could do something like this so to avoid having to do Makefile edits like this to propagate variables to ansible:
ifeq (y,$(CONFIG_GUESTFS_REQUIRES_UEFI))GUESTFS_ARGS += guestfs_requires_uefi=True
endif
Alternatives to this are to do full config postprocessing and converting all symbols to yaml entries, or even having an inclusion file to determine which variables should be converted.
The kconfig selective yaml output support streamlines the need by easily associating which symbols you want to be converted over to yaml directly on the kconfig file itself:
config GUESTFS_REQUIRES_UEFI
bool
+ output yaml
Since there are no upstream users of this in the kernel it is obvious that this likely wouldn't have been desirable to be maintained in the kernel, and Masahiro Yamada confirmed so. So this is not upstreamable to Linux. However, we can just carry the delta forward as its rather small. What this would mean for us since we are using a git subtree for kconfig is that we embrace a yamlconfig branch on kconfig and keep that with the small delta. It can sync with the master branch when new updates for new linux-next tags are updated.
I believe that considering the alternatives, carrying the delta forward on a branch on kconfig for this is a much more straight forward approach but I would like to hear other's opinions on this now that we have the work done and a proof of concept completed. This approach lets us clearly annotate the inclusion process of conversion of kconfig symbols to ansible variables, while also allowing the extra_vars.yaml file to remain slim. This makes a deterministic association between kconfig symbol and ansible variables names clear. The value in this we remove ambiguation between kconfig symbol and ansible variables, while also allowing us to keep our Makefiles for workflows pretty small, removing the complexities in variable conversion.
The work left is then:
a) We need to see how a delta in our kconfig could be maintained
b) What the code changes for actual selective yaml output would look like
c) What the cleanups actually look like as a demonstration
For a) it's real simple: we keep a yamlconfig branch on the kconfig tree [1]. Likewise a demonstration project which uses this would be needed, for that I have created the yamlconfig branch on init-kconfig [2]. The previous patches lets us upgrade the kconfig use din kdevops up to the kconfig as of linux-next tag next-20240830. Now to merge the changes required for yamlconfig all we need to do is run:
git subtree --squash pull --prefix=scripts/kconfig/ kconfig yamlconfig
The patches in this series then make use of this optional feature and demonstrate how it fits into kdevops. The last patch is really what I was hoping for to demonstrate. The third patch in this series titled "scripts/ssh.Makefile: remove Makefile appending of KDEVOPS_HOSTS_PREFIX" demonstrates how easy it is for us to loose ourselves with variables and havne't even realized it. It implicates a long term cleanup we should strive to where essentially we won't have to expect users of the old variables so we remove the pesky old variables.
What this does is, it let's us *selectively* move forward with the conversion proceess workflow by workflow, while allowing *new* workflows to come in squeeky clean from the start because proper determinism on variable names would be used from the start.
The real meat and bones and rationale for this effort is demonstrated on the last patch. Thoughts?
If you want to take this for a spin:
https://github.com/mcgrof/kdevops/tree/yamlconfig
PS. nconfig doesn't yet have yamlconfig support, I can add it easily if this approach is agreeable.
[0] https://lkml.kernel.org/r/[email protected]
[1] https://github.com/linux-kdevops/kconfig/tree/yamlconfig
[2] https://github.com/linux-kdevops/init-kconfig/tree/yamlconfig
Luis Chamberlain (5):
Makefile: add support for selective yamlconfig scripts/guestfs.Makefile: use output yaml for GUESTFS_REQUIRES_UEFI scripts/ssh.Makefile: remove Makefile appending of
KDEVOPS_HOSTS_PREFIX
workflows/Makefile: replace direct named entries with output yaml
fstests: use selective yaml output on a slew of different variables
Makefile | 3 ++- Makefile.extra_vars | 11 +++++---- kconfigs/Kconfig.guestfs | 1 + kconfigs/Kconfig.kdevops | 7 ++++++ kconfigs/workflows/Kconfig | 8 +++++++ scripts/gen-hosts.Makefile | 1 - scripts/guestfs.Makefile | 4 ---- scripts/ssh.Makefile | 3 --- workflows/Makefile | 8 ------- workflows/fstests/Kconfig | 11 +++++++++ workflows/fstests/Makefile | 46 -------------------------------------- 11 files changed, 34 insertions(+), 69 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/5 Makefile: add support for selective yamlconfig
Leverage support for selective yaml config support, this will let us start removing the requirement to use Makefiles to append variables into extra_vars.yaml, all we need to do is use the "output yaml" on the symbols we want converted over.
--- Makefile | 3 ++- Makefile.extra_vars | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
Makefile +2 -1
@@ -9,6 +9,7 @@ EXTRAVERSION = all: deps export KCONFIG_DIR=$(CURDIR)/scripts/kconfig +export KCONFIG_YAMLCFG=$(CURDIR)/.extra_vars_auto.yaml include $(KCONFIG_DIR)/kconfig.Makefile include Makefile.subtrees
@@ -250,7 +251,7 @@ mrproper: $(Q)rm -f terraform/*/terraform.tfvars $(Q)rm -f $(KDEVOPS_NODES) $(Q)rm -f $(KDEVOPS_HOSTFILE) $(KDEVOPS_MRPROPER) - $(Q)rm -f .config .config.old extra_vars.yaml + $(Q)rm -f .config .config.old extra_vars.yaml $(KCONFIG_YAMLCFG) $(Q)rm -f playbooks/secret.yml $(KDEVOPS_EXTRA_ADDON_DEST) $(Q)rm -rf include
Makefile.extra_vars +5 -6
@@ -45,13 +45,12 @@ endef #$(patsubst $(firstword $(subst =, ,$(1)))=%,$(firstword $(subst =, ,$(1))):%,$(1)) #$(patsubst $(firstword $(subst =, ,$(1))=)%,$(firstword $(subst =, , $(1):)%,$(1)),$(1)) -# We can transform most of .config things we need to using -# looping on ANSIBLE_EXTRA_ARGS and converting those with -# this target. If you need to do more complex fancy stuff -# extend the EXTRA_VAR_INPUTS variable in your workflow with -# your custom stuff. +# extra_vars.yaml first gets the selective yaml entries which kconfig writes +# to for us in KCONFIG_YAMLCFG, then we expand on it with more dynamic data. +# We use awk NF to just remove empty lines. most_extra_vars: - @echo --- > $(KDEVOPS_EXTRA_VARS) + @awk NF $(KCONFIG_YAMLCFG) > $(KDEVOPS_EXTRA_VARS) + @echo "# end of of yamlconfig auto output yaml variables " >> $(KDEVOPS_EXTRA_VARS) @$(foreach exp,$(ANSIBLE_EXTRA_ARGS),echo $(call YAML_ENTRY,$(subst =,: ,$(exp)) >> $(KDEVOPS_EXTRA_VARS))) # ANSIBLE_EXTRA_ARGS_SEPARATED is to be used for variables in .config
Signature · 1 line
2.43.0
PATCH 2/5 scripts/guestfs.Makefile: use output yaml for GUESTFS_REQUIRES_UEFI
In reply to Luis ChamberlainSince the kconfig symbol name GUESTFS_REQUIRES_UEFI and the ansible variable match exactly we can now just use "output yaml" on the GUESTFS_REQUIRES_UEFI symbol, and so we don't need the Makefile hack to ensure the variable gets converted over. This simplifies our Makefiles considerably.
--- kconfigs/Kconfig.guestfs | 1 + scripts/guestfs.Makefile | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-)
kconfigs/Kconfig.guestfs +1 -0
@@ -8,6 +8,7 @@ config GUESTFS_HAS_CUSTOM_RAW_IMAGE_URL config GUESTFS_REQUIRES_UEFI bool + output yaml config GUESTFS_CUSTOM_RAW_IMAGE_URL depends on GUESTFS_HAS_CUSTOM_RAW_IMAGE
scripts/guestfs.Makefile +0 -4
@@ -7,10 +7,6 @@ KDEVOPS_NODES := guestfs/kdevops_nodes.yaml export KDEVOPS_PROVISIONED_SSH := $(KDEVOPS_PROVISIONED_SSH_DEFAULT_GUARD) -ifeq (y,$(CONFIG_GUESTFS_REQUIRES_UEFI)) -GUESTFS_ARGS += guestfs_requires_uefi=True -endif - GUESTFS_ARGS += kdevops_enable_guestfs=True GUESTFS_ARGS += guestfs_path='$(TOPDIR_PATH)/guestfs' GUESTFS_ARGS += data_home_dir=/home/kdevops
Signature · 1 line
2.43.0
PATCH 3/5 scripts/ssh.Makefile: remove Makefile appending of KDEVOPS_HOSTS_PREFIX
In reply to Luis ChamberlainWe have CONFIG_KDEVOPS_HOSTS_PREFIX but have two respective ansible variable:
* kdevops_host_prefix
* kdevops_hosts_prefix
We need to keep these for now to ensure old configs work and so existing extra_vars.yaml continue to work. We at least annotate these for future unification into a release where folks are not going to use the old symbols on existing running environments.
We can later look for these with:
git grep ^"# old-yamlconfig-compat"
--- kconfigs/Kconfig.kdevops | 7 +++++++ scripts/gen-hosts.Makefile | 1 - scripts/ssh.Makefile | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-)
kconfigs/Kconfig.kdevops +7 -0
@@ -57,6 +57,7 @@ config KDEVOPS_HOSTS_PREFIX_SET_BY_CLI config KDEVOPS_HOSTS_PREFIX string "The hostname prefix to use for nodes" + output yaml default $(shell, ./scripts/append-makefile-vars.sh $(KDEVOPS_HOSTS_PREFIX)) if KDEVOPS_HOSTS_PREFIX_SET_BY_CLI default "kdevops" if !KDEVOPS_USE_DISTRO_HOSTS_PREFIX && !KDEVOPS_HOSTS_PREFIX_SET_BY_CLI default CUSTOM_DISTRO_HOST_PREFIX if KDEVOPS_USE_DISTRO_HOSTS_PREFIX && !KDEVOPS_HOSTS_PREFIX_SET_BY_CLI
@@ -65,6 +66,12 @@ config KDEVOPS_HOSTS_PREFIX help distinguish projects / goals for a set of nodes. You can use this to override the hostname prefix used. +# old-yamlconfig-compat +config KDEVOPS_HOST_PREFIX + string + output yaml + default KDEVOPS_HOSTS_PREFIX + config KDEVOPS_CUSTOM_SSH_KEXALGORITHMS string "The custom ssh config KexAlgorithms string to use" depends on HAVE_DISTRO_REQUIRES_CUSTOM_SSH_KEXALGORITHMS
scripts/gen-hosts.Makefile +0 -1
@@ -17,7 +17,6 @@ GENHOSTS_EXTRA_ARGS += kdevops_hosts_template_full_path='$(KDEVOPS_HOSTS_TEMPLAT GENHOSTS_EXTRA_ARGS += kdevops_playbooks_dir_full_path='$(KDEVOPS_PLAYBOOKS_DIR_FULL_PATH)' GENHOSTS_EXTRA_ARGS += kdevops_genhosts_templates_dir='$(KDEVOPS_HOSTS_TEMPLATE_DIR)' -GENHOSTS_EXTRA_ARGS += kdevops_hosts_prefix='$(CONFIG_KDEVOPS_HOSTS_PREFIX)' GENHOSTS_EXTRA_ARGS += kdevops_python_interpreter='$(CONFIG_KDEVOPS_PYTHON_INTERPRETER)' GENHOSTS_EXTRA_ARGS += kdevops_python_old_interpreter='$(CONFIG_KDEVOPS_PYTHON_OLD_INTERPRETER)' ifeq (y,$(CONFIG_KDEVOPS_BASELINE_AND_DEV))
scripts/ssh.Makefile +0 -3
@@ -11,9 +11,6 @@ SSH_CONFIG_FILE:=$(subst ",,$(CONFIG_KDEVOPS_SSH_CONFIG)) ANSIBLE_EXTRA_ARGS += sshconfig=$(CONFIG_KDEVOPS_SSH_CONFIG) endif -KDEVOPS_HOSTS_PREFIX:=$(subst ",,$(CONFIG_KDEVOPS_HOSTS_PREFIX)) -ANSIBLE_EXTRA_ARGS += kdevops_host_prefix=$(KDEVOPS_HOSTS_PREFIX) - PHONY += remove-ssh-key remove-ssh-key: $(NQ) Removing key pair for $(KDEVOPS_SSH_PRIVKEY)
Signature · 1 line
2.43.0
PATCH 4/5 workflows/Makefile: replace direct named entries with output yaml
In reply to Luis ChamberlainThere are workflow variables which have an exact respective ansible variable, just use the new "output yaml" so we can aggregate these automatically directly from kconfig.
--- kconfigs/workflows/Kconfig | 8 ++++++++ workflows/Makefile | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)
kconfigs/workflows/Kconfig +8 -0
@@ -260,6 +260,7 @@ endif # !WORKFLOWS_DEDICATED_WORKFLOW config KDEVOPS_WORKFLOW_ENABLE_FSTESTS bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FSTESTS || KDEVOPS_WORKFLOW_DEDICATE_FSTESTS if KDEVOPS_WORKFLOW_ENABLE_FSTESTS
@@ -270,6 +271,7 @@ endif # KDEVOPS_WORKFLOW_ENABLE_FSTESTS config KDEVOPS_WORKFLOW_ENABLE_BLKTESTS bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_BLKTESTS || KDEVOPS_WORKFLOW_DEDICATE_BLKTESTS if KDEVOPS_WORKFLOW_ENABLE_BLKTESTS
@@ -280,6 +282,7 @@ endif # KDEVOPS_WORKFLOW_ENABLE_BLKTESTS config KDEVOPS_WORKFLOW_ENABLE_CXL bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_CXL || KDEVOPS_WORKFLOW_DEDICATE_CXL if KDEVOPS_WORKFLOW_ENABLE_CXL
@@ -290,6 +293,7 @@ endif # KDEVOPS_WORKFLOW_ENABLE_CXL config KDEVOPS_WORKFLOW_ENABLE_PYNFS bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_PYNFS || KDEVOPS_WORKFLOW_DEDICATE_PYNFS select KDEVOPS_SETUP_NFSD
@@ -301,6 +305,7 @@ endif # KDEVOPS_WORKFLOW_ENABLE_PYNFS config KDEVOPS_WORKFLOW_ENABLE_SELFTESTS bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SELFTESTS || KDEVOPS_WORKFLOW_DEDICATE_SELFTESTS if KDEVOPS_WORKFLOW_ENABLE_SELFTESTS
@@ -311,6 +316,7 @@ endif # KDEVOPS_WORKFLOW_ENABLE_SELFTESTS config KDEVOPS_WORKFLOW_ENABLE_GITR bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_GITR || KDEVOPS_WORKFLOW_DEDICATE_GITR if KDEVOPS_WORKFLOW_ENABLE_GITR
@@ -321,6 +327,7 @@ endif # KDEVOPS_WORKFLOW_ENABLE_GITR config KDEVOPS_WORKFLOW_ENABLE_LTP bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_LTP || KDEVOPS_WORKFLOW_DEDICATE_LTP if KDEVOPS_WORKFLOW_ENABLE_LTP
@@ -331,6 +338,7 @@ endif # KDEVOPS_WORKFLOW_ENABLE_GITR config KDEVOPS_WORKFLOW_ENABLE_NFSTEST bool + output yaml default y if KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_NFSTEST || KDEVOPS_WORKFLOW_DEDICATE_NFSTEST if KDEVOPS_WORKFLOW_ENABLE_NFSTEST
workflows/Makefile +0 -8
@@ -15,27 +15,22 @@ WORKFLOW_ARGS += kdevops_bootlinux='False' endif ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_FSTESTS)) -WORKFLOW_ARGS += kdevops_workflow_enable_fstests='True' include workflows/fstests/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_FSTESTS == y ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_BLKTESTS)) -WORKFLOW_ARGS += kdevops_workflow_enable_blktests='True' include workflows/blktests/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_BLKTESTS == y ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_CXL)) -WORKFLOW_ARGS += kdevops_workflow_enable_cxl='True' include workflows/cxl/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_CXL == y ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_PYNFS)) -WORKFLOW_ARGS += kdevops_workflow_enable_pynfs='True' include workflows/pynfs/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_PYNFS == y ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_SELFTESTS)) -WORKFLOW_ARGS += kdevops_workflow_enable_selftests='True' include workflows/selftests/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_SELFTESTS
@@ -44,17 +39,14 @@ include workflows/demos/reboot-limit/Makefile endif # CONFIG_WORKFLOWS_REBOOT_LIMIT == y ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_GITR)) -WORKFLOW_ARGS += kdevops_workflow_enable_gitr='True' include workflows/gitr/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_GITR == y ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_LTP)) -WORKFLOW_ARGS += kdevops_workflow_enable_ltp='True' include workflows/ltp/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_LTP == y ifeq (y,$(CONFIG_KDEVOPS_WORKFLOW_ENABLE_NFSTEST)) -WORKFLOW_ARGS += kdevops_workflow_enable_nfstest='True' include workflows/nfstest/Makefile endif # CONFIG_KDEVOPS_WORKFLOW_ENABLE_NFSTEST == y
Signature · 1 line
2.43.0
PATCH 5/5 fstests: use selective yaml output on a slew of different variables
In reply to Luis ChamberlainThese are the first set of obvious candidate variables which we can convert over to just using the selective yaml output so we don't have to do the Makefile variable conversion ourselves.
--- workflows/fstests/Kconfig | 11 +++++++++ workflows/fstests/Makefile | 46 -------------------------------------- 2 files changed, 11 insertions(+), 46 deletions(-)
workflows/fstests/Kconfig +11 -0
@@ -35,12 +35,15 @@ config FSTESTS_CIFS_ENABLE config FSTESTS_USES_NO_DEVICES bool + output yaml config FSTESTS_GENERATE_SIMPLE_CONFIG_ENABLE bool + output yaml config FSTESTS_GENERATE_NVME_LIVE_CONFIG_ENABLE bool + output yaml choice prompt "Target filesystem to test"
@@ -305,6 +308,7 @@ config HAVE_MIRROR_KDEVOPS_FSTESTS config FSTESTS_GIT string "The fstests git tree to clone" + output yaml default DEFAULT_FSTESTS_HTTPS_URL if !GIT_ALTERNATIVES && !HAVE_MIRROR_FSTESTS default $(shell, scripts/append-makefile-vars.sh git:// $(KDEVOPS_DEFAULT_BRIDGE_IP_VAGRANT) /mirror/fstests.git) if !GIT_ALTERNATIVES && HAVE_MIRROR_FSTESTS && VAGRANT default $(shell, scripts/append-makefile-vars.sh git:// $(KDEVOPS_DEFAULT_BRIDGE_IP_GUESTFS) /mirror/fstests.git) if !GIT_ALTERNATIVES && HAVE_MIRROR_FSTESTS && GUESTFS
@@ -318,6 +322,7 @@ config FSTESTS_GIT config FSTESTS_DATA string "Where to clone the fstests git tree to" + output yaml default "{{data_path}}/fstests" help This is the target location of where to clone the above git tree.
@@ -326,12 +331,14 @@ config FSTESTS_DATA config FSTESTS_GIT_VERSION string "The fstests git tree version(branch/tag/commit)" + output yaml default "HEAD" help The fstests git tree version. config FSTESTS_DATA_TARGET string "The target fstests install directory" + output yaml default "/var/lib/xfstests" help The directory where fstests will be installed. Modifying this probably
@@ -404,6 +411,7 @@ config FSTESTS_TESTDEV_SPARSEFILE_GENERATION config FSTESTS_TESTDEV_NVME_PARTITION_EUIS bool "Use first real NVMe drive and create partitions" + output yaml select EXTRA_STORAGE_SUPPORTS_512 select EXTRA_STORAGE_SUPPORTS_1K select EXTRA_STORAGE_SUPPORTS_2K
@@ -493,6 +501,7 @@ endif # FSTESTS_TMPFS config FSTESTS_TESTDEV_NVME_FALLBACK_MODEL_SERIAL bool "Fallback to using NVMe model an serial" + output yaml depends on FSTESTS_TESTDEV_NVME_PARTITION_EUIS || FSTESTS_TESTDEV_NVME_EUIS default y help
@@ -626,6 +635,7 @@ config FSTESTS_TEST_DEV_ZNS config FSTESTS_TEST_DIR string "The path to use for the fstests TEST_DIR variable" + output yaml default "/media/test" help To test with fstests one must set the TEST_DEV variable, this sets
@@ -648,6 +658,7 @@ config FSTESTS_SCRATCH_DEV_POOL_ZNS config FSTESTS_SCRATCH_MNT string "The path to use for the fstests SCRATCH_MNT variable" + output yaml default "/media/scratch" help This sets the SCRATCH_MNT variable.
workflows/fstests/Makefile +0 -46
71 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 2 lines · Luis Chamberlain
PS. nconfig doesn't yet have yamlconfig support, I can add it easily if this approach is agreeable.
I was wrong, I just forgot to add nconf to the clean targets, so just removing scripts/kconfig/nconf scripts/kconfig/nconf.o and trying again made it work.
And so I guess this is pretty much ready if we agree to go forward.
Luis