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

Use default VS and TS templates when CfgMap obj is deleted #6780

Merged
merged 9 commits into from
Nov 13, 2024
4 changes: 4 additions & 0 deletions internal/configs/configmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,14 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has

if virtualServerTemplate, exists := cfgm.Data["virtualserver-template"]; exists {
cfgParams.VirtualServerTemplate = &virtualServerTemplate
} else {
cfgParams.VirtualServerTemplate = nil
}

if transportServerTemplate, exists := cfgm.Data["transportserver-template"]; exists {
cfgParams.TransportServerTemplate = &transportServerTemplate
} else {
cfgParams.TransportServerTemplate = nil
}

if mainStreamSnippets, exists := GetMapKeyAsStringSlice(cfgm.Data, "stream-snippets", cfgm, "\n"); exists {
Expand Down
11 changes: 10 additions & 1 deletion internal/configs/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ func (cnf *Configurator) UpdateConfig(cfgParams *ConfigParams, resources Extende
return allWarnings, fmt.Errorf("error when parsing the main template: %w", err)
}
} else {
// Reverse to default main template parsed at NIC startup.
// Reverse to default Main template parsed at NIC startup.
cnf.templateExecutor.UseOriginalMainTemplate()
}

Expand All @@ -1327,20 +1327,29 @@ func (cnf *Configurator) UpdateConfig(cfgParams *ConfigParams, resources Extende
if err != nil {
return allWarnings, fmt.Errorf("error when parsing the ingress template: %w", err)
}
} else {
// Reverse to default Ingress template parsed at NIC startup.
cnf.templateExecutor.UseOriginalIngressTemplate()
}

if cfgParams.VirtualServerTemplate != nil {
err := cnf.templateExecutorV2.UpdateVirtualServerTemplate(cfgParams.VirtualServerTemplate)
if err != nil {
return allWarnings, fmt.Errorf("error when parsing the VirtualServer template: %w", err)
}
} else {
// Reverse to default TransportServer template parsed at NIC startup.
cnf.templateExecutorV2.UseOriginalVStemplate()
}

if cfgParams.TransportServerTemplate != nil {
err := cnf.templateExecutorV2.UpdateTransportServerTemplate(cfgParams.TransportServerTemplate)
if err != nil {
return allWarnings, fmt.Errorf("error when parsing the TransportServer template: %w", err)
}
} else {
// Reverse to default TransportServer template parsed at NIC startup.
cnf.templateExecutorV2.UseOriginalTStemplate()
}

mainCfg := GenerateNginxMainConfig(cnf.staticCfgParams, cfgParams)
Expand Down
Loading