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

Fix k8s_as_cloud_service flag used in download-requirements (#3222) #3242

Merged
merged 2 commits into from
Aug 8, 2022
Merged
Changes from 1 commit
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
Next Next commit
Fix k8s_as_cloud_service flag used in download-requirements (#3222)
sbbroot committed Aug 3, 2022
commit 1ef13574a50221836a3d47f51b9a583cc0c3c136
Original file line number Diff line number Diff line change
@@ -41,11 +41,11 @@ files:
# --- Helm charts ---
'https://charts.bitnami.com/bitnami/node-exporter-2.3.17.tgz':
sha256: ec586fabb775a4f05510386899cf348391523c89ff5a1d4097b0592e675ade7f
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

'https://helm.elastic.co/helm/filebeat/filebeat-7.12.1.tgz':
sha256: 5838058fe06372390dc335900a7707109cc7287a84164ca245d395af1f9c0a79
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

# --- OpenSearch Bundle ---
'https://artifacts.opensearch.org/releases/bundle/opensearch/1.2.4/opensearch-1.2.4-linux-arm64.tar.gz':
Original file line number Diff line number Diff line change
@@ -41,19 +41,19 @@ files:
# --- Helm charts ---
'https://charts.bitnami.com/bitnami/node-exporter-2.3.17.tgz':
sha256: ec586fabb775a4f05510386899cf348391523c89ff5a1d4097b0592e675ade7f
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

'https://helm.elastic.co/helm/filebeat/filebeat-7.12.1.tgz':
sha256: 5838058fe06372390dc335900a7707109cc7287a84164ca245d395af1f9c0a79
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

'https://charts.rook.io/release/rook-ceph-v1.8.8.tgz':
sha256: f67e474dedffd4004f3a0b7b40112694a7f1c2b1a0048b03b3083d0a01e86b14
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]
cicharka marked this conversation as resolved.
Show resolved Hide resolved

'https://charts.rook.io/release/rook-ceph-cluster-v1.8.8.tgz':
sha256: df4e1f2125af41fb84c72e4d12aa0cb859dddd4f37b3d5979981bd092040bd16
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

# --- OpenSearch Bundle ---
'https://artifacts.opensearch.org/releases/bundle/opensearch/1.2.4/opensearch-1.2.4-linux-x64.tar.gz':
Original file line number Diff line number Diff line change
@@ -258,8 +258,7 @@ def __print_parsed_manifest_data(self, requirements: Dict[str, Any], manifest: D
logging.info('\n'.join(lines))

def __filter_files(self, requirements: Dict[str, Any],
manifest: Dict[str, Any],
is_k8s_as_cloud_service: bool):
manifest: Dict[str, Any]):
"""
See :func:`~config.Config.__filter_manifest`
"""
@@ -270,9 +269,6 @@ def __filter_files(self, requirements: Dict[str, Any],
if all(dep not in manifest['requested-features'] for dep in deps) and deps != 'default':
files_to_exclude.append(file)

if is_k8s_as_cloud_service:
files_to_exclude = [file for file in files if 'kubernetes-master' not in files[file]['deps']]

if files_to_exclude:
requirements['files'] = {url: data for url, data in files.items() if url not in files_to_exclude}

@@ -301,19 +297,17 @@ def __filter_images(self, requirements: Dict[str, Any], manifest: Dict[str, Any]
requirements['images'] = images_to_download

def __filter_manifest(self, requirements: Dict[str, Any],
manifest: Dict[str, Any],
is_k8s_as_cloud_service: bool):
manifest: Dict[str, Any]):
"""
Filter entries in the `requirements` based on the parsed `manifest` documents.

:param requirements: parsed requirements which will be filtered based on the `manifest` content
:param manifest: parsed documents which will be used to filter `requirements`
:param is_k8s_as_cloud_service: whether to download kubernetes files if service is not present
"""
if 'grafana' not in manifest['requested-features']:
requirements['grafana-dashboards'] = []

self.__filter_files(requirements, manifest, is_k8s_as_cloud_service)
self.__filter_files(requirements, manifest)
self.__filter_images(requirements, manifest)

def read_manifest(self, requirements: Dict[str, Any]):
@@ -333,7 +327,7 @@ def read_manifest(self, requirements: Dict[str, Any]):
mreader = ManifestReader(self.dest_manifest, self.os_arch)
try:
manifest = mreader.parse_manifest()
self.__filter_manifest(requirements, manifest, mreader.is_k8s_as_cloud_service)
self.__filter_manifest(requirements, manifest)

if self.verbose_mode:
self.__print_parsed_manifest_data(requirements, manifest)
Original file line number Diff line number Diff line change
@@ -38,10 +38,6 @@ def __init__(self, dest_manifest: Path, arch: OSArch):
self.__requested_features: Set = set()
self.__requested_images: Set = set()

@property
def is_k8s_as_cloud_service(self) -> bool:
return self.__k8s_as_cloud_service

def __parse_cluster_doc(self, cluster_doc: Dict):
"""
Parse `epiphany-cluster` document and extract only used components.
@@ -74,6 +70,9 @@ def __parse_feature_mappings_doc(self, feature_mappings_doc: Dict):
for feature in mappings[mapping]:
self.__requested_features.add(feature)

if self.__k8s_as_cloud_service:
self.__requested_features.add('k8s-as-cloud-service')

def __parse_image_registry_doc(self, image_registry_doc: Dict):
"""
Parse `configuration/image-registry` document and extract only used images.
Original file line number Diff line number Diff line change
@@ -41,19 +41,19 @@
# --- Helm charts ---
'https://charts.bitnami.com/bitnami/node-exporter-2.3.17.tgz':
sha256: ec586fabb775a4f05510386899cf348391523c89ff5a1d4097b0592e675ade7f
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

'https://helm.elastic.co/helm/filebeat/filebeat-7.12.1.tgz':
sha256: 5838058fe06372390dc335900a7707109cc7287a84164ca245d395af1f9c0a79
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

'https://charts.rook.io/release/rook-ceph-v1.8.8.tgz':
sha256: f67e474dedffd4004f3a0b7b40112694a7f1c2b1a0048b03b3083d0a01e86b14
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

'https://charts.rook.io/release/rook-ceph-cluster-v1.8.8.tgz':
sha256: df4e1f2125af41fb84c72e4d12aa0cb859dddd4f37b3d5979981bd092040bd16
deps: [kubernetes-master]
deps: [kubernetes-master, k8s-as-cloud-service]

# --- OpenSearch Bundle ---
'https://artifacts.opensearch.org/releases/bundle/opensearch/1.2.4/opensearch-1.2.4-linux-x64.tar.gz':
@@ -463,13 +463,15 @@
- filebeat
- firewall
- image-registry
- k8s-as-cloud-service
- node-exporter
- repository

Files to download:
- https://charts.bitnami.com/bitnami/node-exporter-2.3.17.tgz
- https://charts.rook.io/release/rook-ceph-cluster-v1.8.8.tgz
- https://charts.rook.io/release/rook-ceph-v1.8.8.tgz
- https://github.com/prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-amd64.tar.gz
- https://helm.elastic.co/helm/filebeat/filebeat-7.12.1.tgz
--------------------------------------------------
"""