Skip to content

Commit

Permalink
revert #300 (#305)
Browse files Browse the repository at this point in the history
Signed-off-by: sbadiger <[email protected]>
  • Loading branch information
shreyas-badiger authored Sep 3, 2021
1 parent df08ab0 commit 6252725
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 210 deletions.
2 changes: 1 addition & 1 deletion controllers/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ func GetChunks(items []string, chunkSize int) [][]string {
chunks = append(chunks, items[i:end])
}
return chunks
}
}
27 changes: 11 additions & 16 deletions controllers/rollingupgrade_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,17 @@ import (
type RollingUpgradeReconciler struct {
client.Client
logr.Logger
Scheme *runtime.Scheme
AdmissionMap sync.Map
CacheConfig *cache.Config
EventWriter *kubeprovider.EventWriter
maxParallel int
ScriptRunner ScriptRunner
Auth *RollingUpgradeAuthenticator
DrainGroupMapper *sync.Map
DrainErrorMapper *sync.Map
ClusterNodesMap *sync.Map
ReconcileMap *sync.Map
DrainTimeout int
IgnoreDrainFailures bool
Scheme *runtime.Scheme
AdmissionMap sync.Map
CacheConfig *cache.Config
EventWriter *kubeprovider.EventWriter
maxParallel int
ScriptRunner ScriptRunner
Auth *RollingUpgradeAuthenticator
DrainGroupMapper *sync.Map
DrainErrorMapper *sync.Map
ClusterNodesMap *sync.Map
ReconcileMap *sync.Map
}

// RollingUpgradeAuthenticator has the clients for providers
Expand Down Expand Up @@ -168,9 +166,6 @@ func (r *RollingUpgradeReconciler) Reconcile(ctx context.Context, req ctrl.Reque
c.ClusterNodes = r.getClusterNodes()
return c
}(),

DrainTimeout: r.DrainTimeout,
IgnoreDrainFailures: r.IgnoreDrainFailures,
}

// process node rotation
Expand Down
10 changes: 3 additions & 7 deletions controllers/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ type RollingUpgradeContext struct {
RollingUpgrade *v1alpha1.RollingUpgrade
DrainManager *DrainManager
metricsMutex *sync.Mutex

DrainTimeout int
IgnoreDrainFailures bool
}

func (r *RollingUpgradeContext) RotateNodes() error {
Expand Down Expand Up @@ -117,8 +114,7 @@ func (r *RollingUpgradeContext) RotateNodes() error {

func (r *RollingUpgradeContext) ReplaceNodeBatch(batch []*autoscaling.Instance) (bool, error) {
var (
mode = r.RollingUpgrade.StrategyMode()
drainTimeout = common.IntMax(r.DrainTimeout, r.RollingUpgrade.DrainTimeout())
mode = r.RollingUpgrade.StrategyMode()
)

r.Info("rotating batch", "instances", awsprovider.GetInstanceIDs(batch), "name", r.RollingUpgrade.NamespacedName())
Expand Down Expand Up @@ -271,9 +267,9 @@ func (r *RollingUpgradeContext) ReplaceNodeBatch(batch []*autoscaling.Instance)
// Turns onto NodeRotationDrain
r.NodeStep(inProcessingNodes, nodeSteps, r.RollingUpgrade.Spec.AsgName, nodeName, v1alpha1.NodeRotationDrain)

if err := r.Auth.DrainNode(node, time.Duration(r.RollingUpgrade.PostDrainDelaySeconds()), drainTimeout, r.Auth.Kubernetes); err != nil {
if err := r.Auth.DrainNode(node, time.Duration(r.RollingUpgrade.PostDrainDelaySeconds()), r.RollingUpgrade.DrainTimeout(), r.Auth.Kubernetes); err != nil {
// ignore drain failures if either of spec or controller args have set ignoreDrainFailures to true.
if !r.RollingUpgrade.IsIgnoreDrainFailures() && !r.IgnoreDrainFailures {
if !r.RollingUpgrade.IsIgnoreDrainFailures() {
r.DrainManager.DrainErrors <- errors.Errorf("DrainNode failed: instanceID - %v, %v", instanceID, err.Error())
return
}
Expand Down
Loading

0 comments on commit 6252725

Please sign in to comment.