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

Emit events for deployment hooks #9456

Merged
merged 1 commit into from
Jun 30, 2016
Merged

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Jun 21, 2016

Fixes: #9260

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 21, 2016

@Kargakis PTAL (not tested yet)

@@ -70,8 +77,14 @@ func (e *HookExecutor) Execute(hook *deployapi.LifecycleHook, deployment *kapi.R
var err error
switch {
case len(hook.TagImages) > 0:
tagEventMessages := []string{}
for _, t := range hook.TagImages {
tagEventMessages = append(tagEventMessages, fmt.Sprintf("container %s image to %s", t.ContainerName, t.To.Name))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

having a container image name here will make these images better :-)

@mfojtik mfojtik force-pushed the hook-events branch 5 times, most recently from 4c6a1c4 to d534d1a Compare June 22, 2016 09:39
@@ -399,6 +399,7 @@ func GetBootstrapClusterRoles() []authorizationapi.ClusterRole {
authorizationapi.NewRule("get", "list", "update").Groups(kapiGroup).Resources("replicationcontrollers").RuleOrDie(),
authorizationapi.NewRule("get", "list", "watch", "create").Groups(kapiGroup).Resources("pods").RuleOrDie(),
authorizationapi.NewRule("get").Groups(kapiGroup).Resources("pods/log").RuleOrDie(),
authorizationapi.NewRule("create").Groups(kapiGroup).Resources("events").RuleOrDie(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liggitt policy PTAL (the client running inside the deployer pod needs ability to create events to report hooks/etc.).

Copy link
Contributor

Choose a reason for hiding this comment

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

You probably need to run UPDATE_BOOTSTRAP_POLICY_FIXTURE_DATA=true make test-unit WHAT=pkg/cmd/server/bootstrappolicy and save the diff.

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 22, 2016

@Kargakis ready for review :-)

@@ -131,10 +131,10 @@ func NewDeployer(client kclient.Interface, oclient client.Interface, out, errOut
strategyFor: func(config *deployapi.DeploymentConfig) (strategy.DeploymentStrategy, error) {
switch config.Spec.Strategy.Type {
case deployapi.DeploymentStrategyTypeRecreate:
return recreate.NewRecreateDeploymentStrategy(client, oclient, kapi.Codecs.UniversalDecoder(), out, errOut, until), nil
return recreate.NewRecreateDeploymentStrategy(client, oclient, client.Events(""), kapi.Codecs.UniversalDecoder(), out, errOut, until), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you have to pass the recorder as a separate arg? Can't you pick it while in the function from client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kargakis no, events has different interface (record.EventSink)

fmt.Fprintf(e.out, "warning: %s hook failed, deployment will continue: %v\n", label, err)
e.recorder.Eventf(config, kapi.EventTypeNormal, "Failed", "The %s hook failed: %v (ignore), deployment %s/%s will continue", label, err, deployment.Namespace, deployment.Name)
// TODO: The event might not be send to server, remove the sleep when kubernetes(#27858) is resolved
time.Sleep(1 * time.Second)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kargakis will keep this here (kubernetes/kubernetes#27858) so we can see the event logs and will fix this as soon as the upstream issue is fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am going to cry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kargakis i can follow upstream pattern and make the sleep random :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Kargakis you can stop crying now

@mfojtik mfojtik force-pushed the hook-events branch 3 times, most recently from 87f9d00 to a9e5f08 Compare June 23, 2016 19:27
@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 23, 2016

@deads2k @Kargakis reworked, PTAL (I tested this and it is working)

@@ -64,14 +70,49 @@ func NewHookExecutor(client kclient.PodsNamespacer, tags client.ImageStreamTagsN
}
}

func (e *HookExecutor) event(deployment *kapi.ReplicationController, eventType, reason, msg string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

emitEvent

@mfojtik mfojtik force-pushed the hook-events branch 2 times, most recently from b44fae8 to 959fc1c Compare June 28, 2016 10:30
@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 28, 2016

@Kargakis updated, the event is now using DC and fallback to RC in case we are not able to decode RC to DC.

case deployapi.LifecycleHookFailurePolicyIgnore:
fmt.Fprintf(e.out, "warning: %s hook failed, deployment will continue: %v\n", label, err)
e.emitEvent(deployment, kapi.EventTypeWarning, "Failed", fmt.Sprintf("The %s hook failed: %v (ignore), deployment %s/%s will continue", label, err, deployment.Namespace, deployment.Name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Make these messages consistent with the above (either "pre-hook" or "pre hook")

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 28, 2016

@Kargakis fixed, tested.

@0xmichalis
Copy link
Contributor

@mfojtik I cannot find an event for a successful hook. Don't we want those events too? Otherwise, someone may think their hooks are running forever just by looking at the description of the config.

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 28, 2016

@Kargakis added.

@0xmichalis
Copy link
Contributor

LGTM [merge]

@0xmichalis
Copy link
Contributor

@mfojtik a follow-up issue for trimming down events in oc describe would be nice.

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 8a112b6

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 28, 2016

@Kargakis there is DescribeConfig (or something like that) that allows you to trim or toggle events displaying (it came with the rebase), I will check if it is something we can use to shave the event list here. And yes, will open a follow up.

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test ABORTED (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/5493/)

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 29, 2016

[merge]

@0xmichalis
Copy link
Contributor

#9512, [merge]

@0xmichalis
Copy link
Contributor

#9638, [merge]

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 30, 2016

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Jun 30, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/5607/) (Image: devenv-rhel7_4494)

@mfojtik
Copy link
Contributor Author

mfojtik commented Jun 30, 2016

TestClusterQuotaFuzzer flake (known).... [merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 8a112b6

@openshift-bot openshift-bot merged commit 9ca1579 into openshift:master Jun 30, 2016
@mfojtik mfojtik deleted the hook-events branch September 5, 2018 21:07
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

Successfully merging this pull request may close these issues.

4 participants