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

Deploy common-instancetypes v0.0.1-rc #453

Merged
merged 1 commit into from
Dec 9, 2022

Conversation

lyarwood
Copy link
Member

@lyarwood lyarwood commented Nov 18, 2022

What this PR does / why we need it:

This initial change starts to simply deploy the initial v0.0.1-rc bundle
of VirtualMachineCluster{Instancetypes,Preferences} resources. These
resources are deployed under both OpenShift and non-OpenShift based
environments, at present this it the only functionality enabled under
the latter.

Future changes will introduce support for removing deprecated resources
and support for deploying resources from a repo URI.

$ env | grep KUBEVIRT
KUBEVIRT_PROVIDER=k8s-1.24
KUBEVIRT_MEMORY=16384
KUBEVIRTCI_RUNTIME=docker
$ make cluster-down && make cluster-up &&  make cluster-sync
[..]
$ ./cluster/kubectl.sh get virtualmachineclusterpreferences -o json | jq '.items | .[] | .metadata.name'
selecting docker as container runtime
"alpine"
"centos.7"
"centos.7.desktop"
"centos.8.stream"
"centos.8.stream.desktop"
"centos.9.stream"
"centos.9.stream.desktop"
"cirros"
"fedora.35"
"fedora.36"
"rhel.7"
"rhel.7.desktop"
"rhel.8"
"rhel.8.desktop"
"rhel.9"
"rhel.9.desktop"
"ubuntu.18.04"
"ubuntu.20.04"
"ubuntu.22.04"
"windows.10"
"windows.10.virtio"
"windows.11"
"windows.11.virtio"
"windows.2k12"
"windows.2k12.virtio"
"windows.2k16"
"windows.2k16.virtio"
"windows.2k19"
"windows.2k19.virtio"
"windows.2k22"
"windows.2k22.virtio"
$ ./cluster/kubectl.sh get virtualmachineclusterinstancetypes -o json | jq '.items | .[] | .metadata.name'
selecting docker as container runtime
"highperformance.large"
"highperformance.medium"
"highperformance.small"
"server.large"
"server.medium"
"server.micro"
"server.small"
"server.tiny"

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Release note:

