diff --git a/pkg/tarmak/cluster/cluster.go b/pkg/tarmak/cluster/cluster.go index fccdd4e6f9..bbc3062d4e 100644 --- a/pkg/tarmak/cluster/cluster.go +++ b/pkg/tarmak/cluster/cluster.go @@ -731,9 +731,6 @@ func (c *Cluster) ConfigPath() string { } func (c *Cluster) SSHConfigPath() string { - if c.Type() == clusterv1alpha1.ClusterTypeClusterMulti { - return filepath.Join(c.Environment().Tarmak().ConfigPath(), c.Environment().HubName(), "ssh_config") - } return filepath.Join(c.ConfigPath(), "ssh_config") } diff --git a/pkg/tarmak/ssh/ssh.go b/pkg/tarmak/ssh/ssh.go index 85a4c87c4d..315578562a 100644 --- a/pkg/tarmak/ssh/ssh.go +++ b/pkg/tarmak/ssh/ssh.go @@ -70,15 +70,14 @@ func (s *SSH) WriteConfig(c interfaces.Cluster) error { return err } - knownHostsPath := s.tarmak.Cluster().SSHHostKeysPath() + knownHostsPath := c.SSHHostKeysPath() + // open file for appending knownHostsFile, err := os.OpenFile( - knownHostsPath, - os.O_APPEND|os.O_WRONLY|os.O_CREATE, - 0600, - ) + knownHostsPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, + 0600) if err != nil { - return err + return fmt.Errorf("failed to open known hosts file: %s", err) } defer knownHostsFile.Close() diff --git a/pkg/tarmak/tarmak.go b/pkg/tarmak/tarmak.go index 549ef15a2b..81de3dbd28 100644 --- a/pkg/tarmak/tarmak.go +++ b/pkg/tarmak/tarmak.go @@ -178,6 +178,7 @@ func (t *Tarmak) writeSSHConfigForClusterHosts() error { if errCluster != nil { return fmt.Errorf("failed to retrieve current cluster name: %s", errCluster) } + return fmt.Errorf("failed to write ssh config for current cluster '%s': %v", clusterName, err) }