Skip to content

Conversation

@c-pius
Copy link
Contributor

@c-pius c-pius commented Nov 19, 2025

Description

Changes proposed in this pull request:

  • implements UseCase SetSkrKymaStateDeleting

Related issue(s)

@c-pius c-pius requested a review from a team as a code owner November 19, 2025 10:26
@c-pius c-pius linked an issue Nov 20, 2025 that may be closed by this pull request
3 tasks
@lindnerby lindnerby self-requested a review November 21, 2025 08:34
@lindnerby lindnerby self-assigned this Nov 21, 2025
return false, err
}

status, err := u.kymaStatusRepo.Get(ctx, kyma.GetNamespacedName())
Copy link
Member

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?

Copy link
Contributor Author

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
}

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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) {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.
Copy link
Member

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. ☝️

Copy link
Contributor Author

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 👍🏻

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.

Implement a dedicated service for handling Kyma deprovisioning

2 participants