Skip to content

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

Merged
kevin85421 merged 2 commits into
kuberay-project:masterfrom
astefanutti:pr-06
Nov 22, 2023
Merged

kevin85421 merged 2 commits into
kuberay-project:masterfrom
astefanutti:pr-06

Conversation

@astefanutti

@astefanutti astefanutti commented Nov 15, 2023 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

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

@kevin85421

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor Author

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

@blublinsky blublinsky left a comment

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.

Looks great

@kevin85421 kevin85421 left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread ray-operator/Makefile
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
# 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
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

},
Spec: rayv1.RayClusterSpec{
HeadGroupSpec: rayv1.HeadGroupSpec{
EnableIngress: pointer.BoolPtr(true),

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)

RunSpecsWithDefaultAndCustomReporters(t,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Comment thread ray-operator/main.go
return cache.MultiNamespacedCacheBuilder(watchNamespaces)(config, opts)
}
setupLog.Info(fmt.Sprintf("Only watch custom resources in multiple namespaces: %v", watchNamespaces))
for _, namespace := range watchNamespaces {

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

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.

Comment thread ray-operator/main.go
}
options.NewCache = cache.BuilderWithOptions(cache.Options{SelectorsByObject: selectorsByObject})
} else {
options.NewCache = func(config *rest.Config, opts cache.Options) (cache.Cache, error) {

Copy link
Copy Markdown
Collaborator

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.

Comment thread ray-operator/main.go

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

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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
Copy Markdown
Collaborator

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!

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
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@kevin85421

Copy link
Copy Markdown
Collaborator

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

@astefanutti

Copy link
Copy Markdown
Contributor Author

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

@kevin85421 rebased, PTAL.

@kevin85421
kevin85421 merged commit e3bdc83 into kuberay-project:master Nov 22, 2023
@astefanutti
astefanutti deleted the pr-06 branch November 22, 2023 16:19
@kevin85421 kevin85421 mentioned this pull request Nov 28, 2023
1 of 2 tasks
@astefanutti astefanutti mentioned this pull request Dec 7, 2023
2 of 4 tasks
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