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

Upgrade Kubernetes dependencies to v0.28.3 and Golang to 1.20 #1648

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

astefanutti
Copy link
Contributor

@astefanutti astefanutti commented Nov 15, 2023

Why are these changes needed?

This PR upgrades the following dependencies:

  • Kubernetes dependencies to v0.28.3
  • controller-runtime to v0.16.3
  • code-generator v0.28.3
  • controller-tools /controller-gen to v0.13.0
  • Ginkgo to v2.11.0

This also upgrades Go to v1.20 as it's required.

The files matching the following paths have been fully regenerated, and do not contain any manual changes:

  • ray-operator/config/** and helm-chart/** update generated by the upgraded controller-gen tool
  • ray-operator/pkg/client/** update generated by the upgraded code-generator tool

The majority of the manual changes are updates required because of some deprecated / removed APIs.

Note that these changes do not affect the client / server compatibility as they do not affect the requests made to the API server. So this PR should not affect the compatibility with Kubernetes versions, which remains bound to the APIs being used.

The Go upgrade is required by the newer version of controller-runtime, and generally the Kubernetes dependencies.

The operator unit tests had to be adapted with the behavioural changes to the controller-runtime client, which now take into account the status sub-resource.

Related issue number

Fixes #1337.

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@astefanutti astefanutti changed the title Upgrade Kubernetes APIs and controller-runtime versions Upgrade Kubernetes dependencies to v0.28.3 and Golang to 1.20 Nov 15, 2023
@astefanutti
Copy link
Contributor Author

@kevin85421 @architkulkarni @blublinsky @z103cb could you please review?

@kevin85421
Copy link
Member

This is great! I will review this PR next week. Would you mind explaining the following questions in the PR descriptions?

(1) Which file changes are fully generated? Which commands/components generate the changes?
(2) Why do you manually make some file changes? Are there any references to prove they are backward compatible?
(3) What is the compatibility between these upgrade dependencies with Kubernetes? Are they compatible with Kubernetes 1.19?

Thanks!

@astefanutti
Copy link
Contributor Author

@kevin85421 I've updated the description with more details that I hope cover your questions. Let me know otherwise.

Copy link
Contributor

@blublinsky blublinsky left a comment

Choose a reason for hiding this comment

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

Looks great

Copy link
Member

@kevin85421 kevin85421 left a comment

Choose a reason for hiding this comment

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

This is super amazing. I've never approved such a large PR during the first round of review. Thank you for your contribution! I've left some comments, most of which are notes for myself, and I also have a few questions.

# Golang forbids converting float from Json to struct. Need allowDangerousTypes=true to unblock build.
CRD_OPTIONS ?= "crd:maxDescLen=0,trivialVersions=true,preserveUnknownFields=false,generateEmbeddedObjectMeta=true,allowDangerousTypes=true"
CRD_OPTIONS ?= "crd:maxDescLen=0,generateEmbeddedObjectMeta=true,allowDangerousTypes=true"
Copy link
Member

Choose a reason for hiding this comment

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

Not familiar with these options. Why can we make this change?

Copy link
Member

Choose a reason for hiding this comment

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

Update:

  • trivialVersions: I can find some references of trivialVersions in controller-tools v0.6.0 codebase, but I cannot find any reference in v0.13.0 codebase. I believe that this field is deprecated.

  • preserveUnknownFields: I can still find some strings seem to be related to this field in v0.13.0.

@astefanutti would you mind explaining why do we remove preserveUnknownFields=false here? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The preserveUnknownFields option has been removed from the controller-gen CLI, in favor of the kubebuilder:pruning:PreserveUnknownFields marker, that can be used at the type and field level of the Golang API structs, to control pruning.

Pruning unknown fields is the default for CRDs declared in apiextensions.k8s.io/v1, which is equivalent to preserveUnknownFields=false, so there should be not changed.

Replicas: pointer.Int32Ptr(3),
MinReplicas: pointer.Int32Ptr(0),
MaxReplicas: pointer.Int32Ptr(10000),
Replicas: pointer.Int32(3),
Copy link
Member

Choose a reason for hiding this comment

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

@@ -22,7 +22,7 @@ var instanceWithRouteEnabled = &rayv1.RayCluster{
},
Spec: rayv1.RayClusterSpec{
HeadGroupSpec: rayv1.HeadGroupSpec{
EnableIngress: pointer.BoolPtr(true),
Copy link
Member

Choose a reason for hiding this comment

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

}

var _ = BeforeSuite(func(done Done) {
var _ = BeforeSuite(func(ctx SpecContext) {
Copy link
Member

Choose a reason for hiding this comment

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

@@ -52,12 +51,10 @@ var (
func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,
Copy link
Member

Choose a reason for hiding this comment

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

setupLog.Info(fmt.Sprintf("Only watch custom resources in multiple namespaces: %v", watchNamespaces))
for _, namespace := range watchNamespaces {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we decide to use multiple Cache.DefaultNamespaces[namespace] instead of a MultiNamespacedCacheBuilder?

Copy link
Member

Choose a reason for hiding this comment

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

Note: MultiNamespacedCacheBuilder seems to be removed between controller-runtime v0.15.3 and v0.16.0.

} else {
options.NewCache = func(config *rest.Config, opts cache.Options) (cache.Cache, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Note: https://sourcegraph.com/github.com/kubernetes-sigs/controller-runtime@2154ffbc22e26ffd8c3b713927f0df2fa40841f2/-/blob/pkg/manager/manager.go?L113-L120

// NewCache is the function that will create the cache to be used
// by the manager. If not set this will use the default new cache function.
//
// When using a custom NewCache, the Cache options will be passed to the
// NewCache function.
//
// NOTE: LOW LEVEL PRIMITIVE!
// Only use a custom NewCache if you know what you are doing.

label, err := labels.NewRequirement(common.KubernetesCreatedByLabelKey, selection.Equals, []string{common.ComponentName})
if err != nil {
return nil, err
}
selector := labels.NewSelector().Add(*label)

return cache.SelectorsByObject{
return map[client.Object]cache.ByObject{
&batchv1.Job{}: {Label: selector},
Copy link
Member

Choose a reason for hiding this comment

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

A dumb question: Does it mean that the informer only caches batchv1.Job?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no dumb question :)

Anything that's not specified here falls through the defaults. Excerpted from the ByObject documentation:

// The defaulting follows the following precedence order:
// 1. ByObject
// 2. DefaultNamespaces[namespace]
// 3. Default*

Some examples can be found at https://github.com/kubernetes-sigs/controller-runtime/blob/2154ffbc22e26ffd8c3b713927f0df2fa40841f2/designs/cache_options.md, as well as some details at kubernetes-sigs/controller-runtime#2421.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. This is very helpful!

@@ -936,7 +936,7 @@ func TestReconcile_PodEvicted_DiffLess0_OK(t *testing.T) {
// Simulate head pod get evicted.
podList.Items[0].Status.Phase = corev1.PodFailed
podList.Items[0].Status.Reason = "Evicted"
err = fakeClient.Update(ctx, &podList.Items[0])
err = fakeClient.Status().Update(ctx, &podList.Items[0])
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

IsController: true,
OwnerType: &rayv1.RayCluster{},
})
return b.Owns(&v1beta1.PodGroup{})
Copy link
Member

Choose a reason for hiding this comment

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

@kevin85421
Copy link
Member

@astefanutti would you mind rebasing this PR to resolve the conflicts? Thanks!

@astefanutti
Copy link
Contributor Author

@astefanutti would you mind rebasing this PR to resolve the conflicts? Thanks!

@kevin85421 rebased, PTAL.

@kevin85421 kevin85421 merged commit e3bdc83 into ray-project:master Nov 22, 2023
25 checks passed
@astefanutti astefanutti deleted the pr-06 branch November 22, 2023 16:19
astefanutti added a commit to opendatahub-io/kuberay that referenced this pull request Jan 5, 2024
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.

[Feature] Libraries versions
3 participants