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

Replace custom rollout timeout implementation with kubectl native alternative #136

Open
montmanu opened this issue Oct 29, 2020 · 0 comments

Comments

@montmanu
Copy link
Contributor

Description

Currently, support for the wait_deployments and wait_seconds parameters of drone-gke is implemented in part by a separate utility – a musl variant of timeout(1). This command is used in combination with the kubectl rollout status subcommand to ensure that rollout(s) of specific resource(s) succeed within a specific duration.

I'm not sure when support for the --timeout argument was added to kubectl rollout status, but I believe it can now be used to achieve the objective as the current implementation.

Desired Outcome

kubectl and drone-gke should both continue to function as expected when replacing the timeout command based implementation with the --timeout argument based implementation. In other words, both drone-gke and kubectl rollout status should continue to exit with a non-zero code if a rollout fails to complete within the specified duration; otherwise, each program should continue exiting with a 0 code.

The following is a psuedo-code example intended to demonstrate the core of a potential kubectl native alternative for the rollout duration threshold condition:

##
# $PLUGIN_WAIT_DEPLOYMENTS - a list of user specified resources which may have associated rollouts pending
# due to a previous `kubectl apply` execution (example: deployment/nginx)
##

##
# $PLUGIN_WAIT_SECONDS - a user specified rollout duration threshold (example: 180)
# any pending rollouts that are associated with the above resources must complete
# successfully within this duration; otherwise, the rollout is considered to have failed
# and the drone-gke process must exit with a non-zero status code
##

for resource in "${PLUGIN_WAIT_DEPLOYMENTS[@]}"; do
  ##
  # watch the rollout status of the latest revision associated with current $resource,
  # and wait until one of the following conditions is met:
  #
  # - the rollout has completed
  # - the duration represented by the --timeout argument has been exceeded
  ##
  kubectl rollout status "${resource}" --timeout "${PLUGIN_WAIT_SECONDS}s"

  ##
  # here, `$?` will be set to 0 if the rollout completed successfully within the specified duration.
  # otherwise `$?` will be set to a non-zero value.
  #
  # if during any iteration `kubectl rollout status` results in a non-zero exit code,
  # the `drone-gke` process must also exit with a non-zero code.
  ##
done

Alternatives Considered

None.

Related Resources

kubectl help rollout status

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-status-em-

#26

#58

#64

#121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant