Skip to content

Owls104087 (refactored) fix an intermitent failure in ItKubernetesDomainEvents#testK8SEventsDelete #3704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Dec 1, 2022

Conversation

doxiao
Copy link
Member

@doxiao doxiao commented Nov 29, 2022

The PR fixes an intermittent issue in nightly where the ClusterDeleted event is missing when deleting a domain and cluster resources. This PR includes all in #3704, plus refactoring of DomainPresenceInfo (see the last item in the list below).

  • Generate ClusterCreated/Deleted/Changed events no matter if the cluster is not referenced by any domain.
  • When a cluster is referenced by a domain, the ClusterCreated/Deleted/Changed events are generated in a cluster-event-only MakeRightOperation followed by a regular MakeRightOperation to do the necessary domain processing.
  • Refactor the code to have a common ResourcePresenceInfo as the base of DomainPresenceInfo and ClusterPresenceInfo, and to have a MakeRightOperation as the base of MakeRightDomainOperation and MakeRightClusterOperation.

https://build.weblogick8s.org:8443/job/weblogic-kubernetes-operator-kind-new/14221/

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 29, 2022
@doxiao doxiao marked this pull request as ready for review November 29, 2022 19:29
/**
* Operator's mapping between custom resource Domain and runtime details about that domain,
* including the scan and the Pods and Services for servers.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Operator's mapping between custom resource Domain and runtime details about that domain -> "Operator's mapping between custom resource cluster and runtime details about that cluster."

private final ClusterResource cluster;

/**
* Create presence for a domain.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create presence for a domain -> Create presence for a cluster.

/**
* Operator's mapping between custom resource Domain and runtime details about that domain,
* including the scan and the Pods and Services for servers.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can either be mapping between the Domain or Cluster custom resource.

final String namespace;

/**
* Create presence for a domain.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be a cluster.

@@ -27,6 +28,10 @@ public ThreadLoggingContext presenceInfo(DomainPresenceInfo info) {
return namespace(info.getNamespace()).domainUid(info.getDomainUid());
}

public ThreadLoggingContext presenceInfo(ClusterPresenceInfo info) {
return namespace(info.getNamespace());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be confusing when there are multiple clusters (potential with same name) in the same namespace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can have multiple same-named clusters in the same namespace; K8S disallows it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. As we discussed, I meant the name of the cluster itself and not the name of the cluster resource. Should we also include the cluster resource name is the ThreadLoggingContext?

Copy link
Member Author

@doxiao doxiao Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We probably should if we also want the cluster resource name to be in the logging headers. But we need to do a thorough investigation to identify the log messages that need to have the cluster resource name as a header. I would suggest we do that as a separate task.

import oracle.kubernetes.operator.MakeRightOperation;

/**
* A factory which creates and executes steps to align the cached domain status with the value read from Kubernetes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cached domain status -> cached domain and cluster status.

import oracle.kubernetes.operator.work.Step;

/**
* A factory which creates and executes steps to align the cached domain status with the value read from Kubernetes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cached domain status -> cached cluster status.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All comments in javadoc have been addressed. thanks.

@@ -337,7 +341,7 @@ public static Step bringAdminServerUp(DomainPresenceInfo info, PodAwaiterStepFac

@Override
public void runMakeRight(MakeRightDomainOperation operation) {
final DomainPresenceInfo liveInfo = operation.getPresenceInfo();
final DomainPresenceInfo liveInfo = (DomainPresenceInfo) operation.getPresenceInfo();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding generics to MakeRightOperation to remove the need of this cast. Please see suggested changes at 54122bb

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. will do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@ankedia ankedia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.9% 92.9% Coverage
0.0% 0.0% Duplication

@rjeberhard rjeberhard merged commit 31b8677 into main Dec 1, 2022
@rjeberhard rjeberhard deleted the owls104087-fix-new2 branch December 1, 2022 12:27
rjeberhard pushed a commit to rjeberhard/weblogic-kubernetes-operator that referenced this pull request Apr 14, 2023
…ainEvents#testK8SEventsDelete (oracle#3704)

* Generate cluster Created/Deleted/Changed events for unreferenced cluster resources

Co-authored-by: Anthony Lai <anthony.lai@oracle.com>
robertpatrick pushed a commit that referenced this pull request Apr 26, 2023
…ainEvents#testK8SEventsDelete (#3704)

* Generate cluster Created/Deleted/Changed events for unreferenced cluster resources

Co-authored-by: Anthony Lai <anthony.lai@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants