-
Notifications
You must be signed in to change notification settings - Fork 382
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
Conversation
1054036
to
1c26641
Compare
@kevin85421 @architkulkarni @blublinsky @z103cb could you please review? |
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? Thanks! |
@kevin85421 I've updated the description with more details that I hope cover your questions. Let me know otherwise. |
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.
Looks great
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 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" |
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 familiar with these options. Why can we make this change?
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.
Update:
-
trivialVersions
: I can find some references oftrivialVersions
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!
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 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), |
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.
Int32Ptr is a function variable referring to Int32
@@ -22,7 +22,7 @@ var instanceWithRouteEnabled = &rayv1.RayCluster{ | |||
}, | |||
Spec: rayv1.RayClusterSpec{ | |||
HeadGroupSpec: rayv1.HeadGroupSpec{ | |||
EnableIngress: pointer.BoolPtr(true), |
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.
} | ||
|
||
var _ = BeforeSuite(func(done Done) { | ||
var _ = BeforeSuite(func(ctx SpecContext) { |
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.
Note: https://onsi.github.io/ginkgo/MIGRATING_TO_V2#removed-async-testing
Done
was removed by Ginkgo 2.0.
@@ -52,12 +51,10 @@ var ( | |||
func TestAPIs(t *testing.T) { | |||
RegisterFailHandler(Fail) | |||
|
|||
RunSpecsWithDefaultAndCustomReporters(t, |
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.
setupLog.Info(fmt.Sprintf("Only watch custom resources in multiple namespaces: %v", watchNamespaces)) | ||
for _, namespace := range watchNamespaces { |
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.
Why do we decide to use multiple Cache.DefaultNamespaces[namespace]
instead of a MultiNamespacedCacheBuilder
?
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.
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) { |
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.
// 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}, |
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.
A dumb question: Does it mean that the informer only caches batchv1.Job
?
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.
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.
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.
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]) |
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 catch!
IsController: true, | ||
OwnerType: &rayv1.RayCluster{}, | ||
}) | ||
return b.Owns(&v1beta1.PodGroup{}) |
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.
@astefanutti would you mind rebasing this PR to resolve the conflicts? Thanks! |
@kevin85421 rebased, PTAL. |
Why are these changes needed?
This PR upgrades the following dependencies:
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/**
andhelm-chart/**
update generated by the upgraded controller-gen toolray-operator/pkg/client/**
update generated by the upgraded code-generator toolThe 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