Skip to content
This repository was archived by the owner on Oct 11, 2019. It is now read-only.

Only keep existing mutation timestamp when user is replication - #186

Open
benbarclay wants to merge 1 commit into
masterfrom
bbarclay/VYGR-406_scheduled_e2e
Open

Only keep existing mutation timestamp when user is replication#186
benbarclay wants to merge 1 commit into
masterfrom
bbarclay/VYGR-406_scheduled_e2e

Conversation

@benbarclay

Copy link
Copy Markdown
Contributor

No description provided.

@benbarclay
benbarclay requested a review from a team February 21, 2019 04:12
Comment thread pkg/replication/admission.go Outdated
)

const (
// User account this component uses

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"this component"? replication admission is a separate component from replication controller...
I would rephrase comment to explicitly mention replication controller.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I view replication as an entire subsystem. The implementation is split across a controller and a couple of webhooks. I take it you see it differently?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair enough, but in this case it's replication controller request to API server being intercepted by a webhook, so it seems useful to be more clear about what we do.

Comment thread pkg/replication/admission.go Outdated

func createAnnotationPatch(operation admissionv1beta1.Operation, newSD *comp_v1.ServiceDescriptor) ([]byte, error) {
ts, err := generateUpdated(operation, newSD)
func isReplication(userInfo authenticationv1.UserInfo) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isReplicationController?

Comment thread pkg/replication/admission.go Outdated
func generateUpdated(operation admissionv1beta1.Operation, newSD *comp_v1.ServiceDescriptor) (time.Time, error) {
if operation != admissionv1beta1.Update {
func generateUpdated(isReplication bool, operation admissionv1beta1.Operation, newSD *comp_v1.ServiceDescriptor) (time.Time, error) {
if operation != admissionv1beta1.Update || !isReplication {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm... So this code is written in a way that if replication controller doesn't set the timestamp (why? is that possible?), we will generate a timestamp.

Maybe instead we could always parseTimestamp for replication controller and return error if annotation is missing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

afaict the only situation we don't want to generate a timestamp is if the replication controller is doing an update on an existing thing. In all other cases we do want to generate a timestamp. Isn't that what's going on here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but what is the case when replication controller doesn't provide a timestamp? I guess to rephrase the requirement: replication controller must set timestamp and we don't touch it (but validate it's set). In all other cases we generate timestamp.
This way it will be easier to catch bugs in replication controller I think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair call, I'll fix that up

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also not sure if we actually still need to check for operation != admissionv1beta1.Update? I find this code hard to understand. My idea:

if isReplication {
  ts, exists := newSD.Annotations[updatedKey]
  if !exists {
    return nil, errors.New("replication controller must set the mutation timestamp")  
  }
  return parseTimestamp(ts)
}

return time.Now(), nil

@benbarclay
benbarclay force-pushed the bbarclay/VYGR-406_scheduled_e2e branch from 658e048 to 6167fd6 Compare February 21, 2019 06:07
}

return parseTimestamp(ts)
return time.Now(), nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, I think we may need to keep the timestamp if hash hasn't changed, e.g. when someone adds/deletes annotation or finalizer.
So you need to pass a flag if hash has changed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants