49
49
import oracle .kubernetes .operator .processing .EffectiveClusterSpec ;
50
50
import oracle .kubernetes .operator .processing .EffectiveIntrospectorJobPodSpec ;
51
51
import oracle .kubernetes .operator .processing .EffectiveServerSpec ;
52
+ import oracle .kubernetes .utils .SystemClock ;
52
53
import oracle .kubernetes .weblogic .domain .EffectiveConfigurationFactory ;
53
54
import org .apache .commons .lang3 .builder .EqualsBuilder ;
54
55
import org .apache .commons .lang3 .builder .HashCodeBuilder ;
@@ -964,7 +965,7 @@ public List<String> getFatalValidationFailures() {
964
965
}
965
966
966
967
// used by the operator
967
- public List < String > getValidationFailures (KubernetesResourceLookup kubernetesResources ) {
968
+ public ValidationResult getValidationFailures (KubernetesResourceLookup kubernetesResources ) {
968
969
return new DomainValidator ().getValidationFailures (kubernetesResources );
969
970
}
970
971
@@ -1038,14 +1039,18 @@ public int getMaxConcurrentShutdown(ClusterSpec clusterSpec) {
1038
1039
}
1039
1040
}
1040
1041
1042
+ public static record ValidationResult (List <String > failures , boolean isDelay ) {
1043
+ }
1044
+
1041
1045
class DomainValidator extends Validator {
1042
1046
private final Set <String > clusterNames = new HashSet <>();
1043
1047
private final Set <String > serverNames = new HashSet <>();
1048
+ private boolean isDelay ;
1044
1049
1045
- private List < String > getValidationFailures (KubernetesResourceLookup kubernetesResources ) {
1050
+ private ValidationResult getValidationFailures (KubernetesResourceLookup kubernetesResources ) {
1046
1051
addFatalValidationFailures ();
1047
1052
addCrossReferenceValidationFailures (kubernetesResources );
1048
- return failures ;
1053
+ return new ValidationResult ( failures , isDelay ) ;
1049
1054
}
1050
1055
1051
1056
private void addCrossReferenceValidationFailures (KubernetesResourceLookup kubernetesResources ) {
@@ -1542,16 +1547,27 @@ private void addMissingClusterResource(KubernetesResourceLookup resourceLookup)
1542
1547
.forEach (cluster -> verifyClusterExists (resourceLookup , cluster ));
1543
1548
}
1544
1549
1550
+ private boolean isRecentlyCreatedDomain () {
1551
+ return Optional .ofNullable (getMetadata ()).map (V1ObjectMeta ::getCreationTimestamp )
1552
+ .map (timestamp -> timestamp .isAfter (SystemClock .now ().minusSeconds (10 ))).orElse (false );
1553
+ }
1554
+
1545
1555
private void verifyClusterExists (KubernetesResourceLookup resourceLookup , V1LocalObjectReference cluster ) {
1546
1556
if (resourceLookup .findClusterInNamespace (cluster , getNamespace ()) == null ) {
1547
1557
failures .add (missingClusterResource (cluster .getName (), getNamespace ()));
1558
+ if (isRecentlyCreatedDomain ()) {
1559
+ isDelay = true ;
1560
+ }
1548
1561
}
1549
1562
}
1550
1563
1551
1564
@ SuppressWarnings ("SameParameterValue" )
1552
1565
private void verifySecretExists (KubernetesResourceLookup resources , String secretName , SecretType type ) {
1553
1566
if (secretName != null && !isSecretExists (resources .getSecrets (), secretName , getNamespace ())) {
1554
1567
failures .add (DomainValidationMessages .noSuchSecret (secretName , getNamespace (), type ));
1568
+ if (isRecentlyCreatedDomain ()) {
1569
+ isDelay = true ;
1570
+ }
1555
1571
}
1556
1572
}
1557
1573
@@ -1611,6 +1627,9 @@ private void verifyModelConfigMapExists(KubernetesResourceLookup resources, Stri
1611
1627
&& modelConfigMapName != null && !resources .isConfigMapExists (modelConfigMapName , getNamespace ())) {
1612
1628
failures .add (DomainValidationMessages .noSuchModelConfigMap (modelConfigMapName ,
1613
1629
"spec.configuration.model.configMap" , getNamespace ()));
1630
+ if (isRecentlyCreatedDomain ()) {
1631
+ isDelay = true ;
1632
+ }
1614
1633
}
1615
1634
}
1616
1635
@@ -1621,6 +1640,9 @@ && getDomainCreationConfigMap() != null
1621
1640
&& !resources .isConfigMapExists (configMapName , getNamespace ())) {
1622
1641
failures .add (DomainValidationMessages .noSuchModelConfigMap (configMapName ,
1623
1642
"spec.configuration.initializeDomainOnPV.domain.domainCreationConfigMap" , getNamespace ()));
1643
+ if (isRecentlyCreatedDomain ()) {
1644
+ isDelay = true ;
1645
+ }
1624
1646
}
1625
1647
}
1626
1648
@@ -1629,9 +1651,15 @@ private void verifyVolumeWithPVCWhenInitDomainOnPVDefined() {
1629
1651
if (isPVCConfigured ()) {
1630
1652
if (noMatchVolumeWithPVC (getInitPvDomainPVCName ())) {
1631
1653
failures .add (DomainValidationMessages .noMatchVolumeWithPVC (getInitPvDomainPVCName ()));
1654
+ if (isRecentlyCreatedDomain ()) {
1655
+ isDelay = true ;
1656
+ }
1632
1657
}
1633
1658
} else if (noVolumeWithPVC ()) {
1634
1659
failures .add (DomainValidationMessages .noVolumeWithPVC ());
1660
+ if (isRecentlyCreatedDomain ()) {
1661
+ isDelay = true ;
1662
+ }
1635
1663
}
1636
1664
}
1637
1665
}
0 commit comments