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

Fix controller config type coercion for time.Duration #15064

Merged
merged 3 commits into from
Jan 18, 2023

Conversation

hpidcock
Copy link
Member

@hpidcock hpidcock commented Jan 18, 2023

Juju 2.9.38 introduced type coercion on controller config before
going over the wire or going into state. This had unexpected impact
on two of the durations in controller config.

This fix improves all handling of durations, and coerces to only basic
types laid out controller.ConfigSchema.

Introduced by #15016

QA steps

  • bootstrap 2.9.38
  • these two commands should fail
  • juju controller-config agent-ratelimit-rate=255ms
  • juju controller-config max-debug-log-duration=23h
  • upgrade controller to this pr
  • juju controller-config agent-ratelimit-rate=255ms
  • juju controller-config max-debug-log-duration=23h
  • juju controller-config agent-ratelimit-rate should return 255ms
  • juju controller-config max-debug-log-duration=23h should return 23h or 23h0m0s

Documentation changes

N/A

Bug reference

https://bugs.launchpad.net/juju/+bug/2003149

Juju 2.9.38 introduced type coercion on controller config before
going over the wire or going into state. This had unexpected impact
on two of the durations in controller config.

This fix improves all handling of durations, and coerces to only basic
types laid out controller.ConfigSchema.
@hpidcock hpidcock added bug The PR addresses a bug 2.9 labels Jan 18, 2023
@@ -243,7 +248,15 @@ func (c *configCommand) setConfig(client controllerAPI, ctx *cmd.Context) error
values := make(map[string]interface{})
for k := range attrs {
if controller.AllowedUpdateConfigAttributes.Contains(k) {
values[k] = parsed[k]
if field, ok := fields[k]; ok {
Copy link
Member

Choose a reason for hiding this comment

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

Should we log/print a warning here like we do for model config if there's a controller attribute that is mistyped. I would even argue that we go a step further and make it an error. Is there any circumstance where a controller config attribute name is not defined in the schema?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is two schemas, only time this could happen is if it isn't in both.

Copy link
Member Author

Choose a reason for hiding this comment

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

also you can't edit a config key if it isn't in controller.AllowedUpdateConfigAttributes

Copy link
Member

@wallyworld wallyworld left a comment

Choose a reason for hiding this comment

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

As per inline comment, would like to understand the issue around invalid attribute names and lack of error.
Was there QA for upgrading from 2.9.37 or earlier with duration values set?

}

needsUpdate := false
for _, k := range []string{controller.AgentRateLimitRate, controller.MaxDebugLogDuration} {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why we don't need to include all the duration attributes here?

Copy link
Member Author

Choose a reason for hiding this comment

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

these are the only ones that were coerced to time.Duration

@hpidcock
Copy link
Member Author

/merge

@jujubot jujubot merged commit 6f978b2 into juju:2.9 Jan 18, 2023
@hpidcock hpidcock mentioned this pull request Jan 19, 2023
jujubot added a commit that referenced this pull request Jan 19, 2023
#15029

Merges:
- #15014
- #15016 
- #15024 
- #15064 
- #15063

Conflicts:
- caas/kubernetes/provider/metadata.go
- caas/kubernetes/provider/metadata_test.go
- cmd/juju/controller/config_test.go
- scripts/win-installer/setup.iss
- snap/snapcraft.yaml
- version/version.go

Conflicts:
- apiserver/admin_test.go
- caas/kubernetes/provider/metadata.go
- caas/kubernetes/provider/metadata_test.go
- cmd/juju/controller/config.go
- cmd/juju/controller/config_test.go
- cmd/juju/controller/listmodels_test.go
- provider/maas/maas_environ_whitebox_test.go
- scripts/win-installer/setup.iss
- snap/snapcraft.yaml
- state/controller.go
- state/upgrades.go
- state/upgrades_test.go
- upgrades/backend.go
- upgrades/operations.go
- upgrades/upgrade_test.go
- version/version.go
@hpidcock hpidcock mentioned this pull request Jan 19, 2023
jujubot added a commit that referenced this pull request Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.9 bug The PR addresses a bug
Projects
None yet
3 participants