Skip to content

Add more warning for service name replacement #541

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

Merged
merged 3 commits into from
Jul 12, 2024

Conversation

edwardrf
Copy link
Contributor

The following questions has been repeatedly pop up when a service name replacement is needed, which prevents a successful deployment:

  1. The service name need to be replaced has a port not in "host" mode, meaning it has either port->mode:ingress, or missing port config, we do not warn them if this service name is used in other service that depends on it in any of its environment variables.
  2. An environment variable could be replaced by a config, though we do have an warning, but it is not clear that we do not do service name replacement in the configured values

@edwardrf edwardrf requested a review from lionello July 11, 2024 20:19
! service "bad-service": missing compose directive: restart; assuming 'unless-stopped' (add 'restart' to silence)
! service "bad-service": missing memory reservation; specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "env-in-config": environment variable "CONFIG1" overridden by config
! service "env-in-config": environment variable "CONFIG1" with value "http://Mistral:8000" contains a service name needs to be normalized, but it will be repalced by an existing config. service names in a config will not be normalized.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Warning about overridden env var contains a service name replacement

! service "ui": service names were replaced in environment variable "API_URL": "http://mock-mistral:8000"
! service "use-bad-service": missing compose directive: restart; assuming 'unless-stopped' (add 'restart' to silence)
! service "use-bad-service": missing memory reservation; specify deploy.resources.reservations.memory to avoid out-of-memory errors
! service "use-bad-service": service names were NOT replaced in environment variable "DB_URL": "bad-service:5432", only service with port mode host will be replaced
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Warning about service name NOT being replaced.

@lionello
Copy link
Member

I rather we fix #396

@edwardrf edwardrf requested review from lionello and removed request for lionello July 12, 2024 17:26
@@ -130,7 +137,11 @@ func ConvertServices(ctx context.Context, c client.Client, serviceConfigs compos

// Check if the environment variable is an existing config; if so, mark it as such
if _, ok := slices.BinarySearch(config.Names, key); ok {
term.Warnf("service %q: environment variable %q overridden by config", svccfg.Name, key)
if serviceNameRegex != nil && serviceNameRegex.MatchString(*value) {
term.Warnf("service %q: The environment variable %q, with the value %q, contains a service name that needs to be normalized. however, it will be replaced by an existing configuration. service names within a configuration will not be normalized.", svccfg.Name, key, *value)
Copy link
Member

Choose a reason for hiding this comment

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

capitalization

Copy link
Member

Choose a reason for hiding this comment

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

fmt.Printf("service %q: environment variable %q needs service name fix-up, but is overridden by config, which will not be fixed up.", svccfg.Name, key)

@@ -130,7 +137,11 @@ func ConvertServices(ctx context.Context, c client.Client, serviceConfigs compos

// Check if the environment variable is an existing config; if so, mark it as such
if _, ok := slices.BinarySearch(config.Names, key); ok {
term.Warnf("service %q: environment variable %q overridden by config", svccfg.Name, key)
if serviceNameRegex != nil && serviceNameRegex.MatchString(*value) {
term.Warnf("service %q: The environment variable %q, with the value %q, contains a service name that needs to be normalized. however, it will be replaced by an existing configuration. service names within a configuration will not be normalized.", svccfg.Name, key, *value)
Copy link
Member

Choose a reason for hiding this comment

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

fmt.Printf("service %q: environment variable %q needs service name fix-up, but is overridden by config, which will not be fixed up.", svccfg.Name, key)

@@ -143,6 +154,8 @@ func ConvertServices(ctx context.Context, c client.Client, serviceConfigs compos
})
if val != *value {
term.Warnf("service %q: service names were replaced in environment variable %q: %q", svccfg.Name, key, val)
} else if nonReplaceServiceNameRegex != nil && nonReplaceServiceNameRegex.MatchString(*value) {
term.Warnf("service %q: service names in the environment variable %q (%q) were not replaced. only services with port mode set to host will be replaced.", svccfg.Name, key, val)
Copy link
Member

Choose a reason for hiding this comment

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

use "fix up"

@@ -143,6 +154,8 @@ func ConvertServices(ctx context.Context, c client.Client, serviceConfigs compos
})
if val != *value {
term.Warnf("service %q: service names were replaced in environment variable %q: %q", svccfg.Name, key, val)
Copy link
Member

Choose a reason for hiding this comment

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

"service names were fixed up"

@edwardrf edwardrf requested a review from lionello July 12, 2024 21:12
@edwardrf edwardrf force-pushed the edw-add-validation-warning branch from 4e64473 to 45a7467 Compare July 12, 2024 21:41
@lionello lionello merged commit 783c05b into main Jul 12, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants