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

Update Controller To Track Action Progress #1487

Merged
merged 7 commits into from
Jul 26, 2022
Merged

Conversation

ihcsim
Copy link
Contributor

@ihcsim ihcsim commented Jun 16, 2022

Change Overview

This PR updates the controller to track the progress of an actionset, by assessing the phase states. The progress tracker runs in its own goroutine with a 2-second ticker. The progress computation assigns weight to a phase, per the underlying Kanister Function the supports the phase. If a Kanister Function is marked as a long-running one, its phase will be assigned the heavy weight. Otherwise, the phase has the normal weight.

The actionset progress always starts at 10%, to distinguish started/running phases from idle ones, and ends at 100%.

The computation is also done on a best-effort basis, with no elaborated retries on update errors, to ensure the progress goroutine doesn't contend for resources nor contribute to performance latency. In other words, it's possible that the progress goes from 10% to 100% with no immediate updates.

Design doc : https://github.com/kanisterio/kanister/blob/master/design/progress-tracking.md

Out-of-scope: Progress computation of each phase based on log outputs are slated for future PRs.

Release note: The actionSet CRD must be upgraded manually, as Helm doesn't upgrade CRD.

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Issues

Test Plan

Deploy this multi-actions blueprint, where each phase has different completion time:

cat <<EOF | kubectl apply -f -
apiVersion: cr.kanister.io/v1alpha1
kind: Blueprint
metadata:
  name: actionset-progress
  namespace: kanister
actions:
  action0:
    phases:
    - func: KubeTask
      name: action0-task0
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
         sleep 1
    - func: KubeTask
      name: action0-task1
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
         sleep 1
    - func: KubeTask
      name: action0-task2
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
          sleep 5
    - func: KubeTask
      name: action0-task3
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
          sleep 20
  action1:
    phases:
    - func: KubeTask
      name: action1-task0
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
          sleep 1
    - func: KubeTask
      name: action1-task1
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
          sleep 10
    - func: KubeTask
      name: action1-task2
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
          sleep 12
    - func: KubeTask
      name: action1-task3
      args:
        namespace: "{{ .Namespace.Name }}"
        image: ghcr.io/kanisterio/kanister-tools:v9.99.9-dev
        command:
        - sh
        - -c
        - |
          sleep 30
EOF

Create this multi-actions ActionSet to invoke actions in the blueprint:

cat <<EOF | kubectl create -f -
apiVersion: cr.kanister.io/v1alpha1
kind: ActionSet
metadata:
  generateName: multi-actions-
  namespace: kanister
spec:
  actions:
  - name: action0
    blueprint: actionset-progress
    object:
      kind: Namespace
      name: default
  - name: action1
    blueprint: actionset-progress
    object:
      kind: Namespace
      name: default
EOF

The result should look like this:

kubectl -n kanister get actionset multi-actions-t6v65 -ojsonpath='progress: {.status.progress.percentCompleted}{"\n"}last transition time: {.status.progress.lastTransitionTime}
{"\n"}' -w
progrress: 37.50                                                                                                                                                                                 
last transition time: 2022-06-16T16:18:01Z                                                                                                                                                     
progress: 37.50                                                                                                                                                                                 
last transition time: 2022-06-16T16:18:03Z                                                                                                                                                     
progress: 37.50                                                                                                                                                                                 
last transition time: 2022-06-16T16:18:05Z                                                                                                                                                     
progress: 37.50                                                                                                                                                                                 
last transition time: 2022-06-16T16:18:07Z                                                                                                                                                     
progress: 37.50                                                                                                                                                                                 
last transition time: 2022-06-16T16:18:07Z                                                                                                                                                     
progress: 37.50                                                                                                                                                                                 
last transition time: 2022-06-16T16:18:07Z                                                                                                                                                     
progress: 62.50                                                                                                                                                                                 
last transition time: 2022-06-16T16:18:09Z                                                                                                                                                     
percent: 62.50                                            
# ....
  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
@ihcsim ihcsim requested a review from pavannd1 June 16, 2022 17:47
@github-actions
Copy link
Contributor

Thanks for submitting this pull request 🎉. The team will review it soon and get back to you.

If you haven't already, please take a moment to review our project contributing guideline and Code of Conduct document.

@infraq infraq added this to In Progress in Kanister Jun 16, 2022
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
@pavannd1 pavannd1 requested a review from e-sumin June 16, 2022 18:50
@ihcsim ihcsim force-pushed the progress-tracking-actionset branch from 6b8f53b to 942ee9f Compare July 4, 2022 17:17
Copy link
Contributor

@pavannd1 pavannd1 left a comment

Choose a reason for hiding this comment

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

1st review with minor nits. Thorough review in progress 🦅 👀

pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/progress/action.go Outdated Show resolved Hide resolved
pkg/progress/action.go Show resolved Hide resolved
pkg/progress/action.go Outdated Show resolved Hide resolved
pkg/progress/action.go Outdated Show resolved Hide resolved
pkg/progress/action.go Outdated Show resolved Hide resolved
@pavannd1 pavannd1 requested a review from PrasadG193 July 18, 2022 18:29
@pavannd1
Copy link
Contributor

@PrasadG193 @viveksinghggits Please review this 👍🏼

client versioned.Interface,
actionSetName string,
namespace string) error {
var err error
Copy link
Contributor

Choose a reason for hiding this comment

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

Correct me if I'm wrong, but seems that err variable is unused ?
in lines #62/#64 we are exiting immediately, and err will stay nil

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good 👁️. Yes, it can be removed.

pkg/progress/action.go Outdated Show resolved Hide resolved
pkg/progress/action.go Show resolved Hide resolved
@viveksinghggits
Copy link
Contributor

Should we add progress in the additional printer columns so that someone can just figure out the progress by looking at the output of k get actionset.

Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
Signed-off-by: Ivan Sim <ivan.sim@kasten.io>
@ihcsim
Copy link
Contributor Author

ihcsim commented Jul 21, 2022

@viveksinghggits that's a good idea.

Now we can watch the progress while the actionset is running:

$ watch k -n kanister get actionset                                      
NAME                  PROGRESS   LAST TRANSITION TIME   STATE
multi-actions-zmfj4   100.00     2022-07-20T23:41:11Z   complete
multi-actions-fl5w9   87.50      2022-07-21T02:33:12Z   running

Kanister automation moved this from In Progress to Reviewer approved Jul 26, 2022
Copy link
Contributor

@pavannd1 pavannd1 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@pavannd1 pavannd1 added the kueue label Jul 26, 2022
@mergify mergify bot merged commit 2fd28db into master Jul 26, 2022
@mergify mergify bot deleted the progress-tracking-actionset branch July 26, 2022 19:49
Kanister automation moved this from Reviewer approved to Done Jul 26, 2022
pavannd1 added a commit that referenced this pull request Jul 29, 2022
mergify bot pushed a commit that referenced this pull request Jul 29, 2022
@viveksinghggits viveksinghggits restored the progress-tracking-actionset branch August 5, 2022 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants