Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Rollout promote action #20509

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ if obj.status ~= nil and not(fullyPromoted) then
end
end

actions["promote"] = {["disabled"] = true}
if obj.status.canary ~= nil and not(fullyPromoted) then
-- promote one step is only for canary
actions["promote"]["disabled"] = false
end

return actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
function getCurrentCanaryStep(obj)

if obj.spec.strategy.canary == nil or table.getn(obj.spec.strategy.canary.steps) == 0 then
return nil
end

local currentStepIndex = 0

if obj.status.currentStepIndex ~= nil then
currentStepIndex = obj.status.currentStepIndex
end

return currentStepIndex

end

if obj.spec.paused ~= nil and obj.spec.paused then
obj.spec.paused = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give more insight on when paused would be true and why do we need to handle it in promote?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pause is set to true only when manually paused by the user, using the kubectl plugin. In the plugin or the rollouts UI however, the un-pause is handled as well in the promote action, and there is no other available action to only unpause a 'manual' pause.

So, it's a semantic difference, where we can handle that in the promote action as well, or leave this bit handled in the resume action only. For the sake of consistency across UIs and plugins however, I feel like this should be handled here. resume action might not be needed anymore

end

local isInconclusive = obj.spec.strategy.canary ~= nil and obj.status.canary.currentStepAnalysisRunStatus ~= nil and obj.status.canary.currentStepAnalysisRunStatus.status == "Inconclusive"

if isInconclusive and obj.status.pauseConditions ~= nil and table.getn(obj.status.pauseConditions) > 0 and obj.status.controllerPause ~= nil and obj.status.controllerPause then

local currentStepIndex = getCurrentCanaryStep(obj)
if currentStepIndex ~= nil then
if currentStepIndex < table.getn(obj.spec.strategy.canary.steps) then
currentStepIndex = currentStepIndex + 1
end

obj.status.pauseConditions = nil
obj.status.controllerPause = false
obj.status.currentStepIndex = currentStepIndex
end

elseif obj.status.pauseConditions ~= nil and table.getn(obj.status.pauseConditions) > 0 then

obj.status.pauseConditions = nil

elseif obj.spec.strategy.canary ~= nil then

local currentStepIndex = getCurrentCanaryStep(obj)
if currentStepIndex ~= nil then
if currentStepIndex < table.getn(obj.spec.strategy.canary.steps) then
currentStepIndex = currentStepIndex + 1
end

obj.status.pauseConditions = nil
obj.status.currentStepIndex = currentStepIndex
end

end

return obj
Loading