@@ -34,6 +34,11 @@ import (
3434// necessary data to the screen).
3535var ErrNothingElseToAdd = fmt .Errorf ("" )
3636
37+ // ErrPreflightsHaveFail is an error returned when we managed to execute the
38+ // host preflights but they contain failures. We use this to differentiate the
39+ // way we provide user feedback.
40+ var ErrPreflightsHaveFail = fmt .Errorf ("host preflight failures detected" )
41+
3742// installAndEnableLocalArtifactMirror installs and enables the local artifact mirror. This
3843// service is responsible for serving on localhost, through http, all files that are used
3944// during a cluster upgrade.
@@ -122,16 +127,18 @@ func configureNetworkManager(c *cli.Context) error {
122127// RunHostPreflights runs the host preflights we found embedded in the binary
123128// on all configured hosts. We attempt to read HostPreflights from all the
124129// embedded Helm Charts and from the Kots Application Release files.
125- func RunHostPreflights (c * cli.Context , applier * addons.Applier , replicatedAPIURL , proxyRegistryURL string , isAirgap bool , proxy * ecv1beta1.ProxySpec ) error {
130+ func RunHostPreflights (c * cli.Context , applier * addons.Applier , replicatedAPIURL , proxyRegistryURL string , isAirgap bool , proxy * ecv1beta1.ProxySpec , adminConsolePort int , localArtifactMirrorPort int ) error {
126131 hpf , err := applier .HostPreflights ()
127132 if err != nil {
128133 return fmt .Errorf ("unable to read host preflights: %w" , err )
129134 }
130135
131136 data := preflights.TemplateData {
132- ReplicatedAPIURL : replicatedAPIURL ,
133- ProxyRegistryURL : proxyRegistryURL ,
134- IsAirgap : isAirgap ,
137+ ReplicatedAPIURL : replicatedAPIURL ,
138+ ProxyRegistryURL : proxyRegistryURL ,
139+ IsAirgap : isAirgap ,
140+ AdminConsolePort : adminConsolePort ,
141+ LocalArtifactMirrorPort : localArtifactMirrorPort ,
135142 }
136143 chpfs , err := preflights .GetClusterHostPreflights (c .Context , data )
137144 if err != nil {
@@ -190,7 +197,7 @@ func runHostPreflights(c *cli.Context, hpf *v1beta2.HostPreflightSpec, proxy *ec
190197
191198 pb .CloseWithError ()
192199 output .PrintTableWithoutInfo ()
193- return fmt . Errorf ( "host preflight failures detected" )
200+ return ErrPreflightsHaveFail
194201 }
195202
196203 // Warnings found
@@ -697,10 +704,25 @@ var installCommand = &cli.Command{
697704 replicatedAPIURL = license .Spec .Endpoint
698705 proxyRegistryURL = fmt .Sprintf ("https://%s" , defaults .ProxyRegistryAddress )
699706 }
700- if err := RunHostPreflights (c , applier , replicatedAPIURL , proxyRegistryURL , isAirgap , proxy ); err != nil {
707+
708+ adminConsolePort , err := getAdminConsolePortFromFlag (c )
709+ if err != nil {
710+ return fmt .Errorf ("unable to parse admin console port: %w" , err )
711+ }
712+
713+ localArtifactMirrorPort , err := getLocalArtifactMirrorPortFromFlag (c )
714+ if err != nil {
715+ return fmt .Errorf ("unable to parse local artifact mirror port: %w" , err )
716+ }
717+
718+ if err := RunHostPreflights (c , applier , replicatedAPIURL , proxyRegistryURL , isAirgap , proxy , adminConsolePort , localArtifactMirrorPort ); err != nil {
701719 metrics .ReportApplyFinished (c , err )
720+ if err == ErrPreflightsHaveFail {
721+ return ErrNothingElseToAdd
722+ }
702723 return err
703724 }
725+
704726 cfg , err := installAndWaitForK0s (c , applier , proxy )
705727 if err != nil {
706728 return err
0 commit comments