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

UpdateJob when Job annotations or labels changed #806

Merged

Conversation

silenceli
Copy link

bug description: #805

@volcano-sh-bot volcano-sh-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label May 14, 2020
@TravisBuddy
Copy link

Travis tests have failed

Hey @silenceli,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 30c396e0-95c2-11ea-886e-05c348efcea1

@silenceli silenceli force-pushed the updatejob-when-annotation-updated branch from 7c864bf to b915353 Compare May 14, 2020 09:18
@TravisBuddy
Copy link

Travis tests have failed

Hey @silenceli,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: ffc7ffc0-95c3-11ea-886e-05c348efcea1

@silenceli silenceli force-pushed the updatejob-when-annotation-updated branch from b915353 to 0fd0bf4 Compare May 14, 2020 09:21
@TravisBuddy
Copy link

Travis tests have failed

Hey @silenceli,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 6ccb1a80-95c4-11ea-886e-05c348efcea1

@silenceli silenceli force-pushed the updatejob-when-annotation-updated branch from 0fd0bf4 to b3fb4a9 Compare May 14, 2020 09:26
@k82cn
Copy link
Member

k82cn commented May 14, 2020

/assign @hzxuzhonghu

@TravisBuddy
Copy link

Travis tests have failed

Hey @silenceli,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 652eff60-95cb-11ea-886e-05c348efcea1

if reflect.DeepEqual(newJob.Annotations, oldJob.Annotations) &&
reflect.DeepEqual(newJob.Labels, oldJob.Labels) &&
reflect.DeepEqual(newJob.Spec, oldJob.Spec) &&
newJob.Status.State.Phase == oldJob.Status.State.Phase {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if other fields changed, like finalizer? You can still meet the error.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So i suggest

// no update at all
if newJob.ResourceVersion == oldJob.ResourceVersion {
    	return 
}

	if err := cc.cache.Update(newJob); err != nil {
		klog.Errorf("UpdateJob - Failed to update job <%s/%s>: %v in cache",
			newJob.Namespace, newJob.Name, err)
	}

	// NOTE: Since we only reconcile job based on Spec, we will ignore other attributes
	// For Job status, it's used internally and always been updated via our controller.
	if reflect.DeepEqual(newJob.Spec, oldJob.Spec) && newJob.Status.State.Phase == oldJob.Status.State.Phase {
		klog.V(6).Infof("Job update event is ignored since no update in 'Spec'.")
		return
	}

Copy link
Author

Choose a reason for hiding this comment

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

Thx,all done

@silenceli silenceli force-pushed the updatejob-when-annotation-updated branch from b3fb4a9 to 20e5753 Compare May 15, 2020 06:08
@volcano-sh-bot volcano-sh-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 15, 2020
@silenceli
Copy link
Author

Please review again, thanks~

@TravisBuddy
Copy link

Travis tests have failed

Hey @silenceli,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: a0cb39a0-9673-11ea-a89a-bff82cd15392

@silenceli silenceli force-pushed the updatejob-when-annotation-updated branch from 20e5753 to a7d3a65 Compare May 15, 2020 07:15
@TravisBuddy
Copy link

Travis tests have failed

Hey @silenceli,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

TravisBuddy Request Identifier: 03d56810-967c-11ea-a89a-bff82cd15392

@silenceli silenceli force-pushed the updatejob-when-annotation-updated branch from a7d3a65 to 8108eef Compare May 15, 2020 07:45
@volcano-sh-bot volcano-sh-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 15, 2020
@k82cn
Copy link
Member

k82cn commented May 17, 2020

/approve

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 17, 2020
Copy link
Collaborator

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks for the fix

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label May 18, 2020
@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu, k82cn, silenceli

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot merged commit 1fd8846 into volcano-sh:master May 18, 2020
@hzxuzhonghu
Copy link
Collaborator

@Thor-wl please help cherry-pick to release 0.4 branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants