Skip to content

Commit

Permalink
Merge pull request kubevirt#596 from rmohr/graceful
Browse files Browse the repository at this point in the history
Add owner reference support to VirtualMachineReplicaSet
  • Loading branch information
davidvossel authored Dec 1, 2017
2 parents 78de183 + 3a00db6 commit 509f09d
Show file tree
Hide file tree
Showing 18 changed files with 1,029 additions and 113 deletions.
64 changes: 64 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,14 @@
"summary": "Delete a Migration object.",
"operationId": "deleteNamespacedMigration",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.DeleteOptions"
}
},
{
"pattern": "[a-z0-9][a-z0-9\\-]*",
"type": "string",
Expand Down Expand Up @@ -758,6 +766,14 @@
"summary": "Delete a VirtualMachineReplicaSet object.",
"operationId": "deleteNamespacedVirtualMachineReplicaSet",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.DeleteOptions"
}
},
{
"pattern": "[a-z0-9][a-z0-9\\-]*",
"type": "string",
Expand Down Expand Up @@ -1091,6 +1107,14 @@
"summary": "Delete a VirtualMachine object.",
"operationId": "deleteNamespacedVirtualMachine",
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v1.DeleteOptions"
}
},
{
"pattern": "[a-z0-9][a-z0-9\\-]*",
"type": "string",
Expand Down Expand Up @@ -2014,6 +2038,37 @@
}
}
},
"v1.DeleteOptions": {
"description": "DeleteOptions may be provided when deleting an API object.",
"properties": {
"apiVersion": {
"description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources",
"type": "string"
},
"gracePeriodSeconds": {
"description": "The duration in seconds before the object should be deleted. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period for the specified type will be used. Defaults to a per object value if not specified. zero means delete immediately.",
"type": "integer",
"format": "int64"
},
"kind": {
"description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds",
"type": "string"
},
"orphanDependents": {
"description": "Deprecated: please use the PropagationPolicy, this field will be deprecated in 1.7. Should the dependent objects be orphaned. If true/false, the \"orphan\" finalizer will be added to/removed from the object's finalizers list. Either this field or PropagationPolicy may be set, but not both.",
"type": "boolean"
},
"preconditions": {
"description": "Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned.",
"$ref": "#/definitions/v1.Preconditions"
},
"propagationPolicy": {
"description": "Whether and how garbage collection will be performed. Either this field or OrphanDependents may be set, but not both. The default policy is decided by the existing finalizer set in the metadata.finalizers and the resource-specific default policy.",
"$ref": "#/definitions/v1.DeletionPropagation"
}
}
},
"v1.DeletionPropagation": {},
"v1.Devices": {
"properties": {
"channels": {
Expand Down Expand Up @@ -2807,6 +2862,15 @@
}
}
},
"v1.Preconditions": {
"description": "Preconditions must be fulfilled before an operation (update, delete, etc.) is carried out.",
"properties": {
"uid": {
"description": "Specifies the target UID.",
"$ref": "#/definitions/types.UID"
}
}
},
"v1.PreferredSchedulingTerm": {
"description": "An empty preferred scheduling term matches all objects with implicit weight 0 (i.e. it's a no-op). A null preferred scheduling term matches no objects (i.e. is also a no-op).",
"required": [
Expand Down
2 changes: 1 addition & 1 deletion cluster/replicaset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
video:
- type: qxl
disks:
- type: ContainerRegistryDisk:v1alpha
- type: RegistryDisk:v1alpha
source:
name: kubevirt/cirros-registry-disk-demo:devel
target:
Expand Down
8 changes: 4 additions & 4 deletions pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ func init() {

// VirtualMachine is *the* VM Definition. It represents a virtual machine in the runtime environment of kubernetes.
type VirtualMachine struct {
metav1.TypeMeta `json:",inline"`
ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// VM Spec contains the VM specification.
Spec VMSpec `json:"spec,omitempty" valid:"required"`
// Status is the high level overview of how the VM is doing. It contains information available to controllers and users.
Expand Down Expand Up @@ -696,8 +696,8 @@ func PrepareVMNodeAntiAffinitySelectorRequirement(vm *VirtualMachine) k8sv1.Node

// VM is *the* VM Definition. It represents a virtual machine in the runtime environment of kubernetes.
type VirtualMachineReplicaSet struct {
metav1.TypeMeta `json:",inline"`
ObjectMeta metav1.ObjectMeta `json:"metadata,omitempty"`
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
// VM Spec contains the VM specification.
Spec VMReplicaSetSpec `json:"spec,omitempty" valid:"required"`
// Status is the high level overview of how the VM is doing. It contains information available to controllers and users.
Expand Down
13 changes: 11 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,19 @@ func VirtualMachineKey(vm *v1.VirtualMachine) string {
return fmt.Sprintf("%v/%v", vm.ObjectMeta.Namespace, vm.ObjectMeta.Name)
}

func VirtualMachineKeys(vms []v1.VirtualMachine) []string {
func VirtualMachineKeys(vms []*v1.VirtualMachine) []string {
keys := []string{}
for _, vm := range vms {
keys = append(keys, VirtualMachineKey(&vm))
keys = append(keys, VirtualMachineKey(vm))
}
return keys
}

func HasFinalizer(object metav1.Object, finalizer string) bool {
for _, f := range object.GetFinalizers() {
if f == finalizer {
return true
}
}
return false
}
Loading

0 comments on commit 509f09d

Please sign in to comment.