-
Notifications
You must be signed in to change notification settings - Fork 22
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
Setting valid Kyma Resource Name in a new step #937
Setting valid Kyma Resource Name in a new step #937
Conversation
Add one of following labels |
|
||
// could be simplified but this provides single source of truth for Kyma name | ||
operation.KymaResourceName = "" | ||
operation.KymaResourceName = steps.KymaName(operation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that duplicated assignment intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is what comment is about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In effect this makes this simple assignment:
operation.KymaResourceName=strings.ToLower(operation.RuntimeID)
But using always steps.KymaName we ensure consistence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why line 40 is required. I guess it is just to force KymaResourceName to be empty so that steps.KymaName
for sure sets it to RuntimeId
. Is that correct? It seems confusing because we need to get into details of invoked method when analysing what the empty assignment is all about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have the same feeling. It seems awkward. I need to reconsider this with @piotrmiskiewicz if this is what we wanted and if we have to pay such a price for this single point of truth
.
I would prefer to change steps.KymaName() semantics and avoid emptying
the operation.KymaResourceName.
But this function is already used exactly in this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it slightly in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to eat a cake and have a cake. Please take a look.
cmd/broker/provisioning.go
Outdated
{ | ||
condition: provisioning.SkipForOwnClusterPlan, | ||
stage: createRuntimeStageName, | ||
step: provisioning.NewCreateKymaNameStep(db.Operations()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this steps going to do anything else? For now it feels like it is just doing one assignment? I do not think that it is necessary to create a new step for such assignment. Maybe we could put that in initialisation step or somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how we decided to proceed after discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #905 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion this approach is justified, if you have doubts we can arrange a meeting tomorrow.
Some pros:
- simple logic,
- postcondition guaranteed,
- easy to manage in the process of migration from Provisioner to KIM - we will remove some steps gradually
- easy to extend
- easy to test
Currently we have a lot of quite complex steps, and it is hard to grasp what is set where, could we remove step, could we add a new one, and where to put it, to have all required data i to provide all required data for subsequent steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the question is where we should put this assignment. What are hard requirements? Such assignment (logic, which calculates the Kyma resoruce name) must:
- be executed after runtime ID gathering/generation (after interaction with Provisioner)
- be before Runtime CR creation which must be before ApplyKyma step (currently the logic is in the apply kyma step)
@ralikio - I know this logic is very simple, but we can't put it into initialisation step or something like this (it is too early).
We can't put it into a provisioner interaction step (we gather runtime ID there), because this step will be removed soon or even sometimes the provisioner interaction is not executed (own cluster plan)
@@ -54,6 +54,10 @@ func KymaName(operation internal.Operation) string { | |||
return strings.ToLower(operation.RuntimeID) | |||
} | |||
|
|||
func KymaRuntimeResourceName(operation internal.Operation) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this method used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We decided to create single point of truth for Runtime Resource as well. I will add invocation in next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I wanted to add invocation in separate PR, but it is more consistent if I add it here.
return s.operationManager.OperationFailed(operation, fmt.Sprint("RuntimeID not set, cannot create Kyma name"), nil, log) | ||
} | ||
|
||
operation.KymaResourceName = steps.CreateKymaNameFromOperation(operation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should be inside the inline function in the UpdateOperation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the next commit
operation.KymaResourceName = steps.CreateKymaNameFromOperation(operation) | ||
|
||
return s.operationManager.UpdateOperation(operation, func(op *internal.Operation) { | ||
op.RuntimeID = operation.RuntimeID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not need to update RuntimeID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next commit
} | ||
|
||
func (s *CreateKymaNameStep) Run(operation internal.Operation, log logrus.FieldLogger) (internal.Operation, time.Duration, error) { | ||
if time.Since(operation.UpdatedAt) > CreateRuntimeTimeout { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, we do not need to check any timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in the next commit.
@@ -58,7 +58,8 @@ func (s *CreateRuntimeResourceStep) Run(operation internal.Operation, log logrus | |||
return operation, 0, nil | |||
} | |||
|
|||
kymaResourceName, kymaResourceNamespace := getKymaNames(operation) | |||
kymaResourceName := steps.KymaRuntimeResourceName(operation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once, we set the KymaName in the previous step, we can just rely on an operation field, like namespace (one line below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in the next commit.
cmd/broker/provisioning.go
Outdated
@@ -84,6 +84,13 @@ func NewProvisioningProcessingQueue(ctx context.Context, provisionManager *proce | |||
stage: createRuntimeStageName, | |||
step: provisioning.NewGenerateRuntimeIDStep(db.Operations(), db.RuntimeStates(), db.Instances()), | |||
}, | |||
// postcondition: operation.RuntimeID is set | |||
{ | |||
condition: provisioning.SkipForOwnClusterPlan, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do not need this condition, it should wokr also for own cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then tests for OwnCluster fail.
Need to investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed no longer needed step.
Description
Changes proposed in this pull request:
step.KymaName
method as a single point of truth, the value is used to update the operationRelated issue(s)
#791
#905