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

feat/chore: Add App Delete Functionality and Refactor Code #36

Merged
merged 2 commits into from
Oct 17, 2023

Conversation

arkaprovob
Copy link
Contributor

This pull request is for the following changes:

  1. Add App Delete Functionality:

    • Introduces the App Delete feature, following the same process as application distribution upload.
    • During app deletion, the distribution zip file includes only the splaship.yaml file with the target application name and mandatory details related to the application.
    • Sets the exclude flag to true for deleted apps.
  2. **Refactor Code Following App Delete Functionality Addition: **

    • Refactors the codebase to improve readability and maintainability.
    • No changes in functionality, only code organization and style enhancements.

Introduces the app delete feature, following the same process as application distribution upload. For deleting an app the dist zip file will include only the spaship.yaml file with the target application name and mandatory details. Also, exclude from environment is set to 'true'.
@arkaprovob arkaprovob added enhancement New feature or request chore labels Oct 6, 2023
@arkaprovob arkaprovob self-assigned this Oct 6, 2023
EventManager eventManager, @Named("deNamespace") String ns) {
this.ocClient = ocClient;
this.eventManager = eventManager;
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

@arkaprovob can you use a variable instead of directly using the string?

private static final String OPERATOR_DOMAIN_NAME = "operator.domain.name";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great observation, Soumya! I've created a GitHub issue for this. Instead of modifying just this file, let's consider refactoring other classes to ensure that these changes are applied consistently throughout, Let's handle it separately.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@soumyadip007 soumyadip007 left a comment

Choose a reason for hiding this comment

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

@arkaprovob I've added a few comments in this PR. Please check

this.ocClient = ocClient;
this.eventManager = eventManager;
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class);
routerDomain = ConfigProvider.getConfig().getValue("operator.router.domain.name", String.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

private static final String OPERATOR_DOMAIN_NAME = "operator.domain.name";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great observation, Soumya! I've created a GitHub issue for this. Instead of modifying just this file, let's consider refactoring other classes to ensure that these changes are applied consistently throughout, Let's handle it separately.

Copy link
Contributor

Choose a reason for hiding this comment

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


ReUsableItems.releaseLock(environment.getIdentification());
LOG.debug("\n");
// todo change the status code type to enum instead of int for better readability
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional : As you are following // TODO: format in the entire code, you can format // todo with // TODO:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created an issue for the same #38

Copy link
Contributor

Choose a reason for hiding this comment

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

ack

if (!envExists)
createNewEnvironment(environment);
String sideCarSvcUrl = environmentSidecarUrl(environment);
// todo mutability is not good, we should not change the state of the object
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional : As you are following // TODO: format in the entire code, you can format // todo with // TODO:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

created an issue for the same #38

Copy link
Contributor

Choose a reason for hiding this comment

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

ack

private void createNewTenantNamespace(Environment environment, Map<String, String> templateParameters) {
var k8sNSList = ocClient
.templates()
.load(Operations.class.getResourceAsStream("/openshift/mpp-namespace-template.yaml"))
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please add this path to a variable ? (also if possible you can provide an option to read this path from the env variable if you think it's feasible)

private final String OPENSHIFT_NAMESPACE_PATH = "/openshift/mpp-namespace-template.yaml";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good observation I have created a GitHub issue for the same.

}
if (item instanceof PersistentVolumeClaim pvc) {
LOG.debug("creating new pvc in K8s, tracing = {}", tracing);
ocClient.persistentVolumeClaims().inNamespace(nameSpace).createOrReplace(pvc);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note : There might be a potential issue of exception, can we handle it here ! (Optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As long as the parameter of the function KubernetesList result not null, there should be no other issues, thanks to Fabric8 library handling the rest.
I have created #45 to add a null check for the 'KubernetesList result' parameter.

}
if (item instanceof Route route) {
LOG.debug("creating new Route in K8s, tracing = {}", tracing);
ocClient.routes().inNamespace(nameSpace).createOrReplace(route);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note : There might be a potential issue of exception, can we handle it here ! (Optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As long as the parameter of the function KubernetesList result not null, there should be no other issues, thanks to Fabric8 library handling the rest.
I have created this issue to add a null check for the 'KubernetesList result' parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

}
if (item instanceof ConfigMap cm) {
LOG.debug("creating new ConfigMap in K8s, tracing = {}", tracing);
ocClient.configMaps().inNamespace(nameSpace).createOrReplace(cm);
Copy link
Contributor

Choose a reason for hiding this comment

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

Note : There might be a potential issue of exception, can we handle it here ! (Optional)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As long as the parameter of the function KubernetesList result not null, there should be no other issues, thanks to Fabric8 library handling the rest.
I have created #45 to add a null check for the 'KubernetesList result' parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@soumyadip007 soumyadip007 left a comment

Choose a reason for hiding this comment

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

Hi @arkaprovob , I've gone through you comments. Thanks for creating the respected issues against the comments. We'll go through it and resolve these as a separate issue.

EventManager eventManager, @Named("deNamespace") String ns) {
this.ocClient = ocClient;
this.eventManager = eventManager;
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

this.ocClient = ocClient;
this.eventManager = eventManager;
domain = ConfigProvider.getConfig().getValue("operator.domain.name", String.class);
routerDomain = ConfigProvider.getConfig().getValue("operator.router.domain.name", String.class);
Copy link
Contributor

Choose a reason for hiding this comment

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


ReUsableItems.releaseLock(environment.getIdentification());
LOG.debug("\n");
// todo change the status code type to enum instead of int for better readability
Copy link
Contributor

Choose a reason for hiding this comment

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

ack

if (!envExists)
createNewEnvironment(environment);
String sideCarSvcUrl = environmentSidecarUrl(environment);
// todo mutability is not good, we should not change the state of the object
Copy link
Contributor

Choose a reason for hiding this comment

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

ack

String type = (String) rule.get("type");
Map<String, Object> to = (Map<String, Object>) rule.get("to");
String cidrSelectorName = (String) to.get("cidrSelector");
return "0.0.0.0/0".equals(cidrSelectorName) && type.equalsIgnoreCase("Deny");
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay make sense

}
if (item instanceof Route route) {
LOG.debug("creating new Route in K8s, tracing = {}", tracing);
ocClient.routes().inNamespace(nameSpace).createOrReplace(route);
Copy link
Contributor

Choose a reason for hiding this comment

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

}
if (item instanceof ConfigMap cm) {
LOG.debug("creating new ConfigMap in K8s, tracing = {}", tracing);
ocClient.configMaps().inNamespace(nameSpace).createOrReplace(cm);
Copy link
Contributor

Choose a reason for hiding this comment

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

@soumyadip007 soumyadip007 merged commit 172cf9c into spaship:main Oct 17, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants