-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCPBUGS-44882: Add NTP sources to generated install-config.yaml
In OpenShift 4.18 a new `additionalNTPServers` field was added to the baremetal platform section of the `install-config.yaml` file . This needs to be populated with the NTP sources provided by the user in order to correctly set time before installation of new nodes using the baremetal provisioning flow. Related: https://issues.redhat.com/browse/OCPBUGS-44882 Signed-off-by: Juan Hernandez <[email protected]>
- Loading branch information
Showing
15 changed files
with
217 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
package baremetal | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"github.com/openshift/assisted-service/internal/common" | ||
"github.com/openshift/assisted-service/internal/installcfg" | ||
"github.com/openshift/assisted-service/internal/provider" | ||
"github.com/openshift/assisted-service/models" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
var _ = Describe("Add NTP sources", func() { | ||
var ( | ||
logger logrus.FieldLogger | ||
cluster *common.Cluster | ||
infraEnvs []*common.InfraEnv | ||
cfg *installcfg.InstallerConfigBaremetal | ||
provider provider.Provider | ||
) | ||
|
||
BeforeEach(func() { | ||
logger = common.GetTestLog() | ||
cluster = &common.Cluster{ | ||
Cluster: models.Cluster{ | ||
OpenshiftVersion: "4.18", | ||
}, | ||
} | ||
infraEnvs = []*common.InfraEnv{{ | ||
InfraEnv: models.InfraEnv{}, | ||
}} | ||
cfg = &installcfg.InstallerConfigBaremetal{ | ||
ControlPlane: struct { | ||
Hyperthreading string "json:\"hyperthreading,omitempty\"" | ||
Name string "json:\"name\"" | ||
Replicas int "json:\"replicas\"" | ||
}{ | ||
Replicas: 1, | ||
}, | ||
Compute: []struct { | ||
Hyperthreading string "json:\"hyperthreading,omitempty\"" | ||
Name string "json:\"name\"" | ||
Replicas int "json:\"replicas\"" | ||
}{{ | ||
Replicas: 1, | ||
}}, | ||
} | ||
provider = NewBaremetalProvider(logger) | ||
}) | ||
|
||
It("Does nothing if there are no NTP sources", func() { | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(BeEmpty()) | ||
}) | ||
|
||
It("Adds one NTP source from cluster", func() { | ||
cluster.AdditionalNtpSource = "1.1.1.1" | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1")) | ||
}) | ||
|
||
It("Adds multiple NTP sources from cluster", func() { | ||
cluster.AdditionalNtpSource = "1.1.1.1,2.2.2.2,3.3.3.3" | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1", "2.2.2.2", "3.3.3.3")) | ||
}) | ||
|
||
It("Removes extra white space in NTP sources from cluster", func() { | ||
cluster.AdditionalNtpSource = " 1.1.1.1, \t 2.2.2.2 , 3.3.3.3 " | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1", "2.2.2.2", "3.3.3.3")) | ||
}) | ||
|
||
It("Adds one source from one infrastructure environment", func() { | ||
infraEnvs[0].AdditionalNtpSources = "1.1.1.1" | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1")) | ||
}) | ||
|
||
It("Adds multiple sources from one infrastructure environment", func() { | ||
infraEnvs[0].AdditionalNtpSources = "1.1.1.1,2.2.2.2,3.3.3.3" | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1", "2.2.2.2", "3.3.3.3")) | ||
}) | ||
|
||
It("Removes extra white space in NTP sources from infrastructure environment", func() { | ||
infraEnvs[0].AdditionalNtpSources = " 1.1.1.1, \t 2.2.2.2 , 3.3.3.3 " | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1", "2.2.2.2", "3.3.3.3")) | ||
}) | ||
|
||
It("Ignores sources from infrastructure environment if there are NTP sources in the cluster", func() { | ||
cluster.AdditionalNtpSource = "1.1.1.1" | ||
infraEnvs[0].AdditionalNtpSources = "2.2.2.2" | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1")) | ||
}) | ||
|
||
It("Combines NTP sources from multiple infrastructure environments", func() { | ||
infraEnvs := []*common.InfraEnv{ | ||
{ | ||
InfraEnv: models.InfraEnv{ | ||
AdditionalNtpSources: "1.1.1.1", | ||
}, | ||
}, | ||
{ | ||
InfraEnv: models.InfraEnv{ | ||
AdditionalNtpSources: "2.2.2.2", | ||
}, | ||
}, | ||
{ | ||
InfraEnv: models.InfraEnv{ | ||
AdditionalNtpSources: "3.3.3.3", | ||
}, | ||
}, | ||
} | ||
err := provider.AddPlatformToInstallConfig(cfg, cluster, infraEnvs) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(cfg.Platform.Baremetal.AdditionalNTPServers).To(ConsistOf("1.1.1.1", "2.2.2.2", "3.3.3.3")) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package baremetal | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestBaremetalProvider(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Baremetal provider") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.