Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/google/uuid v1.2.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.17.0
github.com/openshift/api v0.0.0-20220324135351-3d6a78ae0721
github.com/openshift/api v0.0.0-20220325173635-8107b7a38e53
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3
github.com/openshift/library-go v0.0.0-20220121154930-b7889002d63e
github.com/operator-framework/operator-sdk v0.5.1-0.20190301204940-c2efe6f74e7b
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,8 @@ github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQ
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/openshift/api v0.0.0-20211209135129-c58d9f695577/go.mod h1:DoslCwtqUpr3d/gsbq4ZlkaMEdYqKxuypsDjorcHhME=
github.com/openshift/api v0.0.0-20220324135351-3d6a78ae0721 h1:2kDNqCgKxnv/KuvUoDlc9sC0TODOtSOxPvuxvKKkVaM=
github.com/openshift/api v0.0.0-20220324135351-3d6a78ae0721/go.mod h1:F/eU6jgr6Q2VhMu1mSpMmygxAELd7+BUxs3NHZ25jV4=
github.com/openshift/api v0.0.0-20220325173635-8107b7a38e53 h1:WpOfczPbuY5llRH94DJRsGTsgm7d8iAA2b7m0+YXAqI=
github.com/openshift/api v0.0.0-20220325173635-8107b7a38e53/go.mod h1:F/eU6jgr6Q2VhMu1mSpMmygxAELd7+BUxs3NHZ25jV4=
github.com/openshift/build-machinery-go v0.0.0-20210712174854-1bb7fd1518d3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/build-machinery-go v0.0.0-20211213093930-7e33a7eb4ce3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 h1:SG1aqwleU6bGD0X4mhkTNupjVnByMYYuW4XbnCPavQU=
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/vsphere/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/vmware/govmomi/vim25/types"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apimachinerytypes "k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"

Expand Down Expand Up @@ -829,7 +830,7 @@ func taskIsFinished(task *mo.Task) (bool, error) {
}
}

func setProviderStatus(taskRef string, condition machinev1.VSphereMachineProviderCondition, scope *machineScope, vm *virtualMachine) error {
func setProviderStatus(taskRef string, condition metav1.Condition, scope *machineScope, vm *virtualMachine) error {
klog.Infof("%s: Updating provider status", scope.machine.Name)

if vm != nil {
Expand All @@ -850,7 +851,7 @@ func setProviderStatus(taskRef string, condition machinev1.VSphereMachineProvide
scope.providerStatus.TaskRef = taskRef
}

scope.providerStatus.Conditions = setVSphereMachineProviderConditions(condition, scope.providerStatus.Conditions)
scope.providerStatus.Conditions = setConditions(condition, scope.providerStatus.Conditions)

return nil
}
Expand Down
28 changes: 13 additions & 15 deletions pkg/controller/vsphere/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ func getVSphereConfig(c runtimeclient.Reader) (*vSphereConfig, error) {
return &vcfg, nil
}

func setVSphereMachineProviderConditions(condition machinev1.VSphereMachineProviderCondition, conditions []machinev1.VSphereMachineProviderCondition) []machinev1.VSphereMachineProviderCondition {
func setConditions(condition metav1.Condition, conditions []metav1.Condition) []metav1.Condition {
now := metav1.Now()

if existingCondition := findProviderCondition(conditions, condition.Type); existingCondition == nil {
condition.LastProbeTime = now
if existingCondition := findCondition(conditions, condition.Type); existingCondition == nil {
condition.LastTransitionTime = now
conditions = append(conditions, condition)
} else {
Expand All @@ -124,7 +123,7 @@ func setVSphereMachineProviderConditions(condition machinev1.VSphereMachineProvi
return conditions
}

func findProviderCondition(conditions []machinev1.VSphereMachineProviderCondition, conditionType machinev1.ConditionType) *machinev1.VSphereMachineProviderCondition {
func findCondition(conditions []metav1.Condition, conditionType string) *metav1.Condition {
for i := range conditions {
if conditions[i].Type == conditionType {
return &conditions[i]
Expand All @@ -133,7 +132,7 @@ func findProviderCondition(conditions []machinev1.VSphereMachineProviderConditio
return nil
}

func updateExistingCondition(newCondition, existingCondition *machinev1.VSphereMachineProviderCondition) {
func updateExistingCondition(newCondition, existingCondition *metav1.Condition) {
if !shouldUpdateCondition(newCondition, existingCondition) {
return
}
Expand All @@ -144,26 +143,25 @@ func updateExistingCondition(newCondition, existingCondition *machinev1.VSphereM
existingCondition.Status = newCondition.Status
existingCondition.Reason = newCondition.Reason
existingCondition.Message = newCondition.Message
existingCondition.LastProbeTime = newCondition.LastProbeTime
}

func shouldUpdateCondition(newCondition, existingCondition *machinev1.VSphereMachineProviderCondition) bool {
func shouldUpdateCondition(newCondition, existingCondition *metav1.Condition) bool {
return newCondition.Reason != existingCondition.Reason || newCondition.Message != existingCondition.Message
}

func conditionSuccess() machinev1.VSphereMachineProviderCondition {
return machinev1.VSphereMachineProviderCondition{
Type: machinev1.MachineCreation,
Status: corev1.ConditionTrue,
func conditionSuccess() metav1.Condition {
return metav1.Condition{
Type: string(machinev1.MachineCreation),
Status: metav1.ConditionTrue,
Reason: machinev1.MachineCreationSucceededConditionReason,
Message: "Machine successfully created",
}
}

func conditionFailed() machinev1.VSphereMachineProviderCondition {
return machinev1.VSphereMachineProviderCondition{
Type: machinev1.MachineCreation,
Status: corev1.ConditionFalse,
func conditionFailed() metav1.Condition {
return metav1.Condition{
Type: string(machinev1.MachineCreation),
Status: metav1.ConditionFalse,
Reason: machinev1.MachineCreationSucceededConditionReason,
}
}
Expand Down

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

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

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

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

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

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

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

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

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

Loading