Repository navigation
Conversation
When deploying onto a cluster that already had a stored manifest secret, assembleConfigForCommand used that manifest directly as the base config, bypassing deployer.DefaultConfig(). Manifests written by an older roxie (predating the imageRegistry field) left roxie.imageRegistry empty, which UsesCustomRegistry() treats as a custom registry, causing deploy to fail validation with "roxie.imageRegistry must include a registry host and org path (e.g. quay.io/rhacs-eng), got:". Always start from the built-in defaults and merge the manifest (and user config, then args) on top, so defaults are preserved when the manifest omits them. Non-empty manifest values still take precedence. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks for this PR! I've given my approval but would recommend also waiting for at least one of @porridge or @mclasmeier to take a look as well. |
vladbologa
left a comment
There was a problem hiding this comment.
Thanks for finding and fixing this!
| if configBase != nil { | ||
| // Merge the provided base (e.g. an existing cluster manifest) on top of | ||
| // the defaults; non-empty values in the base take precedence. | ||
| if err := mergo.Merge(&config, configBase, mergo.WithOverride, mergo.WithoutDereference); err != nil { |
There was a problem hiding this comment.
This seems ok for now, but could create problems in the future if we add e.g. an int field.
If the default value of that field is 1, and the user tries to set it to 0, it won't be posible.
An alternative would be to keep the direct copy and just add the missing field:
if config.Roxie.ImageRegistry == "" {
config.Roxie.ImageRegistry = constants.DefaultRegistry
}
But then every new field with a non-zero default needs such a fix. Not sure which one's better. Your approach would always work fine if all config fields were pointers.
There was a problem hiding this comment.
would always work fine if all config fields were pointers
@kovayur can you please file a Jira ticket and put it in TODO here?
| // Isolate the user config lookup so it cannot pick up a real file on disk. | ||
| tmpDir := t.TempDir() | ||
| t.Setenv("XDG_CONFIG_HOME", tmpDir) | ||
| t.Setenv("HOME", tmpDir) // For non-Unix systems. |
There was a problem hiding this comment.
Extract a helper function and reuse it below? (See setupMockAuthEnvironment in internal/dockerauth/dockerauth_test.go).
| if configBase != nil { | ||
| // Merge the provided base (e.g. an existing cluster manifest) on top of | ||
| // the defaults; non-empty values in the base take precedence. | ||
| if err := mergo.Merge(&config, configBase, mergo.WithOverride, mergo.WithoutDereference); err != nil { |
There was a problem hiding this comment.
would always work fine if all config fields were pointers
@kovayur can you please file a Jira ticket and put it in TODO here?
Problem
roxie deploy centralfails against a cluster that already has a stored manifest secret:Root cause
assembleConfigForCommandused an existing cluster manifest directly as the base config (config = *configBase), bypassingdeployer.DefaultConfig(). Manifests written by an older roxie (before theimageRegistryfield from ROX-35434) have an emptyroxie.imageRegistry. SinceUsesCustomRegistry()returnsImageRegistry != DefaultRegistry, an empty string is treated as a custom registry, sovalidateImageRegistry("")runs and fails with the emptygot:.Fix
Always start from
deployer.DefaultConfig()and merge the cluster manifest (then user config, then args) on top of it. This preserves built-in defaults when the manifest omits them, while non-empty manifest values still take precedence — matching the existingconfigBase == nillayering.Testing
TestAssembleConfigForCommand(fails before the fix, passes after).go build ./...,go test ./...,go vet, andgofmtall clean.🤖 Generated with Claude Code
Summary by CodeRabbit