Skip to content

Commit

Permalink
Removed all OS labels from deprecated template (#233)
Browse files Browse the repository at this point in the history
* Removed OS labels and annotations from the deprecated windows template in order to hide it from consumers

Signed-off-by: Omer Yahud <[email protected]>

* Updated the memory consistency script to skip templates that have no OS labels as they might be deprecated

Signed-off-by: Omer Yahud <[email protected]>
  • Loading branch information
omeryahud authored Sep 30, 2020
1 parent 36a7aff commit db7a44e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
6 changes: 6 additions & 0 deletions templates/LABELS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ the workload a template is supposed to be used for.
Some of them are not going to be used immediately and serve
as examples.

## Deprecated templates

When a template is deprecated, the following annotation is applied to it: `template.kubevirt.io/deprecated: "true"`.

The template itself is not removed for backward compatibility reasons.

## Operating systems

The operating system labels must match the [libosinfo
Expand Down
10 changes: 1 addition & 9 deletions templates/win2k12r2-deprecated.tpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ metadata:
template.openshift.io/bindable: "false"

template.kubevirt.io/version: v1alpha1
template.kubevirt.io/deprecated: "true"
defaults.template.kubevirt.io/disk: rootdisk
defaults.template.kubevirt.io/network: default
template.kubevirt.io/editable: |
Expand All @@ -25,11 +26,6 @@ metadata:
/objects[0].spec.template.spec.volumes
/objects[0].spec.template.spec.networks
name.os.template.kubevirt.io/win2k19: {{ lookup('osinfo', 'win2k19').name }}
name.os.template.kubevirt.io/win2k16: {{ lookup('osinfo', 'win2k16').name }}
name.os.template.kubevirt.io/win2k12r2: {{ lookup('osinfo', 'win2k12r2').name }}
name.os.template.kubevirt.io/win10: {{ lookup('osinfo', 'win10').name }}

validations: |
[
{
Expand Down Expand Up @@ -64,10 +60,6 @@ metadata:
]
labels:
os.template.kubevirt.io/win2k19: "true"
os.template.kubevirt.io/win2k16: "true"
os.template.kubevirt.io/win2k12r2: "true"
os.template.kubevirt.io/win10: "true"
template.kubevirt.io/type: "base"
template.kubevirt.io/version: "{{ lookup('env', 'VERSION') | default('devel', true) }}"

Expand Down
31 changes: 21 additions & 10 deletions travis_ci/validate-min-memory-consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def minMemoryReqInTemplate(template):
min_gi_float = float(min_str.replace("Gi",""))
return int(min_gi_float * (1024**3))

def templateHasOsLabels(template):
labels = template["metadata"]["labels"]
osl_pref_str = "os.template.kubevirt.io"
os_labels = [label for label in labels if osl_pref_str in label]

return len(os_labels) > 0


def memoryReqErrorMessage(newest_os_label, template_name):
return "Memory requirements for OS: {} are not compatible with the requirements set in: {}".format(newest_os_label, template_name)

Expand All @@ -45,16 +53,19 @@ def checkMemoryReqs(path):
continue

logging.info("Checking memory requirements consistency for: {}".format(template["metadata"]["name"]))

try:
newest_os_label = newestOsLabel(template)
actual_min_req = minMemoryReqForOs(newest_os_label)
min_req_in_template = minMemoryReqInTemplate(template)
if min_req_in_template < actual_min_req:
errors.append([newest_os_label, template_name])
except Exception as e:
logging.info(FAILED_INFO_MESSAGE)
raise e

if not templateHasOsLabels(template):
logging.info("Template {} has no OS labels (might be a deprecated template), skipping.".format(template["metadata"]["name"]))
else:
try:
newest_os_label = newestOsLabel(template)
actual_min_req = minMemoryReqForOs(newest_os_label)
min_req_in_template = minMemoryReqInTemplate(template)
if min_req_in_template < actual_min_req:
errors.append([newest_os_label, template_name])
except Exception as e:
logging.info(FAILED_INFO_MESSAGE)
raise e

except yaml.YAMLError as exc:
raise exc
Expand Down

0 comments on commit db7a44e

Please sign in to comment.