Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Simplify testing nightly builds with clusterctl #10018

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions cmd/clusterctl/hack/create-local-repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@

from __future__ import unicode_literals

import sys
import errno
import json
import os
import subprocess
import urllib.request
from distutils.dir_util import copy_tree
from distutils.file_util import copy_file

Expand All @@ -68,19 +70,19 @@
'configFolder': 'controlplane/kubeadm/config/default',
},
'infrastructure-docker': {
'componentsFile': 'infrastructure-components.yaml',
'componentsFile': 'infrastructure-components-development.yaml',
'nextVersion': 'v1.7.99',
'type': 'InfrastructureProvider',
'configFolder': 'test/infrastructure/docker/config/default',
},
'infrastructure-in-memory': {
'componentsFile': 'infrastructure-components.yaml',
'componentsFile': 'infrastructure-components-in-memory-development.yaml',
'nextVersion': 'v1.7.99',
'type': 'InfrastructureProvider',
'configFolder': 'test/infrastructure/inmemory/config/default',
},
'runtime-extension-test': {
'componentsFile': 'runtime-extension-components.yaml',
'componentsFile': 'runtime-extension-components-development.yaml',
'nextVersion': 'v1.7.99',
'type': 'RuntimeExtensionProvider',
'configFolder': 'test/extension/config/default',
Expand Down Expand Up @@ -167,6 +169,9 @@ def create_local_repositories():
assert providerList is not None, 'invalid configuration: please define the list of providers to override'
assert len(providerList)>0, 'invalid configuration: please define at least one provider to override'

if len(sys.argv) == 1:
execCmd(['make', 'kustomize'])
fabriziopandini marked this conversation as resolved.
Show resolved Hide resolved

for provider in providerList:
p = providers.get(provider)
assert p is not None, 'invalid configuration: please specify the configuration for the {} provider'.format(
Expand All @@ -188,10 +193,14 @@ def create_local_repositories():
assert components_file is not None, 'invalid configuration for provider {}: please provide componentsFile value'.format(
provider)

execCmd(['make', 'kustomize'])
components_yaml = execCmd(['./hack/tools/bin/kustomize', 'build', os.path.join(repo, config_folder)])
if len(sys.argv) > 1:
url = "{}/{}".format(sys.argv[1], components_file)
components_yaml = urllib.request.urlopen(url).read()
else:
components_yaml = execCmd(['./hack/tools/bin/kustomize', 'build', os.path.join(repo, config_folder)])

components_path = write_local_repository(provider, next_version, components_file, components_yaml,
metadata_file)
metadata_file)

yield name, type, next_version, components_path

Expand Down Expand Up @@ -289,7 +298,11 @@ def print_instructions(repos):
cmd = "clusterctl init \\\n"
for name, type, next_version, components_path in repos:
cmd += " {} {}:{} \\\n".format(type_to_flag(type), name, next_version)
cmd += " --config $XDG_CONFIG_HOME/cluster-api/dev-repository/config.yaml"
config_dir = os.getenv("XDG_CONFIG_HOME", "")
if config_dir != "":
cmd += " --config $XDG_CONFIG_HOME/cluster-api/dev-repository/config.yaml"
else:
cmd += " --config $HOME/.config/cluster-api/dev-repository/config.yaml"
print(cmd)
print
if 'infrastructure-docker' in providerList:
Expand Down
25 changes: 20 additions & 5 deletions docs/book/src/clusterctl/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,35 @@ clusterctl init \
```

As you might notice, the command is using the `$XDG_CONFIG_HOME/cluster-api/dev-repository/config.yaml` config file,
containing all the required setting to make clusterctl use the local repository.
containing all the required setting to make clusterctl use the local repository (it fallbacks to `$HOME` if `$XDG_CONFIG_HOME`
is not set on your machine).

<aside class="note warning">

<h1>Warnings</h1>

You must pass `--config $XDG_CONFIG_HOME/cluster-api/dev-repository/config.yaml` to all the clusterctl commands you are running
during your dev session.
You must pass `--config ...` to all the clusterctl commands you are running during your dev session.

The above config file changes the location of the [overrides layer] folder thus ensuring
you dev session isn't hijacked by other local artifacts.

With the only exception of the Docker provider, the local repository folder does not contain cluster templates,
so the `clusterctl generate cluster` command will fail.
With the exceptions of the Docker and the in memory provider, the local repository folder does not contain cluster templates,
so the `clusterctl generate cluster` command will fail if you don't copy a template into the local repository.

</aside>

<aside class="note warning">

<h1>Nightly builds</h1>

if you want to run your tests using a Cluster API nightly build, you can run the hack passing the nightly build folder
(change the date at the end of the bucket name according to your needs):

```bash
cmd/clusterctl/hack/create-local-repository.py https://storage.googleapis.com/artifacts.k8s-staging-cluster-api.appspot.com/components/nightly_main_20240101
```

Note: this works only with core Cluster API nightly builds.

</aside>

Expand Down
5 changes: 4 additions & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
kind: Metadata
releaseSeries:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@cahillsf Usually (1.5 & 1.6) we did this as part of "Prepare main branch for development of the new release".

Looks like we missed it for v1.7, but it also looks like it is not documented in release-tasks

Copy link
Member

@cahillsf cahillsf Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it is in the tasks but i missed it this time. thanks for fixing!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I don't know what this google doc is :) (I don't have access)

Shouldn't it be documented in the publicly accessible release-tasks.md? (I didn't find it there, but maybe I missed it)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I dropped the wrong link, just fixed

Add the new release to the root level metadata.yaml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah :D

Okay somehow I missed it, but it's there

Add the new release to the root level metadata.yaml

- major: 1
minor: 7
contract: v1beta1
- major: 1
minor: 6
contract: v1beta1
Expand All @@ -29,4 +32,4 @@ releaseSeries:
contract: v1beta1
- major: 0
minor: 4
contract: v1alpha4
contract: v1alpha4
Loading