@@ -481,8 +481,9 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
481481 SSHRunner : sshRunner ,
482482 IP : instanceIP ,
483483 // TODO: should be more finegrained
484- BundleMetadata : * vm .bundle ,
485- NetworkMode : client .networkMode (),
484+ BundleMetadata : * vm .bundle ,
485+ NetworkMode : client .networkMode (),
486+ ModifyHostsFile : client .modifyHostsFile (),
486487 }
487488
488489 // Run the DNS server inside the VM
@@ -506,7 +507,11 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
506507 logging .Info ("Check DNS query from host..." )
507508 if err := dns .CheckCRCLocalDNSReachableFromHost (servicePostStartConfig ); err != nil {
508509 if ! client .useVSock () {
509- return nil , errors .Wrap (err , "Failed to query DNS from host" )
510+ msg := "Failed to query DNS from host"
511+ if ! servicePostStartConfig .ModifyHostsFile {
512+ msg += " (modify-hosts-file=false). Ensure your system DNS/hosts entries resolve the CRC domains."
513+ }
514+ return nil , errors .Wrap (err , msg )
510515 }
511516 logging .Warn (fmt .Sprintf ("Failed to query DNS from host: %v" , err ))
512517 }
@@ -694,7 +699,7 @@ func createHost(machineConfig config.MachineConfig, preset crcPreset.Preset) err
694699 if err := cluster .GenerateUserPassword (constants .GetKubeAdminPasswordPath (), "kubeadmin" ); err != nil {
695700 return errors .Wrap (err , "Error generating new kubeadmin password" )
696701 }
697- if err = os .WriteFile (constants .GetDeveloperPasswordPath (), []byte (constants .DefaultDeveloperPassword ), 0600 ); err != nil {
702+ if err = os .WriteFile (constants .GetDeveloperPasswordPath (), []byte (constants .DefaultDeveloperPassword ), 0o600 ); err != nil {
698703 return errors .Wrap (err , "Error writing developer password" )
699704 }
700705 }
@@ -748,7 +753,7 @@ func enableEmergencyLogin(sshRunner *crcssh.Runner) error {
748753 for i := range b {
749754 b [i ] = charset [rand .Intn (len (charset ))] //nolint
750755 }
751- if err := os .WriteFile (constants .PasswdFilePath , b , 0600 ); err != nil {
756+ if err := os .WriteFile (constants .PasswdFilePath , b , 0o600 ); err != nil {
752757 return err
753758 }
754759 logging .Infof ("Emergency login password for core user is stored to %s" , constants .PasswdFilePath )
@@ -775,7 +780,7 @@ func updateSSHKeyPair(sshRunner *crcssh.Runner) error {
775780 }
776781
777782 logging .Info ("Updating authorized keys..." )
778- err = sshRunner .CopyData (publicKey , "/home/core/.ssh/authorized_keys" , 0644 )
783+ err = sshRunner .CopyData (publicKey , "/home/core/.ssh/authorized_keys" , 0o644 )
779784 if err != nil {
780785 return err
781786 }
@@ -874,10 +879,10 @@ func startMicroshift(ctx context.Context, sshRunner *crcssh.Runner, ocConfig oc.
874879 if _ , _ , err := sshRunner .RunPrivileged ("Starting microshift service" , "systemctl" , "start" , "microshift" ); err != nil {
875880 return err
876881 }
877- if err := sshRunner .CopyFileFromVM (fmt .Sprintf ("/var/lib/microshift/resources/kubeadmin/api%s/kubeconfig" , constants .ClusterDomain ), constants .KubeconfigFilePath , 0600 ); err != nil {
882+ if err := sshRunner .CopyFileFromVM (fmt .Sprintf ("/var/lib/microshift/resources/kubeadmin/api%s/kubeconfig" , constants .ClusterDomain ), constants .KubeconfigFilePath , 0o600 ); err != nil {
878883 return err
879884 }
880- if err := sshRunner .CopyFile (constants .KubeconfigFilePath , "/opt/kubeconfig" , 0644 ); err != nil {
885+ if err := sshRunner .CopyFile (constants .KubeconfigFilePath , "/opt/kubeconfig" , 0o644 ); err != nil {
881886 return err
882887 }
883888
@@ -895,5 +900,5 @@ func ensurePullSecretPresentInVM(sshRunner *crcssh.Runner, pullSec cluster.PullS
895900 if err != nil {
896901 return err
897902 }
898- return sshRunner .CopyDataPrivileged ([]byte (content ), "/etc/crio/openshift-pull-secret" , 0600 )
903+ return sshRunner .CopyDataPrivileged ([]byte (content ), "/etc/crio/openshift-pull-secret" , 0o600 )
899904}
0 commit comments