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

🌱 Add more ctrl options flags #1725

Merged
merged 1 commit into from
May 16, 2024
Merged

Conversation

honza
Copy link
Member

@honza honza commented May 10, 2024

We add a few command-line flags to the baremetal-operator binary to configure more ctrl.Options{}.

@metal3-io-bot metal3-io-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 10, 2024
@honza honza changed the title Add more ctrl options flags 🌱 Add more ctrl options flags May 10, 2024
@tuminoid
Copy link
Member

/test metal3-bmo-e2e-test-pull

@tuminoid
Copy link
Member

/retest

Copy link
Member

@zaneb zaneb left a comment

Choose a reason for hiding this comment

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

/approve

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated
Cache: cache.Options{
ByObject: secretutils.AddSecretSelector(nil),
DefaultNamespaces: watchNamespaces,
},
}

if leaseDuration != "" {
dur, err := time.ParseDuration(leaseDuration)
Copy link
Member

Choose a reason for hiding this comment

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

Looking at the defaults, it's tempting to skip the parsing and make the command line argument -lease-duration-seconds. Nobody is going to want a duration in years or even hours. It could be a float if they really want to get down to the milliseconds.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we have leaseDurationSeconds, it'll create weird temporaries like:

leaseDurationSecondsDuration := time.Duration(leaseDurationSeconds) * time.Second
ctrlOptions.LeaseDuration = &leaseDurationSecondsDuration

But more annoyingly, we'll have to parse the env vars to ints. So this tidy line:

flag.StringVar(&renewDeadline, "renew-deadline", os.Getenv("RENEW_DEADLINE"), "Golang duration, e.g. '26s'")

would become something more involved because os.Getenv returns a string but the default must be a number.

Copy link
Member

Choose a reason for hiding this comment

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

it'll create weird temporaries

TBH I would take that one extra line of code over complicated user documentation.

we'll have to parse the env vars to ints

flag.IntVar() is only a convenience. If you wanted to keep it as StringVar and continue to do the parsing to int/float here yourself I don't think there's anything stopping you.

Copy link
Member Author

Choose a reason for hiding this comment

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

I switched it to using seconds, left it as a StringVar and added strconv.ParseInt.

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zaneb

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 13, 2024
@zaneb
Copy link
Member

zaneb commented May 14, 2024

@honza did you forget to push your local changes?

@honza
Copy link
Member Author

honza commented May 15, 2024

did you forget to push your local changes?

Nope. But I did push them to the wrong branch... 😞

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
We add a few command-line flags to the baremetal-operator binary to
configure more ctrl.Options{}.

Signed-off-by: Honza Pokorny <honza@redhat.com>
@dtantsur
Copy link
Member

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label May 16, 2024
@dtantsur
Copy link
Member

/test metal3-bmo-e2e-test-pull

@metal3-io-bot metal3-io-bot merged commit e300eed into metal3-io:main May 16, 2024
16 checks passed
@tuminoid tuminoid removed their request for review May 16, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants