Skip to content

Commit

Permalink
only consider a template namechange as a difference to rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
rvanderp3 committed Feb 21, 2024
1 parent 9eaddfb commit 8ae17e2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func (p providerConfig) Diff(other ProviderConfig) ([]string, error) {
case configv1.OpenStackPlatformType:
return deep.Equal(p.openstack.providerConfig, other.OpenStack().providerConfig), nil
case configv1.VSpherePlatformType:
return deep.Equal(p.vsphere.providerConfig, other.VSphere().providerConfig), nil
return p.VSphere().Diff(other.VSphere().providerConfig)
case configv1.NonePlatformType:
return nil, errUnsupportedPlatformType
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import (
"strings"

"github.com/go-logr/logr"
"github.com/go-test/deep"
configv1 "github.com/openshift/api/config/v1"
machinev1 "github.com/openshift/api/machine/v1"
"github.com/openshift/api/machine/v1beta1"
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -83,6 +85,31 @@ func (v VSphereProviderConfig) getWorkspaceFromFailureDomain(failureDomain *conf
return workspace
}

func getReducedTemplate(template string) string {
if strings.Contains(template, "/") {
return template[strings.LastIndex(template, "/")+1:]
}

return template
}

// Diff compares two ProviderConfigs and returns a list of differences,
// or nil if there are none.
func (v VSphereProviderConfig) Diff(other v1beta1.VSphereMachineProviderSpec) ([]string, error) {

// templates can be provided either with an absolute path or relative.
// this can result in the control plane nodes rolling out when they dont need to.
// as long as the OVA name matches that will be considered a match.
otherTemplate := getReducedTemplate(other.Template)
currentTemplate := getReducedTemplate(v.providerConfig.Template)

if otherTemplate == currentTemplate {
other.Template = v.providerConfig.Template
}

return deep.Equal(v.providerConfig, other), nil
}

// InjectFailureDomain returns a new VSphereProviderConfig configured with the failure domain.
func (v VSphereProviderConfig) InjectFailureDomain(fd machinev1.VSphereFailureDomain) (VSphereProviderConfig, error) {
newVSphereProviderConfig := v
Expand Down

0 comments on commit 8ae17e2

Please sign in to comment.