Skip to content

Commit

Permalink
Fix k8s_as_cloud_service flag used in download-requirements (hitachie…
Browse files Browse the repository at this point in the history
  • Loading branch information
sbbroot committed Aug 3, 2022
1 parent 8b3dcc9 commit 1ef1357
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]

'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':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
"""
Expand All @@ -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}

Expand Down Expand Up @@ -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]):
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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
--------------------------------------------------
"""

0 comments on commit 1ef1357

Please sign in to comment.