Skip to content

Commit

Permalink
MGMT-15213: temporary disable release-domain-name-resolved-correctly …
Browse files Browse the repository at this point in the history
…validation (openshift#5351)

This validation doesn't cover proxy/mirror.
Should be enabled in MGMT-15212
  • Loading branch information
ori-amizur authored and CrystalChun committed Jul 12, 2023
1 parent ca56ed5 commit b0797da
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 150 deletions.
13 changes: 9 additions & 4 deletions internal/host/refresh_status_preprocessor.go
Expand Up @@ -264,10 +264,15 @@ func newValidations(v *validator) []validation {
id: IsAppsDomainNameResolvedCorrectly,
condition: v.isAppsDomainNameResolvedCorrectly,
},
{
id: IsReleaseDomainNameResolvedCorrectly,
condition: v.isReleaseDomainResolvedCorrectly,
},
/*
* MGMT-15213: The release domain is not resolved correctly when there is a mirror or proxy. In this case
* validation might fail, but the installation may succeed.
* TODO: MGMT-15213 - Fix the validation bug
{
id: IsReleaseDomainNameResolvedCorrectly,
condition: v.isReleaseDomainResolvedCorrectly,
},
*/
{
id: CompatibleWithClusterPlatform,
condition: v.compatibleWithClusterPlatform,
Expand Down
7 changes: 6 additions & 1 deletion internal/host/statemachine.go
Expand Up @@ -845,7 +845,12 @@ func NewHostStateMachine(sm stateswitch.StateMachine, th TransitionHandler) stat
If(NoSkipInstallationDisk),
If(NoSkipMissingDisk),
If(NoIPCollisionsInNetwork),
If(IsReleaseDomainNameResolvedCorrectly),
/*
* MGMT-15213: The release domain is not resolved correctly when there is a mirror or proxy. In this case
* validation might fail, but the installation may succeed.
* TODO: MGMT-15213 - Fix the validation bug
If(IsReleaseDomainNameResolvedCorrectly),
*/
)

sm.AddTransitionRule(stateswitch.TransitionRule{
Expand Down
83 changes: 44 additions & 39 deletions internal/host/transition_test.go
Expand Up @@ -4296,45 +4296,50 @@ var _ = Describe("Refresh Host", func() {
errorExpected: false,
userManagedNetworking: true,
},
{
name: "pending to known - release image resolved correctly",
validCheckInTime: true,
srcState: models.HostStatusPendingForInput,
dstState: models.HostStatusKnown,
machineNetworks: common.TestIPv4Networking.MachineNetworks,
ntpSources: defaultNTPSources,
imageStatuses: map[string]*models.ContainerImageAvailability{common.TestDefaultConfig.ImageName: common.TestImageStatusesSuccess},
role: models.HostRoleWorker,
statusInfoChecker: makeValueChecker(statusInfoKnown),
validationsChecker: makeJsonChecker(map[validationID]validationCheckResult{
IsReleaseDomainNameResolvedCorrectly: {status: ValidationSuccess, messagePattern: "Domain name resolution for the quay.io domain was successful or not required"},
}),
inventory: hostutil.GenerateMasterInventory(),
domainResolutions: common.TestDomainNameResolutionsSuccess,
errorExpected: false,
addL3Connectivity: true,
},
{
name: "pending to insufficient - release image resolve missing",
validCheckInTime: true,
srcState: models.HostStatusPendingForInput,
dstState: models.HostStatusInsufficient,
machineNetworks: common.TestIPv4Networking.MachineNetworks,
ntpSources: defaultNTPSources,
imageStatuses: map[string]*models.ContainerImageAvailability{common.TestDefaultConfig.ImageName: common.TestImageStatusesSuccess},
role: models.HostRoleWorker,
statusInfoChecker: makeRegexChecker("Couldn't resolve domain name quay.io on the host. To continue installation, create the necessary DNS entries to resolve this domain name to your cluster's release image host IP address"),
validationsChecker: makeJsonChecker(map[validationID]validationCheckResult{
IsReleaseDomainNameResolvedCorrectly: {status: ValidationFailure, messagePattern: "Couldn't resolve domain name quay.io on the host. To continue installation, create the necessary DNS entries to resolve this domain name to your cluster's release image host IP address"},
}),
inventory: hostutil.GenerateMasterInventory(),
domainResolutions: &models.DomainResolutionResponse{Resolutions: funk.Filter(common.TestDomainNameResolutionsSuccess.Resolutions,
func(r *models.DomainResolutionResponseDomain) bool {
return swag.StringValue(r.DomainName) != "quay.io"
}).([]*models.DomainResolutionResponseDomain)},
errorExpected: false,
addL3Connectivity: true,
},
/*
* MGMT-15213: The release domain is not resolved correctly when there is a mirror or proxy. In this case
* validation might fail, but the installation may succeed.
* TODO: MGMT-15213 - Fix the validation bug
{
name: "pending to known - release image resolved correctly",
validCheckInTime: true,
srcState: models.HostStatusPendingForInput,
dstState: models.HostStatusKnown,
machineNetworks: common.TestIPv4Networking.MachineNetworks,
ntpSources: defaultNTPSources,
imageStatuses: map[string]*models.ContainerImageAvailability{common.TestDefaultConfig.ImageName: common.TestImageStatusesSuccess},
role: models.HostRoleWorker,
statusInfoChecker: makeValueChecker(statusInfoKnown),
validationsChecker: makeJsonChecker(map[validationID]validationCheckResult{
IsReleaseDomainNameResolvedCorrectly: {status: ValidationSuccess, messagePattern: "Domain name resolution for the quay.io domain was successful or not required"},
}),
inventory: hostutil.GenerateMasterInventory(),
domainResolutions: common.TestDomainNameResolutionsSuccess,
errorExpected: false,
addL3Connectivity: true,
},
{
name: "pending to insufficient - release image resolve missing",
validCheckInTime: true,
srcState: models.HostStatusPendingForInput,
dstState: models.HostStatusInsufficient,
machineNetworks: common.TestIPv4Networking.MachineNetworks,
ntpSources: defaultNTPSources,
imageStatuses: map[string]*models.ContainerImageAvailability{common.TestDefaultConfig.ImageName: common.TestImageStatusesSuccess},
role: models.HostRoleWorker,
statusInfoChecker: makeRegexChecker("Couldn't resolve domain name quay.io on the host. To continue installation, create the necessary DNS entries to resolve this domain name to your cluster's release image host IP address"),
validationsChecker: makeJsonChecker(map[validationID]validationCheckResult{
IsReleaseDomainNameResolvedCorrectly: {status: ValidationFailure, messagePattern: "Couldn't resolve domain name quay.io on the host. To continue installation, create the necessary DNS entries to resolve this domain name to your cluster's release image host IP address"},
}),
inventory: hostutil.GenerateMasterInventory(),
domainResolutions: &models.DomainResolutionResponse{Resolutions: funk.Filter(common.TestDomainNameResolutionsSuccess.Resolutions,
func(r *models.DomainResolutionResponseDomain) bool {
return swag.StringValue(r.DomainName) != "quay.io"
}).([]*models.DomainResolutionResponseDomain)},
errorExpected: false,
addL3Connectivity: true,
},
*/
}

for _, hostTest := range []struct {
Expand Down
216 changes: 110 additions & 106 deletions internal/host/validations_test.go
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/openshift/assisted-service/internal/versions"
"github.com/openshift/assisted-service/models"
"github.com/openshift/assisted-service/pkg/conversions"
"github.com/pkg/errors"
"github.com/vincent-petithory/dataurl"
"gorm.io/gorm"
)
Expand Down Expand Up @@ -927,118 +926,123 @@ var _ = Describe("Validations test", func() {
}
}
})
Describe("Release image validation", func() {
tests := []*struct {
name string
testHostResolvedDNS bool
expectedStatus ValidationStatus
expectedMessage string
releaseImageErrored bool
releaseImage string
isDay2 bool
}{
{
name: "successful resolution",
testHostResolvedDNS: true,
expectedStatus: ValidationSuccess,
releaseImage: "quay.io/openshift/some-image:latest",
expectedMessage: "Domain name resolution for the quay.io domain was successful or not required",
},
{
name: "successful resolution with port",
testHostResolvedDNS: true,
expectedStatus: ValidationSuccess,
releaseImage: "quay.io:5000/openshift/some-image:latest",
expectedMessage: "Domain name resolution for the quay.io domain was successful or not required",
},
{
name: "failed resolution",
testHostResolvedDNS: false,
releaseImage: "quay.io/openshift/some-image:latest",
expectedStatus: ValidationFailure,
expectedMessage: "Couldn't resolve domain name quay.io on the host. To continue installation, create the necessary DNS entries to resolve this domain name to your cluster's release image host IP address",
},
{
name: "IP and not domain",
testHostResolvedDNS: false,
releaseImage: "1.2.3.4/openshift/some-image:latest",
expectedStatus: ValidationSuccess,
expectedMessage: "Release host 1.2.3.4 is an IP address",
},
{
name: "error getting release image",
testHostResolvedDNS: true,
releaseImageErrored: true,
expectedStatus: ValidationError,
expectedMessage: fmt.Sprintf("failed to get release domain for cluster %s", clusterID.String()),
},
{
name: "successful day2 host",
expectedStatus: ValidationSuccess,
isDay2: true,
expectedMessage: "host belongs to day2 cluster",
},
}
for i := range tests {
t := tests[i]
It(t.name, func() {
resolutions := common.TestDomainNameResolutionsSuccess
if !t.testHostResolvedDNS {
resolutions = common.TestDomainResolutionsAllEmpty
}
// Create test cluster
createTestCluster := func() {
var testCluster *common.Cluster
if t.isDay2 {
testCluster = generateDay2Cluster()
} else {
day1Cluster := hostutil.GenerateTestCluster(clusterID)
testCluster = &day1Cluster
/*
* MGMT-15213: The release domain is not resolved correctly when there is a mirror or proxy. In this case
* validation might fail, but the installation may succeed.
* TODO: MGMT-15213 - Fix the validation bug
Describe("Release image validation", func() {
tests := []*struct {
name string
testHostResolvedDNS bool
expectedStatus ValidationStatus
expectedMessage string
releaseImageErrored bool
releaseImage string
isDay2 bool
}{
{
name: "successful resolution",
testHostResolvedDNS: true,
expectedStatus: ValidationSuccess,
releaseImage: "quay.io/openshift/some-image:latest",
expectedMessage: "Domain name resolution for the quay.io domain was successful or not required",
},
{
name: "successful resolution with port",
testHostResolvedDNS: true,
expectedStatus: ValidationSuccess,
releaseImage: "quay.io:5000/openshift/some-image:latest",
expectedMessage: "Domain name resolution for the quay.io domain was successful or not required",
},
{
name: "failed resolution",
testHostResolvedDNS: false,
releaseImage: "quay.io/openshift/some-image:latest",
expectedStatus: ValidationFailure,
expectedMessage: "Couldn't resolve domain name quay.io on the host. To continue installation, create the necessary DNS entries to resolve this domain name to your cluster's release image host IP address",
},
{
name: "IP and not domain",
testHostResolvedDNS: false,
releaseImage: "1.2.3.4/openshift/some-image:latest",
expectedStatus: ValidationSuccess,
expectedMessage: "Release host 1.2.3.4 is an IP address",
},
{
name: "error getting release image",
testHostResolvedDNS: true,
releaseImageErrored: true,
expectedStatus: ValidationError,
expectedMessage: fmt.Sprintf("failed to get release domain for cluster %s", clusterID.String()),
},
{
name: "successful day2 host",
expectedStatus: ValidationSuccess,
isDay2: true,
expectedMessage: "host belongs to day2 cluster",
},
}
for i := range tests {
t := tests[i]
It(t.name, func() {
resolutions := common.TestDomainNameResolutionsSuccess
if !t.testHostResolvedDNS {
resolutions = common.TestDomainResolutionsAllEmpty
}
// Create test cluster
createTestCluster := func() {
var testCluster *common.Cluster
if t.isDay2 {
testCluster = generateDay2Cluster()
} else {
day1Cluster := hostutil.GenerateTestCluster(clusterID)
testCluster = &day1Cluster
}
Expect(db.Create(&testCluster).Error).ShouldNot(HaveOccurred())
}
Expect(db.Create(&testCluster).Error).ShouldNot(HaveOccurred())
}
createTestCluster()
var host *models.Host
if !t.isDay2 {
day1Host := hostutil.GenerateTestHost(hostID, infraEnvID, clusterID, models.HostStatusDiscovering)
host = &day1Host
} else {
host = getDay2Host()
}
setHostDomainResolutions(host, resolutions)
Expect(db.Create(host).Error).ShouldNot(HaveOccurred())
if !t.isDay2 {
if t.releaseImageErrored == false {
mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(&models.ReleaseImage{URL: swag.String(t.releaseImage)}, nil).Times(1)
createTestCluster()
var host *models.Host
if !t.isDay2 {
day1Host := hostutil.GenerateTestHost(hostID, infraEnvID, clusterID, models.HostStatusDiscovering)
host = &day1Host
} else {
mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(&models.ReleaseImage{}, errors.New("blah")).Times(1)
host = getDay2Host()
}
setHostDomainResolutions(host, resolutions)
Expect(db.Create(host).Error).ShouldNot(HaveOccurred())
if !t.isDay2 {
if t.releaseImageErrored == false {
mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(&models.ReleaseImage{URL: swag.String(t.releaseImage)}, nil).Times(1)
} else {
mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Return(&models.ReleaseImage{}, errors.New("blah")).Times(1)
}
}
}
// Process validations
mockAndRefreshStatus(host)
// Process validations
mockAndRefreshStatus(host)
// Get processed host from database
hostFromDatabase := hostutil.GetHostFromDB(*host.ID, host.InfraEnvID, db).Host
// Get processed host from database
hostFromDatabase := hostutil.GetHostFromDB(*host.ID, host.InfraEnvID, db).Host
// Verify host validations
validationStatus, validationMessage, found := getValidationResult(hostFromDatabase.ValidationsInfo, IsReleaseDomainNameResolvedCorrectly)
Expect(found).To(BeTrue())
Expect(validationStatus).To(Equal(t.expectedStatus),
fmt.Sprintf("Validation status was not as expected, message: %s", validationMessage))
var expectedMessage string
if t.releaseImageErrored {
expectedMessage = fmt.Sprintf("failed to get release domain for cluster %s", clusterID.String())
} else {
expectedMessage = t.expectedMessage
}
Expect(validationMessage).To(Equal(expectedMessage))
})
}
})
// Verify host validations
validationStatus, validationMessage, found := getValidationResult(hostFromDatabase.ValidationsInfo, IsReleaseDomainNameResolvedCorrectly)
Expect(found).To(BeTrue())
Expect(validationStatus).To(Equal(t.expectedStatus),
fmt.Sprintf("Validation status was not as expected, message: %s", validationMessage))
var expectedMessage string
if t.releaseImageErrored {
expectedMessage = fmt.Sprintf("failed to get release domain for cluster %s", clusterID.String())
} else {
expectedMessage = t.expectedMessage
}
Expect(validationMessage).To(Equal(expectedMessage))
})
}
})
*/
Context("Disk encryption validation", func() {
BeforeEach(func() {
mockVersions.EXPECT().GetReleaseImage(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
Expand Down
6 changes: 6 additions & 0 deletions internal/host/validator.go
Expand Up @@ -1528,6 +1528,11 @@ func checkDomainNameResolution(c *validationContext, domainName, printableDomain
return ValidationFailure, fmt.Sprintf("Couldn't resolve domain name %s on the host. To continue installation, create the necessary DNS entries to resolve this domain name to your cluster's %s IP address", printableDomain, target)
}

/*
* MGMT-15213: The release domain is not resolved correctly when there is a mirror or proxy. In this case
* validation might fail, but the installation may succeed.
* TODO: MGMT-15213 - Fix the validation bug
func (v *validator) isReleaseDomainResolvedCorrectly(c *validationContext) (ValidationStatus, string) {
if c.cluster == nil {
return ValidationSuccess, "host is unbound"
Expand All @@ -1544,6 +1549,7 @@ func (v *validator) isReleaseDomainResolvedCorrectly(c *validationContext) (Vali
}
return checkDomainNameResolution(c, releaseImageHost, releaseImageHost, "release image host")
}
*/

func checkUnexpectedDomain(c *validationContext, response *models.DomainResolutionResponse, domainName, messageFormat string) (ValidationStatus, string) {
domainResolution, _ := funk.Find(response.Resolutions,
Expand Down

0 comments on commit b0797da

Please sign in to comment.