openshift / openshift/origin

Implement oc set container-hook.

Open
#17,489 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component/cli kind/feature lifecycle/frozen lifecycle/stale priority/P2
Dominant language
Go
Stars
8.7k
Forks
4.8k
Avg merge
4d 10h
Merged PRs (30d)
53

Description

The idea of implementing oc set container-hook was mentioned in https://github.com/openshift/origin/issues/9040 but it appears it was never implemented even though oc set probe and oc set deployment-hook were.

$ oc explain dc.spec.template.spec.containers.lifecycle
RESOURCE: lifecycle <Object>

DESCRIPTION:
     Actions that the management system should take in response to container
     lifecycle events. Cannot be updated.

    Lifecycle describes actions that the management system should take in response to container lifecycle events. For the PostStart and PreStop lifecycle handlers, management of the container blocks until the action is complete, unless the container process fails, in which case the handler is aborted.

FIELDS:
   postStart	<Object>
     PostStart is called immediately after a container is created. If the
     handler fails, the container is terminated and restarted according to its
     restart policy. Other management of the container blocks until the hook
     completes. More info:
     http://kubernetes.io/docs/user-guide/container-environment#hook-details

   preStop	<Object>
     PreStop is called immediately before a container is terminated. The
     container is terminated after the handler completes. The reason for
     termination is passed to the handler. Regardless of the outcome of the
     handler, the container is eventually terminated. Other management of the
     container blocks until the hook completes. More info:
     http://kubernetes.io/docs/user-guide/container-environment#hook-details

The command would need to support --post-start and --pre-stop options, along with similar options to oc set probe for --open-tcp, --get-url and -- options. Would also need a --container option to specify in which container when there is more than one in the pod and using -- to execute a command.

$ oc explain dc.spec.template.spec.containers.lifecycle.postStart
RESOURCE: postStart <Object>

DESCRIPTION:
     PostStart is called immediately after a container is created. If the
     handler fails, the container is terminated and restarted according to its
     restart policy. Other management of the container blocks until the hook
     completes. More info:
     http://kubernetes.io/docs/user-guide/container-environment#hook-details

    Handler defines a specific action that should be taken

FIELDS:
   exec	<Object>
     One and only one of the following should be specified. Exec specifies the
     action to take.

   httpGet	<Object>
     HTTPGet specifies the http request to perform.

   tcpSocket	<Object>
     TCPSocket specifies an action involving a TCP port. TCP hooks not yet
     supported

Only way to set these from the command line involves using oc edit or oc patch making them not as accessible as probes and deployment hooks.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing oc set probe and oc set deployment-hook commands, which are mentioned as related entry points. Define the command behavior around --post-start, --pre-stop, --open-tcp, --get-url, --, and --container, then verify that lifecycle handlers can be set for the requested container and action types.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.