Skip to content

Commit

Permalink
Added logic for applying default architecture to kubevirt CR status
Browse files Browse the repository at this point in the history
Signed-off-by: David Aghaian <[email protected]>
  • Loading branch information
aghaiand committed May 5, 2023
1 parent 9292b61 commit fc8a5a4
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -17276,6 +17276,9 @@
"$ref": "#/definitions/v1.KubeVirtCondition"
}
},
"defaultArchitecture": {
"type": "string"
},
"generations": {
"type": "array",
"items": {
Expand Down
4 changes: 4 additions & 0 deletions manifests/generated/kv-resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2804,6 +2804,8 @@ spec:
- type
type: object
type: array
defaultArchitecture:
type: string
generations:
items:
description: GenerationStatus keeps track of the generation for
Expand Down Expand Up @@ -5661,6 +5663,8 @@ spec:
- type
type: object
type: array
defaultArchitecture:
type: string
generations:
items:
description: GenerationStatus keeps track of the generation for
Expand Down
3 changes: 3 additions & 0 deletions pkg/virt-operator/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,9 @@ func (c *KubeVirtController) syncInstallation(kv *v1.KubeVirt) error {
// Record the version we're targeting to install
config.SetTargetDeploymentConfig(kv)

// Set the default architecture
config.SetDefaultArchitecture(kv)

if kv.Status.Phase == "" {
kv.Status.Phase = v1.KubeVirtPhaseDeploying
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3138,6 +3138,8 @@ var CRDsValidation map[string]string = map[string]string{
- type
type: object
type: array
defaultArchitecture:
type: string
generations:
items:
description: GenerationStatus keeps track of the generation for a given
Expand Down
12 changes: 12 additions & 0 deletions pkg/virt-operator/util/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"fmt"
"reflect"
"regexp"
"runtime"
"sort"
"strings"

Expand Down Expand Up @@ -560,6 +561,17 @@ func (c *KubeVirtDeploymentConfig) SetTargetDeploymentConfig(kv *v1.KubeVirt) er
return err
}

func (c *KubeVirtDeploymentConfig) SetDefaultArchitecture(kv *v1.KubeVirt) error {
if kv.Spec.Configuration.ArchitectureConfiguration.DefaultArchitecture != "" {
kv.Status.DefaultArchitecture = kv.Spec.Configuration.ArchitectureConfiguration.DefaultArchitecture
} else {
kv.Spec.Configuration.ArchitectureConfiguration.DefaultArchitecture = runtime.GOARCH
kv.Status.DefaultArchitecture = runtime.GOARCH
}

return nil
}

func (c *KubeVirtDeploymentConfig) SetObservedDeploymentConfig(kv *v1.KubeVirt) error {
kv.Status.ObservedKubeVirtVersion = c.GetKubeVirtVersion()
kv.Status.ObservedKubeVirtRegistry = c.GetImageRegistry()
Expand Down
1 change: 1 addition & 0 deletions staging/src/kubevirt.io/api/core/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,7 @@ type KubeVirtStatus struct {
ObservedDeploymentID string `json:"observedDeploymentID,omitempty" optional:"true"`
OutdatedVirtualMachineInstanceWorkloads *int `json:"outdatedVirtualMachineInstanceWorkloads,omitempty" optional:"true"`
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
DefaultArchitecture string `json:"defaultArchitecture,omitempty"`
// +listType=atomic
Generations []GenerationStatus `json:"generations,omitempty" optional:"true"`
}
Expand Down
6 changes: 6 additions & 0 deletions staging/src/kubevirt.io/client-go/api/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fc8a5a4

Please sign in to comment.