Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
feat: variable upgrade timeout based on num nodes (#3752)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis committed Aug 26, 2020
1 parent 3cdabbc commit 9a2d071
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions pkg/operations/kubernetesupgrade/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const (
defaultCordonDrainTimeout = time.Minute * 20
nodePropertiesCopyTimeout = time.Minute * 5
getResourceTimeout = time.Minute * 1
clusterUpgradeTimeout = time.Minute * 180
perNodeUpgradeTimeout = time.Minute * 20
vmStatusUpgraded vmStatus = iota
vmStatusNotUpgraded
vmStatusIgnored
Expand All @@ -75,9 +75,13 @@ func (ku *Upgrader) Init(translator *i18n.Translator, logger *logrus.Entry, clus

// RunUpgrade runs the upgrade pipeline
func (ku *Upgrader) RunUpgrade() error {
ctx, cancel := context.WithTimeout(context.Background(), clusterUpgradeTimeout)
defer cancel()
if err := ku.upgradeMasterNodes(ctx); err != nil {
controlPlaneUpgradeTimeout := perNodeUpgradeTimeout
if ku.ClusterTopology.DataModel.Properties.MasterProfile.Count > 0 {
controlPlaneUpgradeTimeout = perNodeUpgradeTimeout * time.Duration(ku.ClusterTopology.DataModel.Properties.MasterProfile.Count)
}
ctxControlPlane, cancelControlPlane := context.WithTimeout(context.Background(), controlPlaneUpgradeTimeout)
defer cancelControlPlane()
if err := ku.upgradeMasterNodes(ctxControlPlane); err != nil {
return err
}

Expand All @@ -87,12 +91,22 @@ func (ku *Upgrader) RunUpgrade() error {
return nil
}

if err := ku.upgradeAgentScaleSets(ctx); err != nil {
var numNodesToUpgrade int
for _, pool := range ku.ClusterTopology.AgentPoolScaleSetsToUpgrade {
numNodesToUpgrade += len(pool.VMsToUpgrade)
}
nodesUpgradeTimeout := perNodeUpgradeTimeout
if numNodesToUpgrade > 0 {
nodesUpgradeTimeout = perNodeUpgradeTimeout * time.Duration(numNodesToUpgrade)
}
ctxNodes, cancelNodes := context.WithTimeout(context.Background(), nodesUpgradeTimeout)
defer cancelNodes()
if err := ku.upgradeAgentScaleSets(ctxNodes); err != nil {
return err
}

//This is handling VMAS VMs only, not VMSS
return ku.upgradeAgentPools(ctx)
return ku.upgradeAgentPools(ctxNodes)
}

// handleUnreconcilableAddons ensures addon upgrades that addon-manager cannot handle by itself.
Expand Down

0 comments on commit 9a2d071

Please sign in to comment.