Skip to content
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

Fix #2399: Cannot change the type of the Service from ClusterIP to ExternalName #2472

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

rohanKanojia
Copy link
Member

@rohanKanojia rohanKanojia commented Sep 9, 2020

Description

Fix #2399

Removes overridden replace() method in ServiceOperationsImpl

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@rohanKanojia rohanKanojia changed the title Fix #2399: Cannot change the type of the Service from ClusterIP to Ex… Fix #2399: Cannot change the type of the Service from ClusterIP to ExternalName Sep 9, 2020
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (1.8.0_265) you have used to run this analysis is deprecated and we will stop accepting it from October 2020. Please update to at least Java 11.
Read more here

@manusa
Copy link
Member

manusa commented Sep 16, 2020

[merge]

// When
svc.getSpec().setType("ExternalName");
svc.getSpec().setExternalName("my.database.example.com");
svc.getSpec().setClusterIP("");
Copy link
Contributor

Choose a reason for hiding this comment

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

No assertion for ClusterIP ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Services of type ExternalName don't need ClusterIP, API Servers enforces the ClusterIP field to be empty when editing the 'type' field from ClusterIP to ExternalName

}

@Test
public void testClusterIPCreateOrReplace() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The name is a bit misleading.. can we change it to testClusterIpServiceCreateOrReplace ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I'll create a follow up PR with your suggested changes

}

@Test
public void testNodePortCreateOrReplace() {
Copy link
Contributor

Choose a reason for hiding this comment

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

same thing with the name

// Then
assertNotNull(clusterIPSvc);
assertEquals("NodePort", clusterIPSvc.getSpec().getType());
assertEquals(81, clusterIPSvc.getSpec().getPorts().get(0).getTargetPort().getIntVal().intValue());
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also check for the NodePort value created.

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 added this assertion to check whether what I modified in When phase is actually reflected or not. But yes, I can try doing something with NodePort too

}

@Test
public void testLoadBalancerCreateOrReplace() {
Copy link
Contributor

Choose a reason for hiding this comment

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

name

}

@Test
public void testExternalNameCreateOrReplace() {
Copy link
Contributor

Choose a reason for hiding this comment

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

name

@fusesource-ci fusesource-ci merged commit fd6f17f into fabric8io:master Sep 16, 2020
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this pull request Sep 16, 2020
This PR addresses review comments added in fabric8io#2472 which were added after PR actually
got merged
} catch (Exception e) {
throw KubernetesClientException.launderThrowable(forOperationType("patch"), e);
}
try {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the patch also work with ExternalName?

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 think you're right. Could you please create an issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot change the type of the Service from ClusterIP to ExternalName
6 participants