diff --git a/api/v1alpha1/rollingupgrade_types.go b/api/v1alpha1/rollingupgrade_types.go index 10b9110b..5804dc57 100644 --- a/api/v1alpha1/rollingupgrade_types.go +++ b/api/v1alpha1/rollingupgrade_types.go @@ -17,11 +17,12 @@ limitations under the License. package v1alpha1 import ( - "common" + "fmt" "strconv" "strings" + "github.com/keikoproj/upgrade-manager/controllers/common" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" @@ -220,13 +221,16 @@ func (r *RollingUpgrade) IsForceRefresh() bool { return r.Spec.ForceRefresh } +func (r *RollingUpgrade) StrategyMode() UpdateStrategyMode { + return r.Spec.Strategy.Mode +} func (r *RollingUpgrade) Validate() (bool, error) { strategy := r.Spec.Strategy // validating the Type value if strategy.Type == "" { r.Spec.Strategy.Type = RandomUpdateStrategy - } else if !common.ContainsEqualFold(AllowedStrategyType, strategy.Type) { + } else if !common.ContainsEqualFold(AllowedStrategyType, string(strategy.Type)) { err := fmt.Errorf("%s: Invalid value for startegy Type - %d", r.Name, strategy.MaxUnavailable.IntVal) return false, err } diff --git a/controllers/providers/aws/utils.go b/controllers/providers/aws/utils.go index e5e01bd2..f14bc819 100644 --- a/controllers/providers/aws/utils.go +++ b/controllers/providers/aws/utils.go @@ -86,15 +86,16 @@ func GetScalingAZs(instances []*autoscaling.Instance) []string { return AZs } -func SelectInstancesByAZ(instances []*autoscaling.Group) *autoscaling.Instance { - for _, instance := range group.Instances { - selectedID := aws.StringValue(instance.InstanceId) - if strings.EqualFold(instanceID, selectedID) { - return instance - } - } - return &autoscaling.Instance{} -} +// func SelectInstancesByAZ(instances []*autoscaling.Group) *autoscaling.Instance { +// for _, instance := range group.Instances { +// selectedID := aws.StringValue(instance.InstanceId) +// if strings.EqualFold(instanceID, selectedID) { +// return instance +// } +// } +// return &autoscaling.Instance{} +// } + // func ListScalingInstanceIDs(group *autoscaling.Group) []string { // instanceIDs := make([]string, 0) diff --git a/controllers/upgrade.go b/controllers/upgrade.go index 31bb193a..5dd7ac33 100644 --- a/controllers/upgrade.go +++ b/controllers/upgrade.go @@ -77,12 +77,21 @@ func (r *RollingUpgradeReconciler) ReplaceNodeBatch(rollingUpgrade *v1alpha1.Rol switch mode { case v1alpha1.UpdateStrategyModeEager: for _, target := range batch { + _ = target // Add in-progress tag // Standby // Wait for desired nodes + // predrain script + + // Issue drain/scripts concurrently - set lastDrainTime + + // post drain script + + // Wait for desired nodes + // Issue drain/scripts concurrently - set lastDrainTime // Is drained? @@ -91,6 +100,7 @@ func (r *RollingUpgradeReconciler) ReplaceNodeBatch(rollingUpgrade *v1alpha1.Rol } case v1alpha1.UpdateStrategyModeLazy: for _, target := range batch { + _ = target // Add in-progress tag // Issue drain/scripts concurrently - set lastDrainTime @@ -100,7 +110,7 @@ func (r *RollingUpgradeReconciler) ReplaceNodeBatch(rollingUpgrade *v1alpha1.Rol // Terminate - set lastTerminateTime } } - + return true, nil } func (r *RollingUpgradeReconciler) SelectTargets(rollingUpgrade *v1alpha1.RollingUpgrade, scalingGroup *autoscaling.Group) []*autoscaling.Instance {