-
Notifications
You must be signed in to change notification settings - Fork 32
feat: UseCase SetSkrKymaStateDeleting #2876
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
base: feat/kyma-deletion-service
Are you sure you want to change the base?
feat: UseCase SetSkrKymaStateDeleting #2876
Conversation
internal/service/kyma/deletion/usecases/set_skr_kyma_state_deleting_execute_test.go
Outdated
Show resolved
Hide resolved
internal/service/kyma/deletion/usecases/set_skr_kyma_state_deleting.go
Outdated
Show resolved
Hide resolved
internal/service/kyma/deletion/usecases/set_skr_kyma_state_deleting.go
Outdated
Show resolved
Hide resolved
| return false, err | ||
| } | ||
|
|
||
| status, err := u.kymaStatusRepo.Get(ctx, kyma.GetNamespacedName()) |
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.
Not sure if this will work? the KCP Kyma will have a different namespace than the SKR Kyma obviously, but we are interested in the SKR Kyma status here, right?
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.
It works, but agree that it may be confusing. The thing is that the passed kcpKyma.GetNamespacedName() is required to get the related skr client. Once we have the client, the Get actually works on the default names.
Agree that this is not ideal, but also don't have a good idea right now how this could be made more obvious.
func (r *Repository) Get(ctx context.Context, kymaName types.NamespacedName) (*v1beta2.KymaStatus, error) {
skrClient, err := r.getSkrClient(kymaName)
if err != nil {
return nil, err
}
kyma := &v1beta2.Kyma{}
if err := skrClient.Get(ctx,
types.NamespacedName{
Name: shared.DefaultRemoteKymaName,
Namespace: shared.DefaultRemoteNamespace,
},
kyma,
); err != nil {
return nil, err
}
return &kyma.Status, nil
}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.
Maybe it would be enough to state explicitly that the name we are expecting is kcpKymaName. Then it is obvious what to pass and the caller would rely on the repo to know how it translates this to the SKR kyma name?
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.
💡 Now I get it. Question is now, why we include the namespace in the cache key, when it's always the same.
About the naming: Another idea could be to change from Get() into ResolveSkrStatusByKymaName(). Maybe too much, but it would include the client lookup part.
Just something to think about for now, while we continue to work on the feature branch.
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.
Create a TODO
| return secret, nil | ||
| } | ||
|
|
||
| func (r *Repository) Exists(ctx context.Context, kymaName string) (bool, error) { |
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 context of the Repository this is actually the secret name,
the repo does not know that the secret name is the same as the kyma name. The consumer is deciding that and passing it. So secretName or name would be a better fit imo.
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 get the point. But let's discuss that shortly if you don't mind. I think it would also be valid to say that the repo knows how to map from a kymaName which is kind of the uniform identifier of the context we are reconciling in, to the dedicated resource we are touching. Same as the repo fir instance knows what namespace to look up in.
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 I would argue that in this case we are literally looking up a Secret by its name. The Repo does not know the context and is pretty "dumb" here, although the Secret name is also the Kyma name in reality, this could also be an accident or change even, in this context it's not of any value rather confusing even maybe. But just my opinion 😄
Would you be fine with name?
|
|
||
| // TODO: this should work as long as we use the same client cache that we passed to KymaSkrContextProvider | ||
| // it however depends on KymaSkrContextProvider.Init being called. As of now, this is the case, but we | ||
| // should re-think how we use the client cache. |
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.
Good point! We should for sure enforce this as a Singleton and make it apparent that it actually is the same reference used throughout kyma reconciliation. ☝️
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.
Yes. But I am also still contemplating with refactoring the client cache overall. Let's also quickly discuss where we put in our effort first 👍🏻
Description
Changes proposed in this pull request:
Related issue(s)