-
Notifications
You must be signed in to change notification settings - Fork 349
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
Cronjob migration #1856
Cronjob migration #1856
Conversation
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #1856 +/- ##
==========================================
- Coverage 89.44% 87.96% -1.48%
==========================================
Files 100 100
Lines 6128 6274 +146
==========================================
+ Hits 5481 5519 +38
- Misses 471 558 +87
- Partials 176 197 +21
Continue to review full report at Codecov.
|
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
…ator into cronjob-migration
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
Signed-off-by: Kevin Earls <[email protected]>
@rubenvp8510 @pavolloffay Please review. I realize this reduces code coverage slightly, but updating the tests to cover both batch/v1 and batch/v1beta1 would reuire lots of cut and paste or code changes that would be difficult to back out when we no longer need to support batch/v1beta1 |
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 good, i just have some formal questions :)
for _, apiGroupVersion := range apiGroupVersions { | ||
groupAPIList, err := b.dcl.ServerResourcesForGroupVersion(apiGroupVersion) | ||
if err != nil { | ||
log.Errorf("Error getting %s api list: %v", apiGroupVersion, err) |
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.
Is there a way to get a logger form context?
iam asking because of this #1817
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.
Sorry, there might be, but I don't know how to do that.
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 think its something like
import "sigs.k8s.io/controller-runtime/pkg/log"
...
logger := log.FromContext(ctx)
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.
Sure. Can we do that as part of #1817 though?
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.
ok 👍
pkg/cronjob/es_rollover.go
Outdated
Schedule: jaeger.Spec.Storage.EsRollover.Schedule, | ||
SuccessfulJobsHistoryLimit: jaeger.Spec.Storage.EsRollover.SuccessfulJobsHistoryLimit, | ||
JobTemplate: batchv1beta1.JobTemplateSpec{ | ||
Spec: batchv1.JobSpec{ |
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.
Does it need to be a batchv1beta1.JobSpec
here?
Another thing, i wonder if we could get rid of this huge if else thing. while scrolling up and down i noticed it a few times. From my point of view, its easy to make mistakes in case of adaption. On the other hand, if we want to support a 3rd version in future releases, it feels be hard to extend too.
if cronjobsVersion == v1.CronJobsVersionBatchV1Beta1 { .. } else { .. }
// replaced by
func newCronJob(cronJobVer, ObjectMeta, ...opts) (interface{}, error)
// or a structure that can be converted into both?
type ourCronJob struct {}
func (ourCronJob) convert(cronJobVer) (any, bool)
What do you think?
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.
Actually batchv1.JobSpec is available as in k8s 1.19 (See https://github.com/kubernetes/api/blob/release-1.19/batch/v1beta1/types.go#L53) I have extracted the JobSpec definition to make things a bit shorter.
I would love to get rid of the big if/else statements, and tried to do so as much as possible. However, I guess I tried to balance the amount of work vs. benefits. We're hopefully not going to be supporting two versions of the same API in one image for very long. Once 1.21 is the oldest API we have to support we can just rip all of this stuff out.
I'll take another look in the morning though and see if I can get anything working
return tracing.HandleError(err, span) | ||
} | ||
} | ||
} else { |
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.
same here
Signed-off-by: Kevin Earls <[email protected]>
apis/v1/jaeger_types.go
Outdated
@@ -17,6 +17,12 @@ type JaegerPhase string | |||
type JaegerStorageType string | |||
|
|||
const ( | |||
// CronJobsVersionBatchV1 represents the batch/v1 version of the kubernetes CronJob api, available as of 1.21 | |||
CronJobsVersionBatchV1 = "batch/v1" |
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.
These (and the one below) env vars do not belong here.
This file/package should contain types are used in the CRD.
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.
@pavolloffay where should I define these?
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.
Actually FlagPlatformOpenShift
is defined in this file as well so for consistency we can keep it here.
It the batch version is exposed as flag (similar to platform) then I would suggest aligning the name to Flag
as well.
Signed-off-by: Kevin Earls <[email protected]>
@rubenvp8510 @pavolloffay Please review |
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.
up to the others :)
@rubenvp8510 Thanks for the approval. Can you merge this? |
Signed-off-by: Kevin Earls [email protected]
Which problem is this PR solving?
Short description of the changes