`VirtualMachineClusterInstancetypes` and `VirtualMachineClusterPreferences` generated by the [`v0.0.1-rc`](https://github.com/kubevirt/common-instancetypes/releases/tag/v0.0.1-rc) release of the [common-instancetypes](https://github.com/kubevirt/common-instancetypes) project are now installed by default by the operator.

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Nov 18, 2022
@openshift-ci
Copy link

openshift-ci bot commented Nov 18, 2022

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@lyarwood lyarwood changed the title Deploy common instancetypes WIP Deploy common instancetypes Nov 18, 2022
@lyarwood lyarwood force-pushed the deploy-common-instancetypes branch from b32febe to e931ce4 Compare November 21, 2022 15:55
@lyarwood lyarwood changed the title WIP Deploy common instancetypes Deploy common-instancetypes v0.0.1-rc Nov 21, 2022
@lyarwood lyarwood changed the title Deploy common-instancetypes v0.0.1-rc Deploy common-instancetypes v0.0.1-rc Nov 21, 2022
@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Nov 21, 2022
@lyarwood lyarwood marked this pull request as ready for review November 21, 2022 15:59
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 21, 2022
@lyarwood
Copy link
Member Author

Marked this as ready to review but it still obviously needs tests etc, just looking for some initial reviews on direction.

@lyarwood lyarwood force-pushed the deploy-common-instancetypes branch from e931ce4 to 5695c42 Compare November 21, 2022 17:35
Copy link
Member

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

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

On nit, otherwise lgtm!

config/rbac/role.yaml Show resolved Hide resolved
@lyarwood lyarwood force-pushed the deploy-common-instancetypes branch from 5695c42 to e65b4a0 Compare November 28, 2022 20:26
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 7, 2022
@lyarwood lyarwood force-pushed the deploy-common-instancetypes branch from e65b4a0 to d34d127 Compare December 7, 2022 16:25
@kubevirt-bot kubevirt-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 7, 2022
@lyarwood lyarwood force-pushed the deploy-common-instancetypes branch from d34d127 to 9aff1b9 Compare December 7, 2022 16:32
data/olm-catalog/ssp-operator.clusterserviceversion.yaml Outdated Show resolved Hide resolved
internal/operands/common-instancetypes/reconcile.go Outdated Show resolved Hide resolved
ClusterResource(clusterInstancetype).
WithAppLabels(operandName, operandComponent).
UpdateFunc(func(newRes, foundRes client.Object) {
foundRes.(*instancetypev1alpha2.VirtualMachineClusterInstancetype).Spec = newRes.(*instancetypev1alpha2.VirtualMachineClusterInstancetype).Spec
Copy link
Member

Choose a reason for hiding this comment

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

Should the casts be checked?

internal/operands/common-instancetypes/reconsile_test.go Outdated Show resolved Hide resolved
internal/operands/common-instancetypes/reconcile.go Outdated Show resolved Hide resolved
internal/operands/common-instancetypes/reconcile.go Outdated Show resolved Hide resolved
internal/operands/common-instancetypes/reconsile_test.go Outdated Show resolved Hide resolved
internal/operands/common-instancetypes/reconsile_test.go Outdated Show resolved Hide resolved
This initial change starts to simply deploy the v0.0.1-rc bundle
of VirtualMachineCluster{Instancetypes,Preferences} resources. These
resources are deployed under both OpenShift and non-OpenShift
environments. At present this is the only functionality enabled within
the operator when deployed under non-OpenShift environments.

Future changes will introduce support for removing deprecated resources
and for deploying resources from a kustomize repo URI.

Signed-off-by: Lee Yarwood <[email protected]>
@lyarwood lyarwood force-pushed the deploy-common-instancetypes branch from 9aff1b9 to b521a26 Compare December 8, 2022 17:13
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 8, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@0xFelix 0xFelix left a comment

Choose a reason for hiding this comment

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

Only one nit, otherwise LGTM! Thank you.

/approve
/lgtm

}

func New(instancetypeBundlePath, preferenceBundlePath string) (operands.Operand, error) {
virtualMachineClusterInstancetypes, err := fetchClusterResources[instancetypev1alpha2.VirtualMachineClusterInstancetype](instancetypeBundlePath)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if there's a way to make the import name less clunky.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 9, 2022
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 0xFelix

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 9, 2022
@0xFelix
Copy link
Member

0xFelix commented Dec 9, 2022

/retest

@kubevirt-bot kubevirt-bot merged commit d95ccb8 into kubevirt:master Dec 9, 2022
Copy link
Collaborator

@akrejcir akrejcir left a comment

Choose a reason for hiding this comment

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

I'm sorry I didn't look at this before it was merged.
I have some comments, can you implement them in another PR?
And also functional tests are missing.

}

func (c *commonInstancetypes) RequiredCrds() []string {
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

This operand requires these CRDs:

virtualmachineclusterinstancetypes.instancetype.kubevirt.io
virtualmachineclusterpreferences.instancetype.kubevirt.io

}

func (c *commonInstancetypes) Cleanup(request *common.Request) ([]common.CleanupResult, error) {
return nil, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

This method must remove the created cluster resources.

Copy link
Member Author

@lyarwood lyarwood Dec 12, 2022

Choose a reason for hiding this comment

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

The example from common-templates only drops deprecated templates so I wasn't sure what the expected behaviour here actually was:

func (c *commonTemplates) Cleanup(request *common.Request) ([]common.CleanupResult, error) {
var objects []client.Object
namespace := request.Instance.Spec.CommonTemplates.Namespace
deprecatedTemplates, err := getDeprecatedTemplates(request)
if err != nil {
return nil, err
}
for _, obj := range deprecatedTemplates.Items {
obj.ObjectMeta.Namespace = namespace
objects = append(objects, &obj)
}
for index := range c.templatesBundle {
c.templatesBundle[index].ObjectMeta.Namespace = namespace
objects = append(objects, &c.templatesBundle[index])
}
return common.DeleteAll(request, objects...)
}

I'll remove them all now in a follow up.

UpdateFunc(func(newRes, foundRes client.Object) {
foundRes.(*instancetypev1alpha2.VirtualMachineClusterInstancetype).Spec = newRes.(*instancetypev1alpha2.VirtualMachineClusterInstancetype).Spec
}).
ImmutableSpec(func(resource client.Object) interface{} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The VirtualMachineClusterInstancetype is not immutable, so this method should not be called.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah apologies I misunderstood things here, I'll drop it.

UpdateFunc(func(newRes, foundRes client.Object) {
foundRes.(*instancetypev1alpha2.VirtualMachineClusterPreference).Spec = newRes.(*instancetypev1alpha2.VirtualMachineClusterPreference).Spec
}).
ImmutableSpec(func(resource client.Object) interface{} {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similarly, preference is not immutable, so this method should not be called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants