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

chore: fix errors in expose action #8953

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/operations/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (e ExposeOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Clien
if len(expose.ComponentName) > 0 {
clusterCompSpec, ok := compMap[expose.ComponentName]
if !ok {
return fmt.Errorf("component spec not found: %s", expose.ComponentName)
return intctrlutil.NewFatalError(fmt.Sprintf("component spec not found: %s", expose.ComponentName))
}
// shardName or compName
clusterCompSpecName = expose.ComponentName
Expand All @@ -88,7 +88,7 @@ func (e ExposeOpsHandler) Action(reqCtx intctrlutil.RequestCtx, cli client.Clien
return err
}
default:
return fmt.Errorf("invalid expose switch: %s", expose.Switch)
return intctrlutil.NewFatalError(fmt.Sprintf("invalid expose switch: %s", expose.Switch))
}
}
reqCtx.Log.Info("cluster service to be updated", "clusterService", opsRes.Cluster.Spec.Services)
Expand Down Expand Up @@ -296,7 +296,7 @@ func (e ExposeOpsHandler) buildClusterServices(reqCtx intctrlutil.RequestCtx,

convertDefaultCompDefServicePorts := func(compServices []appsv1.ComponentService) ([]corev1.ServicePort, error) {
if len(compServices) == 0 {
return nil, fmt.Errorf("component service is not defined, expose operation is not supported, cluster: %s, component: %s", cluster.Name, clusterCompSpecName)
return nil, intctrlutil.NewFatalError(fmt.Sprintf("component service is not defined, expose operation is not supported, cluster: %s, component: %s", cluster.Name, clusterCompSpecName))
}
defaultServicePorts := make([]corev1.ServicePort, 0, len(compServices))
portsSet := make(map[string]bool) // to avoid duplicate ports
Expand All @@ -322,7 +322,7 @@ func (e ExposeOpsHandler) buildClusterServices(reqCtx intctrlutil.RequestCtx,
}
}
if len(defaultServicePorts) == 0 {
return nil, fmt.Errorf("component does not define an available service, expose operation is not supported, cluster: %s, component: %s", cluster.Name, clusterCompSpecName)
return nil, intctrlutil.NewFatalError(fmt.Sprintf("component does not define an available service, expose operation is not supported, cluster: %s, component: %s", cluster.Name, clusterCompSpecName))
}
return defaultServicePorts, nil
}
Expand All @@ -335,7 +335,7 @@ func (e ExposeOpsHandler) buildClusterServices(reqCtx intctrlutil.RequestCtx,
}
return convertDefaultCompDefServicePorts(compDef.Spec.Services)
}
return nil, fmt.Errorf("component definition is not defined, cluster: %s, component: %s", cluster.Name, clusterCompSpecName)
return nil, intctrlutil.NewFatalError(fmt.Sprintf("component definition is not defined, cluster: %s, component: %s", cluster.Name, clusterCompSpecName))
}

checkComponentHasRoles := func() (bool, error) {
Expand Down Expand Up @@ -404,7 +404,7 @@ func (e ExposeOpsHandler) buildClusterServices(reqCtx intctrlutil.RequestCtx,
return err
}
if hasRoles && exposeService.PodSelector == nil {
return fmt.Errorf("component has roles, at least one of 'roleSelector' or 'podSelector' must be specified, cluster: %s, component: %s", cluster.Name, clusterCompSpecName)
return intctrlutil.NewFatalError(fmt.Sprintf("component has roles, at least one of 'roleSelector' or 'podSelector' must be specified, cluster: %s, component: %s", cluster.Name, clusterCompSpecName))
}
}
cluster.Spec.Services = append(cluster.Spec.Services, clusterService)
Expand Down
Loading