Skip to content

Replace custom rollout timeout implementation with kubectl native alternative #136

@montmanu

Description

@montmanu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions